public
Rubygem
Description: RSpec extension library for Ruby on Rails
Homepage:
Clone URL: git://github.com/dchelimsky/rspec-rails.git
remove remaining conditionals checking for rails >=< 2.0
dchelimsky (author)
Mon Jan 12 05:59:40 -0800 2009
commit  7cea2cbddb47ec4d156ad5ad2491a8ac2e09544c
tree    033d8e12ec1d4d54da7e9802e531fcdce8c27ef8
parent  f6a82199a0e6d583f8b219484c66c0f9168a7202
...
15
16
17
18
19
20
21
22
 
23
24
25
...
15
16
17
 
 
 
 
 
18
19
20
21
0
@@ -15,11 +15,7 @@ class RspecControllerGenerator < ControllerGenerator
0
       m.directory File.join('spec/helpers', class_path)
0
       m.directory File.join('spec/views', class_path, file_name)
0
 
0
-      if Rails::VERSION::STRING < "2.0.0"
0
-        @default_file_extension = "rhtml"
0
-      else
0
-        @default_file_extension = "html.erb"
0
-      end
0
+      @default_file_extension = "html.erb"
0
 
0
       # Controller spec, class, and helper.
0
       m.template 'controller_spec.rb',
...
30
31
32
33
34
35
36
37
38
39
 
 
40
41
42
...
30
31
32
 
 
 
 
 
 
 
33
34
35
36
37
0
@@ -30,13 +30,8 @@ class RspecScaffoldGenerator < Rails::Generator::NamedBase
0
       @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
0
     end
0
     
0
-    if Rails::VERSION::STRING < "2.0.0"
0
-      @resource_generator = "scaffold_resource"
0
-      @default_file_extension = "rhtml"
0
-    else
0
-      @resource_generator = "scaffold"
0
-      @default_file_extension = "html.erb"
0
-    end
0
+    @resource_generator = "scaffold"
0
+    @default_file_extension = "html.erb"
0
     
0
     if ActionController::Base.respond_to?(:resource_action_separator)
0
       @resource_edit_path = "/edit"
...
19
20
21
22
23
24
25
26
27
28
 
 
 
 
...
19
20
21
 
 
 
 
 
 
22
23
24
25
26
0
@@ -19,9 +19,7 @@ require 'spec/rails/example'
0
 require 'spec/rails/extensions'
0
 require 'spec/rails/interop/testcase'
0
 
0
-if Rails::VERSION::STRING >= "2.0"
0
-  # This is a temporary hack to get rspec's auto-runner functionality to not consider
0
-  # ActionMailer::TestCase to be a spec waiting to run.
0
-  require 'action_mailer/test_case'
0
-  Spec::Example::ExampleGroupFactory.register(:ignore_for_now, ActionMailer::TestCase)
0
-end
0
\ No newline at end of file
0
+# This is a temporary hack to get rspec's auto-runner functionality to not consider
0
+# ActionMailer::TestCase to be a spec waiting to run.
0
+require 'action_mailer/test_case'
0
+Spec::Example::ExampleGroupFactory.register(:ignore_for_now, ActionMailer::TestCase)
...
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
35
36
37
 
 
 
 
 
 
 
 
 
38
39
40
0
@@ -35,15 +35,6 @@ module Spec
0
         # cookies in examples using the same API with which you set and read
0
         # them in controllers.
0
         #
0
-        # == Examples (Rails >= 1.2.6)
0
-        #
0
-        #   cookies[:user_id] = '1234'
0
-        #   get :index
0
-        #   assigns[:user].id.should == '1234'
0
-        #
0
-        #   post :login
0
-        #   cookies[:login].expires.should == 1.week.from_now
0
-        #
0
         # == Examples (Rails 2.0 > 2.2)
0
         #
0
         #   cookies[:user_id] = {:value => '1234', :expires => 1.minute.ago}
...
129
130
131
132
133
134
135
136
 
 
 
137
138
139
...
178
179
180
181
182
183
184
185
186
187
188
189
190
 
 
 
 
191
192
193
 
194
195
196
197
198
199
200
201
202
203
204
 
 
 
 
 
205
206
 
 
 
 
 
 
207
208
209
 
 
 
 
 
 
210
211
212
...
129
130
131
 
 
 
 
 
132
133
134
135
136
137
...
176
177
178
 
 
 
 
 
 
 
 
 
 
179
180
181
182
183
 
 
184
185
186
 
 
 
 
 
 
 
 
 
187
188
189
190
191
192
 
193
194
195
196
197
198
199
 
 
200
201
202
203
204
205
206
207
208
0
@@ -129,11 +129,9 @@ require 'controller_spec_controller'
0
         get 'action_which_gets_cookie', :expected => "cookie value"
0
       end
0
       
0
-      if Rails::VERSION::STRING >= "2.0.0"
0
-        it "should support a Hash value" do
0
-          cookies[:cookie_key] = {'value' => 'cookie value', 'path' => '/not/default'}
0
-          get 'action_which_gets_cookie', :expected => {'value' => 'cookie value', 'path' => '/not/default'}
0
-        end
0
+      it "should support a Hash value" do
0
+        cookies[:cookie_key] = {'value' => 'cookie value', 'path' => '/not/default'}
0
+        get 'action_which_gets_cookie', :expected => {'value' => 'cookie value', 'path' => '/not/default'}
0
       end
0
       
0
     end
0
@@ -178,35 +176,33 @@ require 'controller_spec_controller'
0
       end
0
     end
0
     
0
-    if Rails::VERSION::MAJOR >= 2
0
-      describe "with an error that is rescued in the controller" do
0
-        context "without rails' error handling" do
0
-          it "does not raise error" do
0
-            lambda do
0
-              get 'rescued_error_action'
0
-            end.should_not raise_error
0
-          end
0
-
0
-          it "executes rescue_from" do
0
+    describe "with an error that is rescued in the controller" do
0
+      context "without rails' error handling" do
0
+        it "does not raise error" do
0
+          lambda do
0
             get 'rescued_error_action'
0
-            response.body.should == 'Rescued!'
0
-          end
0
+          end.should_not raise_error
0
         end
0
 
0
-        context "with rails' error handling" do
0
-          before(:each) do
0
-            controller.use_rails_error_handling!
0
-          end
0
-          it "does not raise error" do
0
-            lambda do
0
-              get 'rescued_error_action'
0
-            end.should_not raise_error
0
-          end
0
+        it "executes rescue_from" do
0
+          get 'rescued_error_action'
0
+          response.body.should == 'Rescued!'
0
+        end
0
+      end
0
 
0
-          it "executes rescue_from" do
0
+      context "with rails' error handling" do
0
+        before(:each) do
0
+          controller.use_rails_error_handling!
0
+        end
0
+        it "does not raise error" do
0
+          lambda do
0
             get 'rescued_error_action'
0
-            response.body.should == 'Rescued!'
0
-          end
0
+          end.should_not raise_error
0
+        end
0
+
0
+        it "executes rescue_from" do
0
+          get 'rescued_error_action'
0
+          response.body.should == 'Rescued!'
0
         end
0
       end
0
     end
...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
 
 
 
 
 
 
 
 
 
 
42
43
44
...
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
 
 
 
 
 
 
 
 
 
 
73
74
75
...
26
27
28
 
 
 
 
 
 
 
 
 
 
 
 
 
29
30
31
32
33
34
35
36
37
38
39
40
41
42
...
55
56
57
 
 
 
 
 
 
 
 
 
 
 
 
 
58
59
60
61
62
63
64
65
66
67
68
69
70
71
0
@@ -26,19 +26,17 @@ module Spec
0
             end
0
           end
0
           
0
-          if ::Rails::VERSION::STRING >= "2.0.0"
0
-            it "should accept a Hash value" do
0
-              cookies = CookiesProxy.new(self)
0
-              cookies['key'] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' }
0
-              get :index
0
-              if ::Rails::VERSION::STRING >= "2.3"
0
-                cookies['key'].should == 'value'
0
-              else
0
-                cookies['key'].should == ['value']
0
-                cookies['key'].value.should == ['value']
0
-                cookies['key'].expires.should == expiration
0
-                cookies['key'].path.should == path
0
-              end
0
+          it "should accept a Hash value" do
0
+            cookies = CookiesProxy.new(self)
0
+            cookies['key'] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' }
0
+            get :index
0
+            if ::Rails::VERSION::STRING >= "2.3"
0
+              cookies['key'].should == 'value'
0
+            else
0
+              cookies['key'].should == ['value']
0
+              cookies['key'].value.should == ['value']
0
+              cookies['key'].expires.should == expiration
0
+              cookies['key'].path.should == path
0
             end
0
           end
0
             
0
@@ -57,19 +55,17 @@ module Spec
0
             end
0
           end
0
 
0
-          if ::Rails::VERSION::STRING >= "2.0.0"
0
-            it "should accept a Hash value" do
0
-              example_cookies = CookiesProxy.new(self)
0
-              example_cookies[:key] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' }
0
-              get :index
0
-              if ::Rails::VERSION::STRING >= "2.3"
0
-                example_cookies[:key].should == 'value'
0
-              else
0
-                example_cookies[:key].should == ['value']
0
-                example_cookies[:key].value.should == ['value']
0
-                example_cookies[:key].expires.should == expiration
0
-                example_cookies[:key].path.should == path
0
-              end
0
+          it "should accept a Hash value" do
0
+            example_cookies = CookiesProxy.new(self)
0
+            example_cookies[:key] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' }
0
+            get :index
0
+            if ::Rails::VERSION::STRING >= "2.3"
0
+              example_cookies[:key].should == 'value'
0
+            else
0
+              example_cookies[:key].should == ['value']
0
+              example_cookies[:key].value.should == ['value']
0
+              example_cookies[:key].expires.should == expiration
0
+              example_cookies[:key].path.should == path
0
             end
0
           end
0
 
...
112
113
114
115
116
117
118
119
...
112
113
114
 
 
115
116
117
0
@@ -112,8 +112,6 @@ module Spec
0
           ActionView::Helpers::TextHelper,
0
           ActionView::Helpers::UrlHelper
0
         ]
0
-        helpers << ActionView::Helpers::PaginationHelper rescue nil       #removed for 2.0
0
-        helpers << ActionView::Helpers::JavaScriptMacrosHelper rescue nil #removed for 2.0
0
         helpers.each do |helper_module|
0
           it "should include #{helper_module}" do
0
             self.class.ancestors.should include(helper_module)
...
149
150
151
152
153
154
155
156
157
158
 
 
 
 
 
 
159
160
161
162
163
 
 
 
164
165
166
...
149
150
151
 
 
 
 
 
 
 
152
153
154
155
156
157
158
 
 
 
 
159
160
161
162
163
164
0
@@ -149,18 +149,16 @@ describe "A view that includes a partial using :collection and :spacer_template"
0
 
0
 end
0
 
0
-if Rails::VERSION::MAJOR >= 2
0
-  describe "A view that includes a partial using an array as partial_path", :type => :view do
0
-    before(:each) do
0
-      renderable_object = Object.new
0
-      renderable_object.stub!(:name).and_return("Renderable Object")
0
-      assigns[:array] = [renderable_object]
0
-    end
0
+describe "A view that includes a partial using an array as partial_path", :type => :view do
0
+  before(:each) do
0
+    renderable_object = Object.new
0
+    renderable_object.stub!(:name).and_return("Renderable Object")
0
+    assigns[:array] = [renderable_object]
0
+  end
0
 
0
-    it "should render the array passed through to render_partial without modification" do
0
-      render "view_spec/template_with_partial_with_array" 
0
-      response.body.should match(/^Renderable Object$/)
0
-    end
0
+  it "should render the array passed through to render_partial without modification" do
0
+    render "view_spec/template_with_partial_with_array" 
0
+    response.body.should match(/^Renderable Object$/)
0
   end
0
 end
0
 
...
30
31
32
33
34
35
36
37
 
38
39
40
...
30
31
32
 
 
 
 
 
33
34
35
36
0
@@ -30,11 +30,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
0
   
0
     it "should match an rjs template" do
0
       xhr :post, 'some_action'
0
-      if Rails::VERSION::STRING < "2.0.0"
0
-        response.should render_template('render_spec/some_action.rjs')
0
-      else
0
-        response.should render_template('render_spec/some_action')
0
-      end
0
+      response.should render_template('render_spec/some_action')
0
     end
0
   
0
     it "should match a partial template (simple path)" do

Comments