rspec-rails 1.1.12 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/.document +7 -0
  2. data/History.txt +55 -0
  3. data/License.txt +1 -1
  4. data/Manifest.txt +53 -48
  5. data/README.txt +5 -4
  6. data/Rakefile +9 -2
  7. data/TODO.txt +1 -0
  8. data/Upgrade.markdown +103 -0
  9. data/generators/rspec/rspec_generator.rb +1 -0
  10. data/generators/rspec/templates/rspec.rake +134 -111
  11. data/generators/rspec/templates/script/autospec +1 -0
  12. data/generators/rspec/templates/script/spec +21 -4
  13. data/generators/rspec/templates/script/spec_server +34 -107
  14. data/generators/rspec/templates/spec_helper.rb +1 -1
  15. data/generators/rspec_controller/rspec_controller_generator.rb +1 -5
  16. data/generators/rspec_scaffold/rspec_scaffold_generator.rb +13 -17
  17. data/generators/rspec_scaffold/templates/controller_spec.rb +27 -29
  18. data/generators/rspec_scaffold/templates/edit_erb_spec.rb +2 -2
  19. data/generators/rspec_scaffold/templates/helper_spec.rb +1 -1
  20. data/generators/rspec_scaffold/templates/index_erb_spec.rb +2 -2
  21. data/generators/rspec_scaffold/templates/new_erb_spec.rb +2 -2
  22. data/generators/rspec_scaffold/templates/routing_spec.rb +24 -20
  23. data/generators/rspec_scaffold/templates/show_erb_spec.rb +2 -2
  24. data/lib/spec/rails.rb +10 -9
  25. data/lib/spec/rails/example.rb +2 -2
  26. data/lib/spec/rails/example/assigns_hash_proxy.rb +1 -2
  27. data/lib/spec/rails/example/controller_example_group.rb +117 -123
  28. data/lib/spec/rails/example/functional_example_group.rb +7 -22
  29. data/lib/spec/rails/example/helper_example_group.rb +15 -33
  30. data/lib/spec/rails/example/model_example_group.rb +1 -1
  31. data/lib/spec/rails/example/render_observer.rb +0 -26
  32. data/lib/spec/rails/example/routing_example_group.rb +13 -0
  33. data/lib/spec/rails/example/routing_helpers.rb +68 -0
  34. data/lib/spec/rails/example/view_example_group.rb +50 -47
  35. data/lib/spec/rails/extensions.rb +2 -1
  36. data/lib/spec/rails/extensions/action_controller/rescue.rb +25 -8
  37. data/lib/spec/rails/extensions/action_controller/test_case.rb +16 -0
  38. data/lib/spec/rails/extensions/action_controller/test_response.rb +4 -3
  39. data/lib/spec/rails/extensions/action_view/base.rb +9 -9
  40. data/lib/spec/rails/extensions/active_record/base.rb +39 -23
  41. data/lib/spec/rails/extensions/active_support/test_case.rb +7 -0
  42. data/lib/spec/rails/extensions/spec/matchers/have.rb +8 -6
  43. data/lib/spec/rails/extensions/spec/runner/configuration.rb +12 -44
  44. data/lib/spec/rails/matchers/ar_be_valid.rb +8 -5
  45. data/lib/spec/rails/matchers/assert_select.rb +36 -21
  46. data/lib/spec/rails/matchers/have_text.rb +3 -3
  47. data/lib/spec/rails/matchers/include_text.rb +4 -4
  48. data/lib/spec/rails/matchers/redirect_to.rb +30 -19
  49. data/lib/spec/rails/matchers/render_template.rb +7 -3
  50. data/lib/spec/rails/mocks.rb +1 -1
  51. data/lib/spec/rails/spec_server.rb +97 -0
  52. data/lib/spec/rails/story_adapter.rb +4 -4
  53. data/lib/spec/rails/version.rb +2 -2
  54. data/spec/resources/controllers/controller_spec_controller.rb +14 -6
  55. data/spec/resources/controllers/example.txt +1 -0
  56. data/spec/resources/controllers/redirect_spec_controller.rb +4 -0
  57. data/spec/resources/controllers/render_spec_controller.rb +1 -1
  58. data/spec/resources/controllers/rjs_spec_controller.rb +1 -1
  59. data/spec/resources/helpers/explicit_helper.rb +1 -1
  60. data/spec/resources/views/controller_spec/{_partial.rhtml → _partial.html.erb} +0 -0
  61. data/spec/resources/views/controller_spec/{action_setting_flash_after_session_reset.rhtml → action_setting_flash_after_session_reset.html.erb} +0 -0
  62. data/spec/resources/views/controller_spec/{action_setting_flash_before_session_reset.rhtml → action_setting_flash_before_session_reset.html.erb} +0 -0
  63. data/spec/resources/views/controller_spec/{action_setting_the_assigns_hash.rhtml → action_setting_the_assigns_hash.html.erb} +0 -0
  64. data/spec/resources/views/controller_spec/{action_with_errors_in_template.rhtml → action_with_errors_in_template.html.erb} +0 -0
  65. data/spec/resources/views/controller_spec/{action_with_template.rhtml → action_with_template.html.erb} +0 -0
  66. data/spec/resources/views/layouts/{application.rhtml → application.html.erb} +0 -0
  67. data/spec/resources/views/layouts/{simple.rhtml → simple.html.erb} +0 -0
  68. data/spec/resources/views/render_spec/{_a_partial.rhtml → _a_partial.html.erb} +0 -0
  69. data/spec/resources/views/render_spec/{action_with_alternate_layout.rhtml → action_with_alternate_layout.html.erb} +0 -0
  70. data/spec/resources/views/rjs_spec/{_replacement_partial.rhtml → _replacement_partial.html.erb} +0 -0
  71. data/spec/resources/views/rjs_spec/{hide_div.rjs → hide_div.js.rjs} +0 -0
  72. data/spec/resources/views/rjs_spec/{hide_page_element.rjs → hide_page_element.js.rjs} +0 -0
  73. data/spec/resources/views/rjs_spec/{insert_html.rjs → insert_html.js.rjs} +0 -0
  74. data/spec/resources/views/rjs_spec/{replace.rjs → replace.js.rjs} +0 -0
  75. data/spec/resources/views/rjs_spec/{replace_html.rjs → replace_html.js.rjs} +0 -0
  76. data/spec/resources/views/rjs_spec/{replace_html_with_partial.rjs → replace_html_with_partial.js.rjs} +0 -0
  77. data/spec/resources/views/rjs_spec/{visual_effect.rjs → visual_effect.js.rjs} +0 -0
  78. data/spec/resources/views/rjs_spec/{visual_toggle_effect.rjs → visual_toggle_effect.js.rjs} +0 -0
  79. data/spec/resources/views/tag_spec/{no_tags.rhtml → no_tags.html.erb} +0 -0
  80. data/spec/resources/views/tag_spec/{single_div_with_no_attributes.rhtml → single_div_with_no_attributes.html.erb} +0 -0
  81. data/spec/resources/views/tag_spec/{single_div_with_one_attribute.rhtml → single_div_with_one_attribute.html.erb} +0 -0
  82. data/spec/resources/views/view_spec/{_partial.rhtml → _partial.html.erb} +0 -0
  83. data/spec/resources/views/view_spec/{_partial_used_twice.rhtml → _partial_used_twice.html.erb} +0 -0
  84. data/spec/resources/views/view_spec/{_partial_with_local_variable.rhtml → _partial_with_local_variable.html.erb} +0 -0
  85. data/spec/resources/views/view_spec/{_partial_with_sub_partial.rhtml → _partial_with_sub_partial.html.erb} +0 -0
  86. data/spec/resources/views/view_spec/{_spacer.rhtml → _spacer.html.erb} +0 -0
  87. data/spec/resources/views/view_spec/{accessor.rhtml → accessor.html.erb} +0 -0
  88. data/spec/resources/views/view_spec/{block_helper.rhtml → block_helper.html.erb} +0 -0
  89. data/spec/resources/views/view_spec/{entry_form.rhtml → entry_form.html.erb} +0 -0
  90. data/spec/resources/views/view_spec/{explicit_helper.rhtml → explicit_helper.html.erb} +0 -0
  91. data/spec/resources/views/view_spec/foo/{show.rhtml → show.html.erb} +0 -0
  92. data/spec/resources/views/view_spec/{implicit_helper.rhtml → implicit_helper.html.erb} +0 -0
  93. data/spec/resources/views/view_spec/{multiple_helpers.rhtml → multiple_helpers.html.erb} +0 -0
  94. data/spec/resources/views/view_spec/{should_not_receive.rhtml → should_not_receive.html.erb} +0 -0
  95. data/spec/resources/views/view_spec/{template_with_partial.rhtml → template_with_partial.html.erb} +0 -0
  96. data/spec/resources/views/view_spec/{template_with_partial_using_collection.rhtml → template_with_partial_using_collection.html.erb} +0 -0
  97. data/spec/resources/views/view_spec/{template_with_partial_with_array.rhtml → template_with_partial_with_array.html.erb} +0 -0
  98. data/spec/spec/rails/example/assigns_hash_proxy_spec.rb +18 -5
  99. data/spec/spec/rails/example/configuration_spec.rb +15 -29
  100. data/spec/spec/rails/example/{controller_spec_spec.rb → controller_example_group_spec.rb} +40 -96
  101. data/spec/spec/rails/example/cookies_proxy_spec.rb +32 -36
  102. data/spec/spec/rails/example/error_handling_spec.rb +90 -0
  103. data/spec/spec/rails/example/example_group_factory_spec.rb +5 -5
  104. data/spec/spec/rails/example/{helper_spec_spec.rb → helper_example_group_spec.rb} +45 -13
  105. data/spec/spec/rails/example/{model_spec_spec.rb → model_example_group_spec.rb} +3 -1
  106. data/spec/spec/rails/example/routing_example_group_spec.rb +9 -0
  107. data/spec/spec/rails/example/shared_routing_example_group_examples.rb +45 -0
  108. data/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb +1 -1
  109. data/spec/spec/rails/example/{view_spec_spec.rb → view_example_group_spec.rb} +44 -17
  110. data/spec/spec/rails/matchers/ar_be_valid_spec.rb +10 -0
  111. data/spec/spec/rails/matchers/assert_select_spec.rb +59 -60
  112. data/spec/spec/rails/matchers/have_text_spec.rb +12 -4
  113. data/spec/spec/rails/matchers/include_text_spec.rb +11 -13
  114. data/spec/spec/rails/matchers/redirect_to_spec.rb +224 -189
  115. data/spec/spec/rails/matchers/render_template_spec.rb +169 -158
  116. data/spec/spec/rails/spec_server_spec.rb +18 -7
  117. data/spec/spec_helper.rb +21 -9
  118. metadata +68 -53
  119. data/lib/spec/rails/example/rails_example_group.rb +0 -28
  120. data/lib/spec/rails/extensions/action_controller/base.rb +0 -14
  121. data/rspec-rails.gemspec +0 -36
  122. data/spec/resources/views/render_spec/some_action.rjs +0 -1
  123. data/spec/spec/rails/example/shared_behaviour_spec.rb +0 -16
  124. data/spec/spec/rails/extensions/action_controller_rescue_action_spec.rb +0 -57
@@ -9,41 +9,33 @@ module Spec
9
9
  end
10
10
 
11
11
  describe "#use_transactional_fixtures" do
12
- it "should return #{Spec::Runner::Configuration::TEST_CASE}.use_transactional_fixtures" do
13
- config.use_transactional_fixtures.should == Spec::Runner::Configuration::TEST_CASE.use_transactional_fixtures
12
+ it "should return ActiveSupport::TestCase.use_transactional_fixtures" do
13
+ config.use_transactional_fixtures.should == ActiveSupport::TestCase.use_transactional_fixtures
14
14
  end
15
15
 
16
- it "should set #{Spec::Runner::Configuration::TEST_CASE}.use_transactional_fixtures to false" do
17
- Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
18
- example_group.should_receive(:use_transactional_fixtures=).with(false)
19
- end
16
+ it "should set ActiveSupport::TestCase.use_transactional_fixtures to false" do
17
+ ActiveSupport::TestCase.should_receive(:use_transactional_fixtures=).with(false)
20
18
  config.use_transactional_fixtures = false
21
19
  end
22
20
 
23
- it "should set #{Spec::Runner::Configuration::TEST_CASE}.use_transactional_fixtures to true" do
24
- Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
25
- example_group.should_receive(:use_transactional_fixtures=).with(true)
26
- end
21
+ it "should set ActiveSupport::TestCase.use_transactional_fixtures to true" do
22
+ ActiveSupport::TestCase.should_receive(:use_transactional_fixtures=).with(true)
27
23
  config.use_transactional_fixtures = true
28
24
  end
29
25
  end
30
26
 
31
27
  describe "#use_instantiated_fixtures" do
32
- it "should return #{Spec::Runner::Configuration::TEST_CASE}.use_transactional_fixtures" do
33
- config.use_instantiated_fixtures.should == Spec::Runner::Configuration::TEST_CASE.use_instantiated_fixtures
28
+ it "should return ActiveSupport::TestCase.use_transactional_fixtures" do
29
+ config.use_instantiated_fixtures.should == ActiveSupport::TestCase.use_instantiated_fixtures
34
30
  end
35
31
 
36
- it "should set #{Spec::Runner::Configuration::TEST_CASE}.use_instantiated_fixtures to false" do
37
- Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
38
- example_group.should_receive(:use_instantiated_fixtures=).with(false)
39
- end
32
+ it "should set ActiveSupport::TestCase.use_instantiated_fixtures to false" do
33
+ ActiveSupport::TestCase.should_receive(:use_instantiated_fixtures=).with(false)
40
34
  config.use_instantiated_fixtures = false
41
35
  end
42
36
 
43
- it "should set #{Spec::Runner::Configuration::TEST_CASE}.use_instantiated_fixtures to true" do
44
- Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
45
- example_group.should_receive(:use_instantiated_fixtures=).with(true)
46
- end
37
+ it "should set ActiveSupport::TestCase.use_instantiated_fixtures to true" do
38
+ ActiveSupport::TestCase.should_receive(:use_instantiated_fixtures=).with(true)
47
39
  config.use_instantiated_fixtures = true
48
40
  end
49
41
  end
@@ -51,25 +43,19 @@ module Spec
51
43
  describe "#fixture_path" do
52
44
  it "should default to RAILS_ROOT + '/spec/fixtures'" do
53
45
  config.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
54
- Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
55
- example_group.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
56
- end
46
+ ActiveSupport::TestCase.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
57
47
  end
58
48
 
59
49
  it "should set fixture_path" do
60
50
  config.fixture_path = "/new/path"
61
51
  config.fixture_path.should == "/new/path"
62
- Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
63
- example_group.fixture_path.should == "/new/path"
64
- end
52
+ ActiveSupport::TestCase.fixture_path.should == "/new/path"
65
53
  end
66
54
  end
67
55
 
68
56
  describe "#global_fixtures" do
69
57
  it "should set fixtures on TestCase" do
70
- Configuration::EXAMPLE_GROUP_CLASSES.each do |example_group|
71
- example_group.should_receive(:fixtures).with(:blah)
72
- end
58
+ ActiveSupport::TestCase.should_receive(:fixtures).with(:blah)
73
59
  config.global_fixtures = [:blah]
74
60
  end
75
61
  end
@@ -1,10 +1,28 @@
1
1
  require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
  require 'controller_spec_controller'
3
+ require File.join(File.dirname(__FILE__), "/shared_routing_example_group_examples.rb")
3
4
 
4
5
  ['integration', 'isolation'].each do |mode|
5
6
  describe "A controller example running in #{mode} mode", :type => :controller do
6
7
  controller_name :controller_spec
7
8
  integrate_views if mode == 'integration'
9
+
10
+ accesses_configured_helper_methods
11
+ include RoutingExampleGroupSpec
12
+
13
+ describe "with an implicit subject" do
14
+ it "uses the controller" do
15
+ subject.should == controller
16
+ end
17
+ end
18
+
19
+ describe "with a specified subject" do
20
+ subject { 'specified' }
21
+
22
+ it "uses the specified subject" do
23
+ subject.should == 'specified'
24
+ end
25
+ end
8
26
 
9
27
  it "should provide controller.session as session" do
10
28
  get 'action_with_template'
@@ -86,7 +104,12 @@ require 'controller_spec_controller'
86
104
  get 'action_which_gets_session', :expected => "session value"
87
105
  end.should_not raise_error
88
106
  end
89
-
107
+
108
+ it "allows inline rendering" do
109
+ get 'action_that_renders_inline'
110
+ response.body.should == "inline code"
111
+ end
112
+
90
113
  describe "handling should_receive(:render)" do
91
114
  it "should warn" do
92
115
  controller.should_receive(:render).with(:template => "controller_spec/action_with_template")
@@ -101,22 +124,6 @@ require 'controller_spec_controller'
101
124
  end
102
125
  end
103
126
 
104
- describe "handling deprecated expect_render" do
105
- it "should warn" do
106
- Kernel.should_receive(:warn).with(/expect_render is deprecated/)
107
- controller.expect_render(:template => "controller_spec/action_with_template")
108
- get :action_with_template
109
- end
110
- end
111
-
112
- describe "handling deprecated stub_render" do
113
- it "should warn" do
114
- Kernel.should_receive(:warn).with(/stub_render is deprecated/)
115
- controller.stub_render(:template => "controller_spec/action_with_template")
116
- get :action_with_template
117
- end
118
- end
119
-
120
127
  describe "setting cookies in the request" do
121
128
 
122
129
  it "should support a String key" do
@@ -129,11 +136,9 @@ require 'controller_spec_controller'
129
136
  get 'action_which_gets_cookie', :expected => "cookie value"
130
137
  end
131
138
 
132
- if Rails::VERSION::STRING >= "2.0.0"
133
- it "should support a Hash value" do
134
- cookies[:cookie_key] = {'value' => 'cookie value', 'path' => '/not/default'}
135
- get 'action_which_gets_cookie', :expected => {'value' => 'cookie value', 'path' => '/not/default'}
136
- end
139
+ it "should support a Hash value" do
140
+ cookies[:cookie_key] = {'value' => 'cookie value', 'path' => '/not/default'}
141
+ get 'action_which_gets_cookie', :expected => {'value' => 'cookie value', 'path' => '/not/default'}
137
142
  end
138
143
 
139
144
  end
@@ -142,7 +147,7 @@ require 'controller_spec_controller'
142
147
 
143
148
  it "should support a Symbol key" do
144
149
  get 'action_which_sets_cookie', :value => "cookie value"
145
- if Rails::VERSION::STRING >= "2.3"
150
+ if ::Rails::VERSION::STRING >= "2.3"
146
151
  cookies[:cookie_key].should == "cookie+value"
147
152
  else
148
153
  cookies[:cookie_key].should == ["cookie value"]
@@ -151,7 +156,7 @@ require 'controller_spec_controller'
151
156
 
152
157
  it "should support a String key" do
153
158
  get 'action_which_sets_cookie', :value => "cookie value"
154
- if Rails::VERSION::STRING >= "2.3"
159
+ if ::Rails::VERSION::STRING >= "2.3"
155
160
  cookies['cookie_key'].should == "cookie+value"
156
161
  else
157
162
  cookies['cookie_key'].should == ["cookie value"]
@@ -160,95 +165,35 @@ require 'controller_spec_controller'
160
165
 
161
166
  end
162
167
 
163
- describe "with an error that is not rescued in the controller" do
164
- context "without rails' error handling" do
165
- it "raises the error" do
166
- lambda do
167
- get 'other_error_action'
168
- end.should raise_error(ControllerSpecController::UnRescuedError)
169
- end
170
- end
171
- context "with rails' error handling" do
172
- it "does not raise the error" do
173
- controller.use_rails_error_handling!
174
- lambda do
175
- get 'other_error_action'
176
- end.should_not raise_error
177
- end
178
- end
179
- end
180
-
181
- if Rails::VERSION::MAJOR >= 2
182
- describe "with an error that is rescued in the controller" do
183
- context "without rails' error handling" do
184
- it "does not raise error" do
185
- lambda do
186
- get 'rescued_error_action'
187
- end.should_not raise_error
188
- end
189
-
190
- it "executes rescue_from" do
191
- get 'rescued_error_action'
192
- response.body.should == 'Rescued!'
193
- end
194
- end
195
-
196
- context "with rails' error handling" do
197
- before(:each) do
198
- controller.use_rails_error_handling!
199
- end
200
- it "does not raise error" do
201
- lambda do
202
- get 'rescued_error_action'
203
- end.should_not raise_error
204
- end
205
-
206
- it "executes rescue_from" do
207
- get 'rescued_error_action'
208
- response.body.should == 'Rescued!'
209
- end
210
- end
211
- end
212
- end
213
-
214
- it "should support custom routes" do
215
- route_for(:controller => "custom_route_spec", :action => "custom_route").should == "/custom_route"
216
- end
217
-
218
- it "should support existing routes" do
219
- route_for(:controller => "controller_spec", :action => "some_action").should == "/controller_spec/some_action"
220
- end
221
-
222
- it "should generate params for custom routes" do
223
- params_from(:get, '/custom_route').should == {:controller => "custom_route_spec", :action => "custom_route"}
224
- end
225
-
226
- it "should generate params for existing routes" do
227
- params_from(:get, '/controller_spec/some_action').should == {:controller => "controller_spec", :action => "some_action"}
228
- end
229
-
230
168
  it "should expose instance vars through the assigns hash" do
231
169
  get 'action_setting_the_assigns_hash'
232
170
  assigns[:indirect_assigns_key].should == :indirect_assigns_key_value
233
171
  end
234
-
172
+
235
173
  it "should expose instance vars through the assigns hash that are set to false" do
236
174
  get 'action_that_assigns_false_to_a_variable'
237
175
  assigns[:a_variable].should be_false
238
176
  end
239
-
177
+
240
178
  it "should NOT complain when calling should_receive with arguments other than :render" do
241
179
  controller.should_receive(:anything_besides_render)
242
180
  lambda {
243
181
  controller.rspec_verify
244
182
  }.should raise_error(Exception, /expected :anything_besides_render/)
245
183
  end
246
-
184
+
247
185
  it "should not run a skipped before_filter" do
248
186
  lambda {
249
187
  get 'action_with_skipped_before_filter'
250
188
  }.should_not raise_error
251
189
  end
190
+
191
+ describe "extending #render on a controller" do
192
+ it "supports two arguments (as with rails 2.2)" do
193
+ get 'action_with_two_arg_render'
194
+ response.body.should =~ /new Effect\.Highlight/
195
+ end
196
+ end
252
197
  end
253
198
 
254
199
  describe "Given a controller spec for RedirectSpecController running in #{mode} mode", :type => :controller do
@@ -301,9 +246,8 @@ end
301
246
  end
302
247
  end
303
248
 
304
-
305
249
  describe ControllerSpecController, :type => :controller do
306
- it "should not require naming the controller if describe is passed a type" do
250
+ it "should use the controller passed to #describe" do
307
251
  end
308
252
  end
309
253
 
@@ -16,29 +16,27 @@ module Spec
16
16
  describe "with a String key" do
17
17
 
18
18
  it "should accept a String value" do
19
- cookies = CookiesProxy.new(self)
20
- cookies['key'] = 'value'
19
+ proxy = CookiesProxy.new(self)
20
+ proxy['key'] = 'value'
21
21
  get :index
22
22
  if ::Rails::VERSION::STRING >= "2.3"
23
- cookies['key'].should == 'value'
23
+ proxy['key'].should == 'value'
24
24
  else
25
- cookies['key'].should == ['value']
25
+ proxy['key'].should == ['value']
26
26
  end
27
27
  end
28
28
 
29
- if ::Rails::VERSION::STRING >= "2.0.0"
30
- it "should accept a Hash value" do
31
- cookies = CookiesProxy.new(self)
32
- cookies['key'] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' }
33
- get :index
34
- if ::Rails::VERSION::STRING >= "2.3"
35
- cookies['key'].should == 'value'
36
- else
37
- cookies['key'].should == ['value']
38
- cookies['key'].value.should == ['value']
39
- cookies['key'].expires.should == expiration
40
- cookies['key'].path.should == path
41
- end
29
+ it "should accept a Hash value" do
30
+ proxy = CookiesProxy.new(self)
31
+ proxy['key'] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' }
32
+ get :index
33
+ if ::Rails::VERSION::STRING >= "2.3"
34
+ proxy['key'].should == 'value'
35
+ else
36
+ proxy['key'].should == ['value']
37
+ proxy['key'].value.should == ['value']
38
+ proxy['key'].expires.should == expiration
39
+ proxy['key'].path.should == path
42
40
  end
43
41
  end
44
42
 
@@ -47,29 +45,27 @@ module Spec
47
45
  describe "with a Symbol key" do
48
46
 
49
47
  it "should accept a String value" do
50
- example_cookies = CookiesProxy.new(self)
51
- example_cookies[:key] = 'value'
48
+ proxy = CookiesProxy.new(self)
49
+ proxy[:key] = 'value'
52
50
  get :index
53
51
  if ::Rails::VERSION::STRING >= "2.3"
54
- example_cookies[:key].should == 'value'
52
+ proxy[:key].should == 'value'
55
53
  else
56
- example_cookies[:key].should == ['value']
54
+ proxy[:key].should == ['value']
57
55
  end
58
56
  end
59
57
 
60
- if ::Rails::VERSION::STRING >= "2.0.0"
61
- it "should accept a Hash value" do
62
- example_cookies = CookiesProxy.new(self)
63
- example_cookies[:key] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' }
64
- get :index
65
- if ::Rails::VERSION::STRING >= "2.3"
66
- example_cookies[:key].should == 'value'
67
- else
68
- example_cookies[:key].should == ['value']
69
- example_cookies[:key].value.should == ['value']
70
- example_cookies[:key].expires.should == expiration
71
- example_cookies[:key].path.should == path
72
- end
58
+ it "should accept a Hash value" do
59
+ proxy = CookiesProxy.new(self)
60
+ proxy[:key] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' }
61
+ get :index
62
+ if ::Rails::VERSION::STRING >= "2.3"
63
+ proxy[:key].should == 'value'
64
+ else
65
+ proxy[:key].should == ['value']
66
+ proxy[:key].value.should == ['value']
67
+ proxy[:key].expires.should == expiration
68
+ proxy[:key].path.should == path
73
69
  end
74
70
  end
75
71
 
@@ -77,11 +73,11 @@ module Spec
77
73
 
78
74
  describe "#delete" do
79
75
  it "should delete from the response cookies" do
80
- example_cookies = CookiesProxy.new(self)
76
+ proxy = CookiesProxy.new(self)
81
77
  response_cookies = mock('cookies')
82
78
  response.should_receive(:cookies).and_return(response_cookies)
83
79
  response_cookies.should_receive(:delete).with('key')
84
- example_cookies.delete :key
80
+ proxy.delete :key
85
81
  end
86
82
  end
87
83
  end
@@ -0,0 +1,90 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ require 'controller_spec_controller'
3
+
4
+ ['integration', 'isolation'].each do |mode|
5
+ describe "A controller example running in #{mode} mode", :type => :controller do
6
+ controller_name :controller_spec
7
+ integrate_views if mode == 'integration'
8
+
9
+ describe "without use_rails_error_handling!" do
10
+ describe "with an error that is *not* rescued" do
11
+ it "raises the error" do
12
+ lambda do
13
+ get 'un_rescued_error_action'
14
+ end.should raise_error(ControllerSpecController::UnRescuedError)
15
+ end
16
+ end
17
+ describe "with an error that *is* rescued" do
18
+ it "returns a 200" do
19
+ get 'rescued_error_action'
20
+ response.response_code.should == 200
21
+ end
22
+ end
23
+ end
24
+
25
+ describe "with deprecated use_rails_error_handling!" do
26
+ before(:each) do
27
+ Kernel.stub!(:warn)
28
+ end
29
+
30
+ it "warns of deprecation" do
31
+ Kernel.should_receive(:warn).with(/DEPRECATION NOTICE/)
32
+ controller.use_rails_error_handling!
33
+ end
34
+
35
+ describe "with an error that is *not* rescued" do
36
+ it "returns the error code" do
37
+ controller.use_rails_error_handling!
38
+ get 'un_rescued_error_action'
39
+ response.response_code.should == 500
40
+ end
41
+ end
42
+
43
+ describe "with an error that *is* rescued" do
44
+ it "returns a 200" do
45
+ controller.use_rails_error_handling!
46
+ get 'rescued_error_action'
47
+ response.response_code.should == 200
48
+ end
49
+ end
50
+ end
51
+
52
+ describe "with rescue_action_in_public!" do
53
+ describe "with an error that is *not* rescued" do
54
+ it "returns the error code" do
55
+ rescue_action_in_public!
56
+ get 'un_rescued_error_action'
57
+ response.response_code.should == 500
58
+ end
59
+ end
60
+
61
+ describe "with an error that *is* rescued" do
62
+ it "returns a 200" do
63
+ rescue_action_in_public!
64
+ get 'rescued_error_action'
65
+ response.response_code.should == 200
66
+ end
67
+ end
68
+ end
69
+
70
+ describe "with bypass_rescue" do
71
+ describe "with an error that is *not* rescued" do
72
+ it "raises the error" do
73
+ bypass_rescue
74
+ lambda do
75
+ get 'un_rescued_error_action'
76
+ end.should raise_error(ControllerSpecController::UnRescuedError)
77
+ end
78
+ end
79
+
80
+ describe "with an error that *is* rescued" do
81
+ it "raises the error" do
82
+ bypass_rescue
83
+ lambda do
84
+ get 'rescued_error_action'
85
+ end.should raise_error(ControllerSpecController::RescuedError)
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end