Changeset 242

Show
Ignore:
Timestamp:
05/27/07 14:49:11 (2 years ago)
Author:
e.@brainspl.at
Message:

convert all framework specs to use describe/it instead of context/specify. new const MERB_VIEW_ROOT to optimize rendering a tad

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/TODO

    r135 r242  
    11[TODO] 
    2 * Irb Console **DONE** 
    3 * Migrations **DONE** 
    4 * Helpers 
    5 * config file **DONE** 
    6 * session 
    7   ** AR ** DONE ** 
    8   ** DRb 
    9 * Rails integration 
    10 * Text backend? 
    11 * plugins support(rails plugins too?) 
    12 * Layouts **DONE** 
    13 * auto template_dir **DONE** 
    14 * before/after filters **DONE** 
    15 * merbjs **DONE** 
    16 * testing 
     2* more specs for Template engines and Rendering 
     3*  
  • trunk/lib/merb.rb

    r241 r242  
    5252DIST_ROOT = Merb::Server.dist_root || Dir.pwd+'/dist' 
    5353MERB_ENV  = Merb::Server.config[:environment] 
     54MERB_VIEW_ROOT = MERB_ROOT / "dist/app/views" 
    5455 
    5556logpath = $TESTING ? "/tmp/merb_test.log" : "#{MERB_ROOT}/log/merb.#{Merb::Server.port}.log" 
  • trunk/lib/merb/merb_controller.rb

    r238 r242  
    2222    self._session_id_key = :_session_id 
    2323    self._template_extensions = { } 
    24     self._template_root = File.expand_path(MERB_ROOT / "dist/app/views"
    25     self._layout_root   = File.expand_path(MERB_ROOT / "dist/app/views/layout") 
     24    self._template_root = File.expand_path(MERB_VIEW_ROOT
     25    self._layout_root   = File.expand_path(MERB_VIEW_ROOT / "layout") 
    2626     
    2727    include Merb::ControllerMixin 
  • trunk/lib/merb/mixins/render_mixin.rb

    r240 r242  
    165165      def find_template(opts={}) 
    166166        if template = opts[:template] 
    167           path = MERB_ROOT / "dist/app/views" / template 
     167          path = MERB_VIEW_ROOT / template 
    168168        elsif action = opts[:action] 
    169169          path = 
    170             File.expand_path(MERB_ROOT / "dist/app/views" / self.class.name.snake_case / action) 
     170            File.expand_path(MERB_VIEW_ROOT / self.class.name.snake_case / action) 
    171171        elsif _layout = opts[:layout] 
    172172          path = _layout_root / _layout 
  • trunk/specs/merb/merb_controller_filters_spec.rb

    r173 r242  
    3838end 
    3939 
    40 context "Dispatch and before/after filters" do 
     40describe "Dispatch and before/after filters" do 
    4141 
    42   setup do 
     42  before :each do 
    4343    @in = Merb::MockRequest.new 
    4444    @res = StringIO.new 
    4545  end 
    4646 
    47   specify ":symbol before filter is called" do 
     47  it "should call a :symbol before filter" do 
    4848    c = TestFiltersController.new(@in.req, @in.env,{:controller => 'TestFiltersController', :action => 'one'}, @res) 
    4949    c.dispatch(:one) 
     
    5454  end 
    5555   
    56   specify "Proc before filter is called" do 
     56  it "should call a Proc before filter" do 
    5757    c = TestFiltersController.new(@in.req, @in.env,{:controller => 'TestFiltersController', :action => 'two'}, @res) 
    5858    c.dispatch(:two) 
     
    6363  end 
    6464   
    65   specify "filters_halted is called when throw :halt" do 
     65  it "should call filters_halted when throw :halt" do 
    6666    c = TestFiltersController.new(@in.req, @in.env,{:controller => 'TestFiltersController', :action => 'four'}, @res) 
    6767    c.dispatch(:four) 
  • trunk/specs/merb/merb_controller_spec.rb

    r232 r242  
    88context "Merb::Controller" do 
    99         
    10   setup do 
     10  before :each do 
    1111    @in = Merb::MockRequest.new 
    1212    @res = StringIO.new 
    1313  end 
    1414   
    15   teardown do 
     15  after :each do 
    1616    @in = nil 
    1717    @res=nil 
    1818  end 
    1919   
    20   specify "should instantiate" do 
     20  it "should instantiate" do 
    2121    c = Merb::Controller.new @in.req, @in.env,{:controller => 'Test', :action => 'foo'}, @res 
    2222    @in.env.should == c.instance_variable_get( "@env")  
    2323  end 
    2424   
    25   specify "Default layout should be application.rhtml" do 
     25  it "Default layout should be application.rhtml" do 
    2626    c = Merb::Controller.new @in.req, @in.env,{}, @res 
    2727    c._layout.should == :application 
    2828  end   
    2929   
    30   specify "Post body is parsed into params" do 
     30  it "Post body is parsed into params" do 
    3131    @in.post_body = "title=hello%20there&body=some%20text&commit=Submit" 
    3232    @in['REQUEST_METHOD'] = 'POST' 
     
    3737  end   
    3838     
    39   specify "Query String is parsed into params" do 
     39  it "Query String is parsed into params" do 
    4040    @in['QUERY_STRING'] = "title=hello%20there&body=some%20text&commit=Submit" 
    4141    c = Merb::Controller.new @in.req, @in.env,{:controller => 'Test', :action => 'foo'}, @res 
     
    4545  end    
    4646   
    47   specify "multipart/form-data handles file upload" do 
     47  it "multipart/form-data handles file upload" do 
    4848    m = Multipart::Post.new 
    4949    p = { :file => File.open(FIXTURES / 'sample.txt') } 
     
    5959  end 
    6060   
    61   specify "multipart/form-data handles multiple form fields" do 
     61  it "multipart/form-data handles multiple form fields" do 
    6262    m = Multipart::Post.new 
    6363    p = {:foo => 'bario', 'files[]' => File.open(FIXTURES / 'sample.txt'), 
     
    7575  end 
    7676 
    77   specify "multipart/form-data handles hash-style form fields" do 
     77  it "multipart/form-data handles hash-style form fields" do 
    7878    m = Multipart::Post.new 
    7979    p = {:foo => 'bario', 'files[foo]' => File.open(FIXTURES / 'sample.txt'), 
     
    9090  end 
    9191   
    92   specify "Json Post Body is parsed into params" do 
     92  it "Json Post Body is parsed into params" do 
    9393    @in.post_body = "{\"title\":\"hello there\",\"body\":\"some text\"}" 
    9494    @in['REQUEST_METHOD'] = 'POST' 
  • trunk/specs/merb/merb_dispatch_spec.rb

    r241 r242  
    11require File.dirname(__FILE__) + '/../spec_helper' 
    22require File.dirname(__FILE__) + '/../mock_request' 
    3  
     3require File.dirname(__FILE__) + '/../fixtures/controllers/dispatch_spec_controllers' 
    44$TESTING = true 
    55 
    6 class Foo < Merb::Controller 
     6describe Merb::Dispatcher do 
    77 
    8   def index 
    9     "index" 
    10   end 
    11    
    12   def bar 
    13     "bar" 
    14   end 
    15  
    16 end 
    17  
    18 class Posts < Merb::Controller 
    19   # GET /posts 
    20   # GET /posts.xml 
    21   def index() :index end 
    22   # GET /posts/1 
    23   # GET /posts/1.xml 
    24   def show() :show end 
    25   # GET /posts/new 
    26   def new() :new end 
    27   # GET /posts/1;edit 
    28   def edit() :edit end 
    29   # POST /posts 
    30   # POST /posts.xml 
    31   def create() :create end 
    32   # PUT /posts/1 
    33   # PUT /posts/1.xml 
    34   def update() :update end 
    35   # DELETE /posts/1 
    36   # DELETE /posts/1.xml 
    37   def destroy() :destroy end 
    38   # GET /posts/1;stats 
    39   # PUT /posts/1;stats 
    40   def stats() :stats end   
    41   # GET /posts;filter   
    42   def filter() :filter end   
    43 end 
    44  
    45 class As < Merb::Controller 
    46   # GET /as 
    47   # GET /as.xml 
    48   def index() :index end 
    49   # GET /as/1 
    50   # GET /as/1.xml 
    51   def show() :show end 
    52   # GET /as/new 
    53   def new() :new end 
    54   # GET /as/1;edit 
    55   def edit() :edit end 
    56   # POST /as 
    57   # POST /as.xml 
    58   def create() :create end 
    59   # PUT /as/1 
    60   # PUT /as/1.xml 
    61   def update() :update end 
    62   # DELETE /as/1 
    63   # DELETE /as/1.xml 
    64   def destroy() :destroy end  
    65 end 
    66  
    67 class Bs < Merb::Controller 
    68   # GET /as/1/bs 
    69   # GET /as/1/bs.xml 
    70   def index() :index end 
    71   # GET /as/1/bs/1 
    72   # GET /as/1/bs/1.xml 
    73   def show() :show end 
    74   # GET /as/1/bs/new 
    75   def new() :new end 
    76   # GET /as/1/bs/1;edit 
    77   def edit() :edit end 
    78   # POST /as/1/bs 
    79   # POST /as/1/bs.xml 
    80   def create() :create end 
    81   # PUT /as/1/bs/1 
    82   # PUT /as/1/bs/1.xml 
    83   def update() :update end 
    84   # DELETE /as/1/bs/1 
    85   # DELETE /as/1/bs/1.xml 
    86   def destroy() :destroy end  
    87 end 
    88  
    89 class Cs < Merb::Controller 
    90   # GET /as/1/bs/1/cs 
    91   # GET /as/1/bs/1/cs.xml 
    92   def index() :index end 
    93   # GET /as/1/bs/1/cs/1 
    94   # GET /as/1/bs/1/cs/1.xml 
    95   def show() :show end 
    96   # GET /as/1/bs/1/cs/new 
    97   def new() :new end 
    98   # GET /as/1/bs/1/cs/1;edit 
    99   def edit() :edit end 
    100   # POST /as/1/bs/1/cs 
    101   # POST /as/1/bs/1/cs.xml 
    102   def create() :create end 
    103   # PUT /as/1/bs/1/cs/1 
    104   # PUT /as/1/bs/1/cs/1.xml 
    105   def update() :update end 
    106   # DELETE /as/1/bs/1/cs/1 
    107   # DELETE /as/1/bs/1/cs/1.xml 
    108   def destroy() :destroy end  
    109 end 
    110  
    111 class Tags < Merb::Controller 
    112   # GET /tags 
    113   # GET /tags.xml 
    114   def index() :index end 
    115   # GET /tags/1 
    116   # GET /tags/1.xml 
    117   def show() :show end 
    118   # GET /tags/new 
    119   def new() :new end 
    120   # GET /tags/1;edit 
    121   def edit() :edit end 
    122   # POST /tags 
    123   # POST /tags.xml 
    124   def create() :create end 
    125   # PUT /tags/1 
    126   # PUT /tags/1.xml 
    127   def update() :update end 
    128   # DELETE /tags/1 
    129   # DELETE /tags/1.xml 
    130   def destroy() :destroy end 
    131   # GET /tags/1;stats 
    132   # PUT /tags/1;stats 
    133   def stats() :stats end   
    134   # GET /tags;filter   
    135   def filter() :filter end   
    136 end 
    137  
    138 class Comments < Merb::Controller 
    139   # GET /comments 
    140   # GET /comments.xml 
    141   def index() :index end 
    142   # GET /comments/1 
    143   # GET /comments/1.xml 
    144   def show() :show end 
    145   # GET /comments/new 
    146   def new() :new end 
    147   # GET /comments/1;edit 
    148   def edit() :edit end 
    149   # POST /comments 
    150   # POST /comments.xml 
    151   def create() :create end 
    152   # PUT /comments/1 
    153   # PUT /comments/1.xml 
    154   def update() :update end 
    155   # DELETE /comments/1 
    156   # DELETE /comments/1.xml 
    157   def destroy() :destroy end 
    158   # GET /comments/1;stats 
    159   # PUT /comments/1;stats 
    160   def stats() :stats end   
    161 end 
    162  
    163 class Icon < Merb::Controller 
    164   # GET /icon 
    165   # GET /icon.xml 
    166   def show() :show end 
    167   # GET /icon/new 
    168   def new() :new end 
    169   # GET /icon;edit 
    170   def edit() :edit end 
    171   # POST /icon 
    172   # POST /icon.xml 
    173   def create() :create end 
    174   # PUT /icon 
    175   # PUT /icon.xml 
    176   def update() :update end 
    177   # DELETE /icon 
    178   # DELETE /icon.xml 
    179   def destroy() :destroy end 
    180   # GET /icon;stats 
    181   # PUT /icon;stats 
    182   def stats() :stats end 
    183 end   
    184  
    185 class Profile < Merb::Controller 
    186   def show() :show end 
    187 end 
    188  
    189 context "Merb::Dispatcher" do 
    190  
    191   setup do 
     8  before(:each) do 
    1929    Merb::Server.allow_reloading=false 
    19310    Merb::Router.prepare do |r| 
     
    21027    #puts Merb::Router.generator.inspect 
    21128  end   
    212  
    213   def request(verb, path) 
    214     res = StringIO.new 
    215     request = Merb::MockRequest.with( path, :request_method => (verb.to_s.upcase rescue 'GET')) 
    216     route = Merb::Dispatcher.route_path path 
    217     Merb::Dispatcher.stub!(:instantiate_controller).and_return {  
    218       Object.const_get( route[:controller].camel_case ).new(request.body, request.params, route, res) 
    219     } 
    220     Merb::Dispatcher.handle request, res 
    221   end 
    222  
    223   specify "compile_statement should contain router lambda" do 
    224     Merb::Router.compiled_statement.should be_kind_of(String) 
    225     Merb::Router.compiled_statement.should =~ /lambda\{\|path/ 
    226     Merb::Router.compiled_statement.should =~ /@compiled_regexen/ 
    227     Merb::Router.compiled_statement.should =~ /update\(sections\)/ 
    228   end 
    229    
    230   specify "should handle request: GET /foo/bar and return Foo#bar" do 
     29   
     30  it "should handle request: GET /foo/bar and return Foo#bar" do 
    23131    controller, action = request(:get, '/foo/bar') 
    23232    controller.class.should == Foo 
     
    23535  end 
    23636   
    237   specify "should handle request: GET /foo/bar/1.xml and return Foo#bar format xml" do 
     37  it "should handle request: GET /foo/bar/1.xml and return Foo#bar format xml" do 
    23838    controller, action = request(:get, '/foo/bar/1.xml') 
    23939    controller.class.should == Foo 
     
    24343  end 
    24444   
    245   specify "should handle request: GET /foo/bar.xml and return Foo#bar format xml" do 
     45  it "should handle request: GET /foo/bar.xml and return Foo#bar format xml" do 
    24646    controller, action = request(:get, '/foo/bar.xml') 
    24747    controller.class.should == Foo 
     
    25151  end 
    25252   
    253   specify "should handle request: GET /foo.xml and return Foo#index format xml" do 
     53  it "should handle request: GET /foo.xml and return Foo#index format xml" do 
    25454    controller, action = request(:get, '/foo.xml') 
    25555    controller.class.should == Foo 
     
    25959  end 
    26060   
    261   specify "should handle request: GET /foo. and return Foo#index" do 
     61  it "should handle request: GET /foo. and return Foo#index" do 
    26262    controller, action = request(:get, '/foo') 
    26363    controller.class.should == Foo 
     
    26666  end 
    26767   
    268   specify "should handle request: GET /icon and return Icon#show" do 
     68  it "should handle request: GET /icon and return Icon#show" do 
    26969    controller, action = request(:get, '/icon') 
    27070    controller.class.should == Icon 
     
    27373  end 
    27474   
    275   specify "should handle request: GET /icon.xml and return Icon#show format xml" do 
     75  it "should handle request: GET /icon.xml and return Icon#show format xml" do 
    27676    controller, action = request(:get, '/icon.xml') 
    27777    controller.class.should == Icon 
     
    28181  end 
    28282   
    283   specify "should handle request: GET /icon/new and return Icon#new" do 
     83  it "should handle request: GET /icon/new and return Icon#new" do 
    28484    controller, action = request(:get, '/icon/new') 
    28585    controller.class.should == Icon 
     
    28888  end 
    28989   
    290   specify "should handle request: GET /icon;edit and return Icon#edit" do 
     90  it "should handle request: GET /icon;edit and return Icon#edit" do 
    29191    controller, action = request(:get, '/icon;edit') 
    29292    controller.class.should == Icon 
     
    29595  end 
    29696   
    297   specify "should handle request: GET /icon/edit and return Icon#edit" do 
     97  it "should handle request: GET /icon/edit and return Icon#edit" do 
    29898    controller, action = request(:get, '/icon/edit') 
    29999    controller.class.should == Icon 
     
    302102  end 
    303103   
    304   specify "should handle request: POST /icon and return Icon#create" do 
     104  it "should handle request: POST /icon and return Icon#create" do 
    305105    controller, action = request(:post, '/icon') 
    306106    controller.class.should == Icon 
     
    309109  end 
    310110   
    311   specify "should handle request: PUT /icon and return Icon#update" do 
     111  it "should handle request: PUT /icon and return Icon#update" do 
    312112    controller, action = request(:put, '/icon') 
    313113    controller.class.should == Icon 
     
    316116  end 
    317117   
    318   specify "should handle request: DELETE /icon and return Icon#destroy" do 
     118  it "should handle request: DELETE /icon and return Icon#destroy" do 
    319119    controller, action = request(:delete, '/icon') 
    320120    controller.class.should == Icon 
     
    323123  end 
    324124   
    325   specify "should handle request: GET /admin/tags and return Tags#index" do 
     125  it "should handle request: GET /admin/tags and return Tags#index" do 
    326126    controller, action = request(:get, '/admin/tags') 
    327127    controller.class.should == Tags 
     
    330130  end 
    331131   
    332   specify "should handle request: GET /admin/tags.xml and return Tags#index format xml" do 
     132  it "should handle request: GET /admin/tags.xml and return Tags#index format xml" do 
    333133    controller, action = request(:get, '/admin/tags.xml') 
    334134    controller.class.should == Tags 
     
    338138  end 
    339139 
    340   specify "should handle request: GET /posts and return Posts#index" do 
     140  it "should handle request: GET /posts and return Posts#index" do 
    341141    controller, action = request(:get, '/posts') 
    342142    controller.class.should == Posts 
     
    345145  end 
    346146   
    347   specify "should handle request: GET /posts;filter and return Posts#filter" do 
     147  it "should handle request: GET /posts;filter and return Posts#filter" do 
    348148    controller, action = request(:get, '/posts;filter') 
    349149    controller.class.should == Posts 
     
    352152  end 
    353153   
    354   specify "should handle request: GET /posts/filter and return Posts#filter" do 
     154  it "should handle request: GET /posts/filter and return Posts#filter" do 
    355155    controller, action = request(:get, '/posts/filter') 
    356156    controller.class.should == Posts 
     
    359159  end 
    360160   
    361   specify "should handle request: GET /posts/1/comments and return Comments#index with post_id == 1" do 
     161  it "should handle request: GET /posts/1/comments and return Comments#index with post_id == 1" do 
    362162    controller, action = request(:get, '/posts/1/comments') 
    363163    controller.class.should == Comments 
     
    366166  end 
    367167   
    368   specify "should handle request: GET /posts/1/profile and return Profile#show with post_id == 1" do 
     168  it "should handle request: GET /posts/1/profile and return Profile#show with post_id == 1" do 
    369169    controller, action = request(:get, '/posts/1/profile') 
    370170    controller.class.should == Profile 
     
    373173  end 
    374174   
    375   specify "should handle request: GET /posts/1/profile.xml and return Profile#show with post_id == 1" do 
     175  it "should handle request: GET /posts/1/profile.xml and return Profile#show with post_id == 1" do 
    376176    controller, action = request(:get, '/posts/1/profile.xml') 
    377177    controller.class.should == Profile 
     
    381181  end 
    382182   
    383   specify "should handle request: GET /posts.xml and return Posts#index format xml" do 
     183  it "should handle request: GET /posts.xml and return Posts#index format xml" do 
    384184    controller, action = request(:get, '/posts.xml') 
    385185    controller.class.should == Posts 
     
    389189  end 
    390190   
    391   specify "should handle request: GET /posts/1 and return Posts#show" do 
     191  it "should handle request: GET /posts/1 and return Posts#show" do 
    392192    controller, action = request(:get, '/posts/1') 
    393193    controller.class.should == Posts 
     
    397197  end 
    398198   
    399   specify "should handle request: GET /posts/1/comments/1 and return Comments#show with post_id == 1" do 
     199  it "should handle request: GET /posts/1/comments/1 and return Comments#show with post_id == 1" do 
    400200    controller, action = request(:get, '/posts/1/comments/1') 
    401201    controller.class.should == Comments 
     
    406206  end 
    407207   
    408   specify "should handle request: GET /as/1/bs/1 and return Bs#show with as_id == 1 & id == 1" do 
     208  it "should handle request: GET /as/1/bs/1 and return Bs#show with as_id == 1 & id == 1" do 
    409209    controller, action = request(:get, '/as/1/bs/1') 
    410210    controller.class.should == Bs 
     
    415215  end 
    416216   
    417   specify "should handle request: GET /as/1/bs/1/cs and return Cs#show with a_id == 1 & b_id == 1" do 
     217  it "should handle request: GET /as/1/bs/1/cs and return Cs#show with a_id == 1 & b_id == 1" do 
    418218    controller, action = request(:get, '/as/1/bs/1/cs') 
    419219    controller.class.should == Cs 
     
    424224  end 
    425225   
    426   specify "should handle request: GET /as/1/bs/1/cs/1  and return Bs#show with as_id == 1 & b_id == 1 & id == 1" do 
     226  it "should handle request: GET /as/1/bs/1/cs/1  and return Bs#show with as_id == 1 & b_id == 1 & id == 1" do 
    427227    controller, action = request(:get, '/as/1/bs/1/cs/1') 
    428228    controller.class.should == Cs 
     
    434234  end 
    435235   
    436   specify "should handle request: GET /posts/1.xml and return Posts#show format xml" do 
     236  it "should handle request: GET /posts/1.xml and return Posts#show format xml" do 
    437237    controller, action = request(:get, '/posts/1.xml') 
    438238    controller.class.should == Posts 
     
    443243  end 
    444244   
    445   specify "should handle request: GET /posts/1/comments/1.xml and return Comments#show with post_id == 1 and format xml" do 
     245  it "should handle request: GET /posts/1/comments/1.xml and return Comments#show with post_id == 1 and format xml" do 
    446246    controller, action = request(:get, '/posts/1/comments/1.xml') 
    447247    controller.class.should == Comments 
     
    453253  end 
    454254   
    455   specify "should handle request: GET /posts/new and return Posts#new" do 
     255  it "should handle request: GET /posts/new and return Posts#new" do 
    456256    controller, action = request(:get, '/posts/new') 
    457257    controller.class.should == Posts 
     
    460260  end 
    461261   
    462   specify "should handle request: GET /posts/1/comments/new and return Comments#new with post_id == 1" do 
     262  it "should handle request: GET /posts/1/comments/new and return Comments#new with post_id == 1" do 
    463263    controller, action = request(:get, '/posts/1/comments/new') 
    464264    controller.class.should == Comments 
     
    467267  end 
    468268   
    469   specify "should handle request: GET /posts/1;edit and return Posts#edit" do 
     269  it "should handle request: GET /posts/1;edit and return Posts#edit" do 
    470270    controller, action = request(:get, '/posts/1;edit') 
    471271    controller.class.should == Posts 
     
    474274    controller.body.should == :edit 
    475275  end 
    476   specify "should handle request: GET /posts/1/edit and return Posts#edit" do 
     276  it "should handle request: GET /posts/1/edit and return Posts#edit" do 
    477277    controller, action = request(:get, '/posts/1/edit') 
    478278    controller.class.should == Posts 
     
    482282  end 
    483283   
    484   specify "should handle request: GET /posts/1/comments/1;edit and return Comments#edit with post_id == 1" do 
     284  it "should handle request: GET /posts/1/comments/1;edit and return Comments#edit with post_id == 1" do 
    485285    controller, action = request(:get, '/posts/1/comments/1;edit') 
    486286    controller.class.should == Comments 
     
    491291  end 
    492292   
    493   specify "should handle request: GET /posts/1/comments/1/edit and return Comments#edit with post_id == 1" do 
     293  it "should handle request: GET /posts/1/comments/1/edit and return Comments#edit with post_id == 1" do 
    494294    controller, action = request(:get, '/posts/1/comments/1/edit') 
    495295    controller.class.should == Comments 
     
    500300  end 
    501301   
    502   specify "should handle request: POST /posts and return Posts#create" do     
     302  it "should handle request: POST /posts and return Posts#create" do     
    503303    controller, action = request(:post, '/posts') 
    504304    controller.class.should == Posts 
     
    507307  end 
    508308   
    509   specify "should handle request: POST /posts/1/comments and return Comments#create  with post_id == 1" do     
     309  it "should handle request: POST /posts/1/comments and return Comments#create  with post_id == 1" do     
    510310    controller, action = request(:post, '/posts/1/comments') 
    511311    controller.class.should == Comments 
     
    514314  end 
    515315   
    516   specify "should handle request: POST /posts/1/comments.xml and return Comments#create  with post_id == 1 and format xml" do     
     316  it "should handle request: POST /posts/1/comments.xml and return Comments#create  with post_id == 1 and format xml" do     
    517317    controller, action = request(:post, '/posts/1/comments.xml') 
    518318    controller.class.should == Comments 
     
    523323   
    524324   
    525   specify "should handle request: POST /posts.xml and return Posts#create format xml" do     
     325  it "should handle request: POST /posts.xml and return Posts#create format xml" do     
    526326    controller, action = request(:post, '/posts.xml') 
    527327    controller.class.should == Posts 
     
    531331  end 
    532332   
    533   specify "should handle request: PUT /posts/1 and return Posts#update" do 
     333  it "should handle request: PUT /posts/1 and return Posts#update" do 
    534334    controller, action = request(:put, '/posts/1') 
    535335    controller.class.should == Posts 
     
    539339  end 
    540340   
    541   specify "should handle request: PUT /posts/1/comments/1 and return Comments#update with post_id == 1" do 
     341  it "should handle request: PUT /posts/1/comments/1 and return Comments#update with post_id == 1" do 
    542342    controller, action = request(:put, '/posts/1/comments/1') 
    543343    controller.class.should == Comments 
     
    548348  end 
    549349   
    550   specify "should handle request: PUT /posts/1.xml and return Posts#update format xml" do     
     350  it "should handle request: PUT /posts/1.xml and return Posts#update format xml" do     
    551351    controller, action = request(:put, '/posts/1.xml') 
    552352    controller.class.should == Posts 
     
    557357  end 
    558358   
    559   specify "should handle request: PUT /posts/1/comments/1.xml and return Comments#update with post_id == 1 and format xml" do 
     359  it "should handle request: PUT /posts/1/comments/1.xml and return Comments#update with post_id == 1 and format xml" do 
    560360    controller, action = request(:put, '/posts/1/comments/1.xml') 
    561361    controller.class.should == Comments 
     
    567367  end 
    568368   
    569   specify "should handle request: DELETE /posts/1 and return Posts#destroy" do 
     369  it "should handle request: DELETE /posts/1 and return Posts#destroy" do 
    570370    controller, action = request(:delete, '/posts/1') 
    571371    controller.class.should == Posts 
     
    575375  end 
    576376   
    577   specify "should handle request: DELETE /posts/1/comments/1 and return Comments#destroy with post_id == 1" do 
     377  it "should handle request: DELETE /posts/1/comments/1 and return Comments#destroy with post_id == 1" do 
    578378    controller, action = request(:delete, '/posts/1/comments/1') 
    579379    controller.class.should == Comments 
     
    584384  end 
    585385   
    586   specify "should handle request: DELETE /posts/1.xml and return Posts#destroy format xml" do     
     386  it "should handle request: DELETE /posts/1.xml and return Posts#destroy format xml" do     
    587387    controller, action = request(:delete, '/posts/1.xml') 
    588388    controller.class.should == Posts 
     
    593393  end 
    594394   
    595   specify "should handle request: DELETE /posts/1/comments/1.xml and return Comments#destroy with post_id == 1" do 
     395  it "should handle request: DELETE /posts/1/comments/1.xml and return Comments#destroy with post_id == 1" do 
    596396    controller, action = request(:delete, '/posts/1/comments/1.xml') 
    597397    controller.class.should == Comments 
     
    603403  end 
    604404   
    605   specify "should handle request: GET /posts/1;stats and return Posts#stats" do 
     405  it "should handle request: GET /posts/1;stats and return Posts#stats" do 
    606406    controller, action = request(:get, '/posts/1;stats') 
    607407    controller.class.should == Posts 
     
    611411  end 
    612412   
    613   specify "should handle request: GET /posts/1/stats and return Posts#stats" do 
     413  it "should handle request: GET /posts/1/stats and return Posts#stats" do 
    614414    controller, action = request(:get, '/posts/1/stats') 
    615415    controller.class.should == Posts 
     
    619419  end 
    620420   
    621   specify "should handle request: GET /posts/1/comments/1;stats and return Comments#stats with post_id == 1" do 
     421  it "should handle request: GET /posts/1/comments/1;stats and return Comments#stats with post_id == 1" do 
    622422    controller, action = request(:get, '/posts/1/comments/1;stats') 
    623423    controller.class.should == Comments 
     
    628428  end 
    629429   
    630   specify "should handle request: GET /posts/1/comments/1/stats and return Comments#stats with post_id == 1" do 
     430  it "should handle request: GET /posts/1/comments/1/stats and return Comments#stats with post_id == 1" do 
    631431    controller, action = request(:get, '/posts/1/comments/1/stats') 
    632432    controller.class.should == Comments 
     
    637437  end 
    638438   
    639   specify "should handle request: PUT /posts/1;stats and return Posts#stats" do 
     439  it "should handle request: PUT /posts/1;stats and return Posts#stats" do 
    640440    controller, action = request(:put, '/posts/1;stats') 
    641441    controller.class.should == Posts 
     
    645445  end 
    646446   
    647   specify "should handle request: PUT /posts/1/comments/1;stats and return Comments#stats with post_id == 1" do 
     447  it "should handle request: PUT /posts/1/comments/1;stats and return Comments#stats with post_id == 1" do 
    648448    controller, action = request(:get, '/posts/1/comments/1;stats') 
    649449    controller.class.should == Comments 
     
    654454  end 
    655455   
    656   specify "should handle request: PUT /posts/1/comments/1/stats and return Comments#stats with post_id == 1" do 
     456  it "should handle request: PUT /posts/1/comments/1/stats and return Comments#stats with post_id == 1" do 
    657457    controller, action = request(:get, '/posts/1/comments/1/stats') 
    658458    controller.class.should == Comments 
  • trunk/specs/merb/merb_responder_spec.rb

    r232 r242  
    44include Merb::ResponderMixin 
    55 
    6 context "A Merb Responder's AcceptType" do 
    7    
    8   def new_mime(entry,index) 
    9     Rest::AcceptType.new(entry,index) 
    10   end 
    11    
    12   setup do 
     6def new_mime(entry,index) 
     7  Rest::AcceptType.new(entry,index) 
     8end 
     9 
     10describe "A Merb Responder's AcceptType" do 
     11   
     12  before :each do 
    1313    @app_xhtml = new_mime('application/xhtml+xml',1) 
    1414    @text_html = new_mime('text/html',5) 
     
    1616  end 
    1717   
    18   specify "should initialize properly from mime description and index" do 
     18  it "should initialize properly from mime description and index" do 
    1919    acc_entry = new_mime('  application/html  ;   q=0.9  ',1) 
    2020    acc_entry.media_range.should == 'application/html' 
     
    2727  end 
    2828   
    29   specify "should assign lowest quality to */* unless otherwise specified" do 
     29  it "should assign lowest quality to */* unless otherwise specified" do 
    3030    new_mime('*/*',1).quality.should == 0 
    3131    new_mime('*/*;q=1.0',1).quality.should == 100 
     
    3333  end 
    3434   
    35   specify "should be equal to another AcceptType in the same synonym group" do 
     35  it "should be equal to another AcceptType in the same synonym group" do 
    3636    @text_html.should == @app_html 
    3737    @text_html.should eql(@app_html) 
     
    3939  end 
    4040   
    41   specify "should share a super range with an AcceptType in the same synonym group" do 
     41  it "should share a super range with an AcceptType in the same synonym group" do 
    4242    @text_html.synonyms.should == @app_html.synonyms 
    4343    @text_html.super_range.should == @app_html.super_range 
    4444  end 
    4545   
    46   specify "should parse type and subtype" do 
     46  it "should parse type and subtype" do 
    4747    @app_xhtml.type.should == 'application' 
    4848    @app_xhtml.sub_type.should == 'xhtml+xml' 
     
    6262  end 
    6363   
    64   specify "should parse accept header string to Array of AcceptType instances" do 
     64  it "should parse accept header string to Array of AcceptType instances" do 
    6565    acc_hdr = Rest::Responder.parse(@acc_hdr) 
    6666    acc_hdr.should be_kind_of(Array) 
     
    6868  end 
    6969   
    70   specify "should parse single entry accept headers" do 
     70  it "should parse single entry accept headers" do 
    7171    acc_hdr = Rest::Responder.parse('application/xml') 
    7272    acc_hdr.should be_kind_of(Array) 
     
    7474  end 
    7575   
    76   specify "should parse accept header into proper number of AcceptType instances" do 
     76  it "should parse accept header into proper number of AcceptType instances" do 
    7777    acc_hdr = 'foo/bar,baz/quuz,chimi/changa,cobra/khai' 
    7878    acc_hdr = Rest::Responder.parse(acc_hdr) 
     
    8080  end 
    8181   
    82   specify "should only return unique AcceptType instances" do 
     82  it "should only return unique AcceptType instances" do 
    8383    acc_hdr = 'text/html,application/xhtml+xml,application/html,text/xml,' \ 
    8484              'application/xml,application/x-xml' 
     
    8787  end 
    8888   
    89   specify "should sort AcceptType instances by quality" do 
     89  it "should sort AcceptType instances by quality" do 
    9090    acc_hdr = 'foo/bar;q=0.1,donny/darko;q=0.9,tango/cash,water/melon;q=0.5' 
    9191    acc_hdr = Rest::Responder.parse(acc_hdr) 
     
    9494  end 
    9595   
    96   specify "should sort AcceptType instances by order" do 
     96  it "should sort AcceptType instances by order" do 
    9797    acc_hdr = 'foo/bar,baz/quuz,chimi/changa,cobra/khai' 
    9898    acc_hdr = Rest::Responder.parse(acc_hdr) 
     
    101101  end 
    102102   
    103   specify "should prefer alternate xml forms (foo+xml) over application/xml" do 
     103  it "should prefer alternate xml forms (foo+xml) over application/xml" do 
    104104    acc_hdr = Rest::Responder.parse(@acc_hdr) 
    105105    acc_hdr.first.super_range.should == 'text/html' 
    106106  end 
    107107   
    108   specify "should sort AcceptType instances by quality and order" do 
     108  it "should sort AcceptType instances by quality and order" do 
    109109    acc_hdr = Rest::Responder.parse(@acc_hdr) 
    110110    acc_hdr.map!{|hdr| hdr.super_range }.should ==  
     
    145145context "A Merb Responder's Content Negotiation" do 
    146146 
    147   specify "should set Content-Type by :format for supported type: xml" do 
     147  it "should set Content-Type by :format for supported type: xml" do 
    148148    c = new_controller(:format => 'xml') 
    149149    c.dispatch(:index) 
     
    152152  end 
    153153   
    154   specify "should set Content-Type by :format for supported type: yaml" do 
     154  it "should set Content-Type by :format for supported type: yaml" do 
    155155    c = new_controller(:format => 'yaml') 
    156156    c.dispatch(:index) 
     
    159159  end 
    160160   
    161   specify "should set Content-Type by :format for supported type: html" do 
     161  it "should set Content-Type by :format for supported type: html" do 
    162162    c = new_controller(:format => 'html') 
    163163    c.dispatch(:index) 
     
    166166  end 
    167167   
    168   specify "should set Content-Type by accept header for supported type: xml" do 
     168  it "should set Content-Type by accept header for supported type: xml" do 
    169169    c = new_controller(:http_accept => 'text/xml') 
    170170    c.dispatch(:index) 
     
    173173  end 
    174174   
    175   specify "should set Content-Type by accept header for supported type: yaml" do 
     175  it "should set Content-Type by accept header for supported type: yaml" do 
    176176    c = new_controller(:http_accept => 'text/yaml') 
    177177    c.dispatch(:index) 
     
    180180  end 
    181181   
    182   specify "should set Content-Type by accept header for supported type: html" do 
     182  it "should set Content-Type by accept header for supported type: html" do 
    183183    c = new_controller(:http_accept => 'text/html') 
    184184    c.dispatch(:index) 
     
    187187  end 
    188188   
    189   specify "should set Content-Type by :format in preference to accept headers when both are of a supported response type" do 
     189  it "should set Content-Type by :format in preference to accept headers when both are of a supported response type" do 
    190190    c = new_controller(:http_accept => 'text/plain', :format => 'yaml') 
    191191    c.dispatch(:index) 
     
    194194  end 
    195195   
    196   specify "should set status 406 when format is of an unsupported response type" do 
     196  it "should set status 406 when format is of an unsupported response type" do 
    197197    c = new_controller(:format => 'fromage') 
    198198    c.dispatch(:index) 
     
    200200  end 
    201201   
    202   specify "should set status 406 when no accept header is of a unsupported response type" do 
     202  it "should set status 406 when no accept header is of a unsupported response type" do 
    203203    c = new_controller(:http_accept => 'stale/crackers;q=0.7,camel/milk;q=1.0') 
    204204    c.dispatch(:index) 
     
    206206  end 
    207207   
    208   specify "should raise runtime error when respond_to type is not in TYPES" do 
     208  it "should raise runtime error when respond_to type is not in TYPES" do 
    209209    r = Merb::MockRequest.new 
    210210    c = CrazyResponderSpecController.new(r.req, r.env, {}, StringIO.new) 
     
    212212  end 
    213213   
    214   specify "should call the block for the supported response type yaml" do 
     214  it "should call the block for the supported response type yaml" do 
    215215    c = new_controller(:http_accept => 'text/yaml') 
    216216    c.dispatch(:index) 
     
    218218  end 
    219219   
    220   specify "should call the block for the supported response type xml" do 
     220  it "should call the block for the supported response type xml" do 
    221221    c = new_controller(:http_accept => 'text/xml') 
    222222    c.dispatch(:index) 
     
    224224  end 
    225225   
    226   specify "should call the block for the supported response type html" do 
     226  it "should call the block for the supported response type html" do 
    227227    c = new_controller(:http_accept => 'text/html') 
    228228    c.dispatch(:index) 
     
    230230  end 
    231231   
    232   specify "should utilise format in preference to accept header" do 
     232  it "should utilise format in preference to accept header" do 
    233233    c = new_controller(:http_accept => 'text/html', :format => 'xml') 
    234234    c.dispatch(:index) 
     
    237237  end 
    238238   
    239   specify "should respond to the */* catchall accept header" do 
     239  it "should respond to the */* catchall accept header" do 
    240240    c = new_controller(:http_accept => '*/*') 
    241241    c.dispatch(:index) 
     
    244244  end 
    245245   
    246   specify "should honor a return :nothing => status specified in the respond_to block" do 
     246  it "should honor a return :nothing => status specified in the respond_to block" do 
    247247    c = new_controller(:http_accept => 'application/xml') 
    248248    c.dispatch(:create) 
  • trunk/specs/merb/merb_view_context_spec.rb

    r240 r242  
    99end 
    1010 
    11 context "A View Context" do   
    12   specify "should render an image tag with the image_tag method" do 
     11describe "A View Context" do   
     12  it "should render an image tag with the image_tag method" do 
    1313    image_tag('foo.gif').clean.should == 
    1414      %[<img src="/images/foo.gif"/>].clean 
     
    1919  end 
    2020   
    21   specify "should render a link tag with the css_include_tag method" do 
     21  it "should render a link tag with the css_include_tag method" do 
    2222    css_include_tag('foo.css').clean.should == 
    2323      %[<link href="/stylesheets/foo.css" media="all" rel="Stylesheet" type="text/css"/>].clean 
     
    3030  end 
    3131 
    32   specify "should render a script tag with the js_include_tag method" do