rspec-rails 3.0.0.beta2 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -1
  4. data/Capybara.md +1 -3
  5. data/Changelog.md +126 -58
  6. data/README.md +31 -4
  7. data/lib/generators/rspec/controller/templates/controller_spec.rb +1 -1
  8. data/lib/generators/rspec/controller/templates/view_spec.rb +1 -1
  9. data/lib/generators/rspec/feature/templates/feature_spec.rb +1 -1
  10. data/lib/generators/rspec/helper/templates/helper_spec.rb +1 -1
  11. data/lib/generators/rspec/install/templates/spec/spec_helper.rb.tt +21 -1
  12. data/lib/generators/rspec/integration/templates/request_spec.rb +1 -1
  13. data/lib/generators/rspec/mailer/templates/mailer_spec.rb +1 -1
  14. data/lib/generators/rspec/model/templates/model_spec.rb +1 -1
  15. data/lib/generators/rspec/observer/templates/observer_spec.rb +1 -1
  16. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +11 -3
  17. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +4 -3
  18. data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
  19. data/lib/generators/rspec/scaffold/templates/new_spec.rb +5 -4
  20. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +1 -1
  21. data/lib/generators/rspec/scaffold/templates/show_spec.rb +2 -2
  22. data/lib/generators/rspec/view/templates/view_spec.rb +1 -1
  23. data/lib/rspec/rails.rb +1 -8
  24. data/lib/rspec/rails/configuration.rb +72 -0
  25. data/lib/rspec/rails/example.rb +0 -64
  26. data/lib/rspec/rails/example/controller_example_group.rb +16 -12
  27. data/lib/rspec/rails/example/feature_example_group.rb +0 -2
  28. data/lib/rspec/rails/example/helper_example_group.rb +0 -2
  29. data/lib/rspec/rails/example/mailer_example_group.rb +0 -1
  30. data/lib/rspec/rails/example/model_example_group.rb +0 -4
  31. data/lib/rspec/rails/example/request_example_group.rb +0 -2
  32. data/lib/rspec/rails/example/routing_example_group.rb +0 -2
  33. data/lib/rspec/rails/example/view_example_group.rb +1 -2
  34. data/lib/rspec/rails/extensions.rb +0 -1
  35. data/lib/rspec/rails/fixture_support.rb +0 -8
  36. data/lib/rspec/rails/matchers.rb +1 -0
  37. data/lib/rspec/rails/matchers/have_http_status.rb +355 -0
  38. data/lib/rspec/rails/matchers/routing_matchers.rb +1 -1
  39. data/lib/rspec/rails/tasks/rspec.rake +12 -5
  40. data/lib/rspec/rails/version.rb +1 -1
  41. data/lib/rspec/rails/view_rendering.rb +6 -34
  42. metadata +42 -316
  43. metadata.gz.sig +0 -0
  44. data/features/Generators.md +0 -25
  45. data/features/GettingStarted.md +0 -84
  46. data/features/README.md +0 -48
  47. data/features/RailsVersions.md +0 -4
  48. data/features/Transactions.md +0 -84
  49. data/features/Upgrade.md +0 -121
  50. data/features/controller_specs/Cookies.md +0 -57
  51. data/features/controller_specs/README.md +0 -45
  52. data/features/controller_specs/anonymous_controller.feature +0 -436
  53. data/features/controller_specs/bypass_rescue.feature +0 -75
  54. data/features/controller_specs/controller_spec.feature +0 -58
  55. data/features/controller_specs/engine_routes.feature +0 -51
  56. data/features/controller_specs/isolation_from_views.feature +0 -87
  57. data/features/controller_specs/render_views.feature +0 -114
  58. data/features/directory_structure.feature +0 -71
  59. data/features/feature_specs/feature_spec.feature +0 -35
  60. data/features/helper_specs/helper_spec.feature +0 -122
  61. data/features/mailer_specs/url_helpers.feature +0 -38
  62. data/features/matchers/README.md +0 -18
  63. data/features/matchers/new_record_matcher.feature +0 -41
  64. data/features/matchers/redirect_to_matcher.feature +0 -40
  65. data/features/matchers/relation_match_array.feature +0 -27
  66. data/features/matchers/render_template_matcher.feature +0 -49
  67. data/features/mocks/mock_model.feature +0 -147
  68. data/features/mocks/stub_model.feature +0 -58
  69. data/features/model_specs/README.md +0 -21
  70. data/features/model_specs/errors_on.feature +0 -51
  71. data/features/model_specs/records.feature +0 -27
  72. data/features/model_specs/transactional_examples.feature +0 -109
  73. data/features/request_specs/request_spec.feature +0 -49
  74. data/features/routing_specs/README.md +0 -16
  75. data/features/routing_specs/be_routable_matcher.feature +0 -80
  76. data/features/routing_specs/engine_routes.feature +0 -38
  77. data/features/routing_specs/named_routes.feature +0 -18
  78. data/features/routing_specs/route_to_matcher.feature +0 -90
  79. data/features/step_definitions/additional_cli_steps.rb +0 -4
  80. data/features/step_definitions/model_steps.rb +0 -3
  81. data/features/support/capybara.rb +0 -7
  82. data/features/support/env.rb +0 -53
  83. data/features/support/rails_versions.rb +0 -4
  84. data/features/support/rubinius.rb +0 -6
  85. data/features/view_specs/inferred_controller_path.feature +0 -45
  86. data/features/view_specs/stub_template.feature +0 -51
  87. data/features/view_specs/view_spec.feature +0 -206
  88. data/lib/rspec/rails/extensions/active_record/base.rb +0 -58
  89. data/lib/rspec/rails/mocks.rb +0 -272
  90. data/lib/rspec/rails/vendor/webrat.rb +0 -33
  91. data/spec/generators/rspec/controller/controller_generator_spec.rb +0 -97
  92. data/spec/generators/rspec/feature/feature_generator_spec.rb +0 -43
  93. data/spec/generators/rspec/helper/helper_generator_spec.rb +0 -30
  94. data/spec/generators/rspec/install/install_generator_spec.rb +0 -30
  95. data/spec/generators/rspec/integration/integration_generator_spec.rb +0 -32
  96. data/spec/generators/rspec/mailer/mailer_generator_spec.rb +0 -48
  97. data/spec/generators/rspec/model/model_generator_spec.rb +0 -52
  98. data/spec/generators/rspec/observer/observer_generator_spec.rb +0 -21
  99. data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +0 -138
  100. data/spec/generators/rspec/view/view_generator_spec.rb +0 -41
  101. data/spec/rspec/rails/assertion_adapter_spec.rb +0 -28
  102. data/spec/rspec/rails/assertion_delegator_spec.rb +0 -43
  103. data/spec/rspec/rails/configuration_spec.rb +0 -26
  104. data/spec/rspec/rails/deprecations_spec.rb +0 -18
  105. data/spec/rspec/rails/example/controller_example_group_spec.rb +0 -159
  106. data/spec/rspec/rails/example/feature_example_group_spec.rb +0 -56
  107. data/spec/rspec/rails/example/helper_example_group_spec.rb +0 -66
  108. data/spec/rspec/rails/example/mailer_example_group_spec.rb +0 -21
  109. data/spec/rspec/rails/example/model_example_group_spec.rb +0 -15
  110. data/spec/rspec/rails/example/request_example_group_spec.rb +0 -17
  111. data/spec/rspec/rails/example/routing_example_group_spec.rb +0 -32
  112. data/spec/rspec/rails/example/view_example_group_spec.rb +0 -235
  113. data/spec/rspec/rails/extensions/active_model/errors_on_spec.rb +0 -23
  114. data/spec/rspec/rails/extensions/active_record/base_spec.rb +0 -42
  115. data/spec/rspec/rails/fixture_support_spec.rb +0 -17
  116. data/spec/rspec/rails/matchers/be_a_new_spec.rb +0 -142
  117. data/spec/rspec/rails/matchers/be_new_record_spec.rb +0 -33
  118. data/spec/rspec/rails/matchers/be_routable_spec.rb +0 -41
  119. data/spec/rspec/rails/matchers/be_valid_spec.rb +0 -73
  120. data/spec/rspec/rails/matchers/has_spec.rb +0 -29
  121. data/spec/rspec/rails/matchers/have_rendered_spec.rb +0 -93
  122. data/spec/rspec/rails/matchers/redirect_to_spec.rb +0 -81
  123. data/spec/rspec/rails/matchers/relation_match_array_spec.rb +0 -31
  124. data/spec/rspec/rails/matchers/route_to_spec.rb +0 -151
  125. data/spec/rspec/rails/minitest_lifecycle_adapter_spec.rb +0 -31
  126. data/spec/rspec/rails/mocks/mock_model_spec.rb +0 -400
  127. data/spec/rspec/rails/mocks/stub_model_spec.rb +0 -154
  128. data/spec/rspec/rails/setup_and_teardown_adapter_spec.rb +0 -32
  129. data/spec/rspec/rails/view_rendering_spec.rb +0 -111
  130. data/spec/spec_helper.rb +0 -33
  131. data/spec/support/ar_classes.rb +0 -42
  132. data/spec/support/helpers.rb +0 -34
  133. data/spec/support/matchers.rb +0 -9
  134. data/spec/support/null_object.rb +0 -6
@@ -1,436 +0,0 @@
1
- Feature: anonymous controller
2
-
3
- Use the `controller` method to define an anonymous controller
4
- that will inherit from the described class. This is useful for
5
- specifying behavior like global error handling.
6
-
7
- To specify a different base class you can pass the class explicitly
8
- to the controller method:
9
-
10
- controller(BaseController)
11
-
12
- You can also disable base type inference, in which case anonymous
13
- controllers will inherit from `ApplicationController` instead of
14
- the described class by default:
15
-
16
- Rspec.configure do |c|
17
- c.infer_base_class_for_anonymous_controllers = false
18
- end
19
-
20
- describe BaseController do
21
- controller { ... }
22
- # ^^ would normally create an anonymous subclass of `BaseController`,
23
- # but since `infer_base_class_for_anonymous_controllers` is disabled,
24
- # it creates a subclass of `ApplicationController` instead
25
-
26
- Scenario: specify error handling in ApplicationController
27
- Given a file named "spec/controllers/application_controller_spec.rb" with:
28
- """ruby
29
- require "spec_helper"
30
-
31
- class ApplicationController < ActionController::Base
32
- class AccessDenied < StandardError; end
33
-
34
- rescue_from AccessDenied, :with => :access_denied
35
-
36
- private
37
-
38
- def access_denied
39
- redirect_to "/401.html"
40
- end
41
- end
42
-
43
- describe ApplicationController do
44
- controller do
45
- def index
46
- raise ApplicationController::AccessDenied
47
- end
48
- end
49
-
50
- describe "handling AccessDenied exceptions" do
51
- it "redirects to the /401.html page" do
52
- get :index
53
- expect(response).to redirect_to("/401.html")
54
- end
55
- end
56
- end
57
- """
58
- When I run `rspec spec`
59
- Then the examples should all pass
60
-
61
- Scenario: specify error handling in subclass of ApplicationController
62
- Given a file named "spec/controllers/application_controller_subclass_spec.rb" with:
63
- """ruby
64
- require "spec_helper"
65
-
66
- class ApplicationController < ActionController::Base
67
- class AccessDenied < StandardError; end
68
- end
69
-
70
- class ApplicationControllerSubclass < ApplicationController
71
-
72
- rescue_from ApplicationController::AccessDenied, :with => :access_denied
73
-
74
- private
75
-
76
- def access_denied
77
- redirect_to "/401.html"
78
- end
79
- end
80
-
81
- describe ApplicationControllerSubclass do
82
- controller(ApplicationControllerSubclass) do
83
- def index
84
- raise ApplicationController::AccessDenied
85
- end
86
- end
87
-
88
- describe "handling AccessDenied exceptions" do
89
- it "redirects to the /401.html page" do
90
- get :index
91
- expect(response).to redirect_to("/401.html")
92
- end
93
- end
94
- end
95
- """
96
- When I run `rspec spec`
97
- Then the examples should all pass
98
-
99
- Scenario: infer base class from the described class
100
- Given a file named "spec/controllers/base_class_can_be_inferred_spec.rb" with:
101
- """ruby
102
- require "spec_helper"
103
-
104
- class ApplicationController < ActionController::Base; end
105
-
106
- class ApplicationControllerSubclass < ApplicationController; end
107
-
108
- describe ApplicationControllerSubclass do
109
- controller do
110
- def index
111
- render :text => "Hello World"
112
- end
113
- end
114
-
115
- it "creates an anonymous controller derived from ApplicationControllerSubclass" do
116
- expect(controller).to be_a_kind_of(ApplicationControllerSubclass)
117
- end
118
- end
119
- """
120
- When I run `rspec spec`
121
- Then the examples should all pass
122
-
123
- Scenario: get name and controller_name from the described class
124
- Given a file named "spec/controllers/get_name_and_controller_name_from_described_class_spec.rb" with:
125
- """ruby
126
- require "spec_helper"
127
-
128
- class ApplicationController < ActionController::Base; end
129
- class FoosController < ApplicationController; end
130
-
131
- describe "FoosController controller_name" do
132
- controller FoosController do
133
- def index
134
- @name = self.class.name
135
- @controller_name = controller_name
136
- render :text => "Hello World"
137
- end
138
- end
139
-
140
- before do
141
- get :index
142
- end
143
-
144
- it "gets the class name as described" do
145
- expect(assigns[:name]).to eq('FoosController')
146
- end
147
-
148
- it "gets the controller_name as described" do
149
- expect(assigns[:controller_name]).to eq('foos')
150
- end
151
- end
152
- """
153
- When I run `rspec spec`
154
- Then the examples should all pass
155
-
156
- Scenario: invoke around filter in base class
157
- Given a file named "spec/controllers/application_controller_around_filter_spec.rb" with:
158
- """ruby
159
- require "spec_helper"
160
-
161
- class ApplicationController < ActionController::Base
162
- around_filter :an_around_filter
163
-
164
- def an_around_filter
165
- @callback_invoked = true
166
- yield
167
- end
168
- end
169
-
170
- describe ApplicationController do
171
- controller do
172
- def index
173
- render :nothing => true
174
- end
175
- end
176
-
177
- it "invokes the callback" do
178
- get :index
179
-
180
- expect(assigns[:callback_invoked]).to be_truthy
181
- end
182
- end
183
- """
184
- When I run `rspec spec`
185
- Then the examples should all pass
186
-
187
- Scenario: anonymous controllers only create resource routes
188
- Given a file named "spec/controllers/application_controller_spec.rb" with:
189
- """ruby
190
- require "spec_helper"
191
-
192
- describe ApplicationController do
193
- controller do
194
- def index
195
- render :text => "index called"
196
- end
197
-
198
- def create
199
- render :text => "create called"
200
- end
201
-
202
- def new
203
- render :text => "new called"
204
- end
205
-
206
- def show
207
- render :text => "show called"
208
- end
209
-
210
- def edit
211
- render :text => "edit called"
212
- end
213
-
214
- def update
215
- render :text => "update called"
216
- end
217
-
218
- def destroy
219
- render :text => "destroy called"
220
- end
221
-
222
- def willerror
223
- render :text => "will not render"
224
- end
225
- end
226
-
227
- describe "#index" do
228
- it "responds to GET" do
229
- get :index
230
- expect(response.body).to eq "index called"
231
- end
232
-
233
- it "also responds to POST" do
234
- post :index
235
- expect(response.body).to eq "index called"
236
- end
237
-
238
- it "also responds to PUT" do
239
- put :index
240
- expect(response.body).to eq "index called"
241
- end
242
-
243
- it "also responds to DELETE" do
244
- delete :index
245
- expect(response.body).to eq "index called"
246
- end
247
- end
248
-
249
- describe "#create" do
250
- it "responds to POST" do
251
- post :create
252
- expect(response.body).to eq "create called"
253
- end
254
-
255
- # And the rest...
256
- %w{get post put delete}.each do |calltype|
257
- it "responds to #{calltype}" do
258
- send(calltype, :create)
259
- expect(response.body).to eq "create called"
260
- end
261
- end
262
- end
263
-
264
- describe "#new" do
265
- it "responds to GET" do
266
- get :new
267
- expect(response.body).to eq "new called"
268
- end
269
-
270
- # And the rest...
271
- %w{get post put delete}.each do |calltype|
272
- it "responds to #{calltype}" do
273
- send(calltype, :new)
274
- expect(response.body).to eq "new called"
275
- end
276
- end
277
- end
278
-
279
- describe "#edit" do
280
- it "responds to GET" do
281
- get :edit, :id => "anyid"
282
- expect(response.body).to eq "edit called"
283
- end
284
-
285
- it "requires the :id parameter" do
286
- expect { get :edit }.to raise_error(ActionController::RoutingError)
287
- end
288
-
289
- # And the rest...
290
- %w{get post put delete}.each do |calltype|
291
- it "responds to #{calltype}" do
292
- send(calltype, :edit, {:id => "anyid"})
293
- expect(response.body).to eq "edit called"
294
- end
295
- end
296
- end
297
-
298
- describe "#show" do
299
- it "responds to GET" do
300
- get :show, :id => "anyid"
301
- expect(response.body).to eq "show called"
302
- end
303
-
304
- it "requires the :id parameter" do
305
- expect { get :show }.to raise_error(ActionController::RoutingError)
306
- end
307
-
308
- # And the rest...
309
- %w{get post put delete}.each do |calltype|
310
- it "responds to #{calltype}" do
311
- send(calltype, :show, {:id => "anyid"})
312
- expect(response.body).to eq "show called"
313
- end
314
- end
315
- end
316
-
317
- describe "#update" do
318
- it "responds to PUT" do
319
- put :update, :id => "anyid"
320
- expect(response.body).to eq "update called"
321
- end
322
-
323
- it "requires the :id parameter" do
324
- expect { put :update }.to raise_error(ActionController::RoutingError)
325
- end
326
-
327
- # And the rest...
328
- %w{get post put delete}.each do |calltype|
329
- it "responds to #{calltype}" do
330
- send(calltype, :update, {:id => "anyid"})
331
- expect(response.body).to eq "update called"
332
- end
333
- end
334
- end
335
-
336
- describe "#destroy" do
337
- it "responds to DELETE" do
338
- delete :destroy, :id => "anyid"
339
- expect(response.body).to eq "destroy called"
340
- end
341
-
342
- it "requires the :id parameter" do
343
- expect { delete :destroy }.to raise_error(ActionController::RoutingError)
344
- end
345
-
346
- # And the rest...
347
- %w{get post put delete}.each do |calltype|
348
- it "responds to #{calltype}" do
349
- send(calltype, :destroy, {:id => "anyid"})
350
- expect(response.body).to eq "destroy called"
351
- end
352
- end
353
- end
354
-
355
- describe "#willerror" do
356
- it "cannot be called" do
357
- expect { get :willerror }.to raise_error(ActionController::RoutingError)
358
- end
359
- end
360
- end
361
- """
362
- When I run `rspec spec`
363
- Then the examples should all pass
364
-
365
- Scenario: draw custom routes for anonymous controllers
366
- Given a file named "spec/controllers/application_controller_spec.rb" with:
367
- """ruby
368
- require "spec_helper"
369
-
370
- describe ApplicationController do
371
- controller do
372
- def custom
373
- render :text => "custom called"
374
- end
375
- end
376
-
377
- specify "a custom action can be requested if routes are drawn manually" do
378
- routes.draw { get "custom" => "anonymous#custom" }
379
-
380
- get :custom
381
- expect(response.body).to eq "custom called"
382
- end
383
- end
384
- """
385
- When I run `rspec spec`
386
- Then the examples should all pass
387
-
388
- Scenario: draw custom routes for defined controllers
389
- Given a file named "spec/controllers/application_controller_spec.rb" with:
390
- """ruby
391
- require "spec_helper"
392
-
393
- class FoosController < ApplicationController; end
394
-
395
- describe ApplicationController do
396
- controller FoosController do
397
- def custom
398
- render :text => "custom called"
399
- end
400
- end
401
-
402
- specify "a custom action can be requested if routes are drawn manually" do
403
- routes.draw { get "custom" => "foos#custom" }
404
-
405
- get :custom
406
- expect(response.body).to eq "custom called"
407
- end
408
- end
409
- """
410
- When I run `rspec spec`
411
- Then the examples should all pass
412
-
413
- Scenario: refer to application routes in the controller under test
414
- Given a file named "spec/controllers/application_controller_spec.rb" with:
415
- """ruby
416
- require "spec_helper"
417
-
418
- Rails.application.routes.draw do
419
- match "/login" => "sessions#new", :as => "login", :via => "get"
420
- end
421
-
422
- describe ApplicationController do
423
- controller do
424
- def index
425
- redirect_to login_url
426
- end
427
- end
428
-
429
- it "redirects to the login page" do
430
- get :index
431
- expect(response).to redirect_to("/login")
432
- end
433
- end
434
- """
435
- When I run `rspec spec`
436
- Then the examples should all pass
@@ -1,75 +0,0 @@
1
- Feature: bypass rescue
2
-
3
- Use `bypass_rescue` to bypass both Rails' default handling of errors in
4
- controller actions, and any custom handling declared with a `rescue_from`
5
- statement.
6
-
7
- This lets you specify details of the exception being raised, regardless of
8
- how it might be handled upstream.
9
-
10
- Background:
11
- Given a file named "spec/controllers/gadgets_controller_spec_context.rb" with:
12
- """ruby
13
- class AccessDenied < StandardError; end
14
-
15
- class ApplicationController < ActionController::Base
16
- rescue_from AccessDenied, :with => :access_denied
17
-
18
- private
19
-
20
- def access_denied
21
- redirect_to "/401.html"
22
- end
23
- end
24
- """
25
-
26
- Scenario: standard exception handling using `rescue_from`
27
- Given a file named "spec/controllers/gadgets_controller_spec.rb" with:
28
- """ruby
29
- require "spec_helper"
30
-
31
- require 'controllers/gadgets_controller_spec_context'
32
-
33
- describe GadgetsController do
34
- before do
35
- def controller.index
36
- raise AccessDenied
37
- end
38
- end
39
-
40
- describe "index" do
41
- it "redirects to the /401.html page" do
42
- get :index
43
- expect(response).to redirect_to("/401.html")
44
- end
45
- end
46
- end
47
- """
48
- When I run `rspec spec/controllers/gadgets_controller_spec.rb`
49
- Then the examples should all pass
50
-
51
- Scenario: bypass `rescue_from` handling with `bypass_rescue`
52
- Given a file named "spec/controllers/gadgets_controller_spec.rb" with:
53
- """ruby
54
- require "spec_helper"
55
-
56
- require 'controllers/gadgets_controller_spec_context'
57
-
58
- describe GadgetsController do
59
- before do
60
- def controller.index
61
- raise AccessDenied
62
- end
63
- end
64
-
65
- describe "index" do
66
- it "raises AccessDenied" do
67
- bypass_rescue
68
- expect { get :index }.to raise_error(AccessDenied)
69
- end
70
- end
71
- end
72
- """
73
- When I run `rspec spec/controllers/gadgets_controller_spec.rb`
74
- Then the examples should all pass
75
-