@@ -22,6 +22,7 @@ Hopefully this will be of help to those of you learning RSpec and Rails. If ther
22
22
23
23
- [ Support Configuration] ( #support-configuration )
24
24
- [ Run Specs in a Random Order] ( #run-specs-in-a-random-order )
25
+ - [ Testing Production Errors] ( #testing-production-errors )
25
26
- [ Testing Rake Tasks with RSpec] ( #testing-rake-tasks-with-rspec )
26
27
- [ Pry-rescue debugging] ( #pry-rescue-debugging )
27
28
- [ Time Travel Examples] ( #time-travel-examples )
@@ -41,6 +42,7 @@ Hopefully this will be of help to those of you learning RSpec and Rails. If ther
41
42
- [ Matchers] ( #matchers )
42
43
- [ Generators] ( #generators )
43
44
- [ Feature Specs & Docs] ( #feature-specs--docs )
45
+ - [ API Request Specs, Docs, & Helpers] ( #api-request-specs-docs--helpers )
44
46
- [ Mailer Specs & Docs] ( #mailer-specs--docs )
45
47
- [ Controller Specs & Docs] ( #controller-specs--docs )
46
48
- [ View Specs & Docs] ( #view-specs--docs )
@@ -73,12 +75,18 @@ The specs run in a random order each time the test suite is run. This helps prev
73
75
Random order test runs are configured using the ` config.order = :random ` and ` Kernel.srand config.seed ` options in [ spec/spec_helper.rb] ( spec/spec_helper.rb ) .
74
76
75
77
78
+ # Testing Production Errors
79
+
80
+ When errors are raised, the Rails test environment may not behave as in production. The test environment may mask the actual error response you want to test. To help with this, you can disable test environment exception handling temporarily, [ spec/support/error_responses.rb] ( spec/support/error_responses.rb ) provides ` respond_without_detailed_exceptions ` . See it in use in [ spec/api/v1/token_spec.rb] ( spec/api/v1/token_spec.rb ) to provide production-like error responses in the test environment.
81
+
82
+
76
83
# Testing Rake Tasks with RSpec
77
84
78
85
RSpec testing Rake task configuration and example:
79
86
- [ spec/support/tasks.rb] ( spec/support/tasks.rb )
80
87
- [ spec/tasks/subscription_tasks_spec.rb] ( spec/tasks/subscription_tasks_spec.rb )
81
88
89
+
82
90
# Pry-rescue debugging
83
91
pry-rescue can be used to debug failing specs, by opening pry's debugger whenever a test failure is encountered. For setup and usage see [ pry-rescue's README] ( https://github.com/ConradIrwin/pry-rescue ) .
84
92
@@ -208,6 +216,7 @@ Custom matchers configuration how-to and examples:
208
216
- Chainable matcher: [ spec/matchers/be_confirm_subscription_page.rb] ( spec/matchers/be_confirm_subscription_page.rb )
209
217
- [ spec/matchers/have_error_messages.rb] ( spec/matchers/have_error_messages.rb )
210
218
- [ spec/features/subscribe_to_newsletter_spec.rb] ( spec/features/subscribe_to_newsletter_spec.rb )
219
+ - Lightweight matcher with ` satisfy ` : [ spec/api/v1/token_spec.rb] ( spec/api/v1/token_spec.rb )
211
220
212
221
213
222
# RSpec-Expectations Docs
@@ -220,41 +229,47 @@ Custom matchers configuration how-to and examples:
220
229
- [ spec/controllers/subscriptions_controller_spec.rb] ( spec/controllers/subscriptions_controller_spec.rb )
221
230
- [ spec/mailers/subscription_mailer_spec.rb] ( spec/mailers/subscription_mailer_spec.rb )
222
231
- [ spec/models/subscription_spec.rb] ( spec/models/subscription_spec.rb )
223
- - [ RSpec Mocks API] ( https://relishapp.com/rspec/rspec-mocks/v/3-1/ docs )
232
+ - [ RSpec Mocks API] ( https://relishapp.com/rspec/rspec-mocks/docs )
224
233
225
234
# RSpec-Rails
226
- See [ RSpec Rails] ( https://relishapp.com/rspec/rspec-rails/v/3-1/ docs ) for installation instructions.
235
+ See [ RSpec Rails] ( https://relishapp.com/rspec/rspec-rails/docs ) for installation instructions.
227
236
228
237
## Matchers
229
- - https://relishapp.com/rspec/rspec-rails/v/3-1/ docs/matchers
238
+ - https://relishapp.com/rspec/rspec-rails/docs/matchers
230
239
231
240
## Generators
232
- - https://relishapp.com/rspec/rspec-rails/v/3-1/ docs/generators
241
+ - https://relishapp.com/rspec/rspec-rails/docs/generators
233
242
234
243
## Feature Specs & Docs
235
244
- [ spec/features/subscribe_to_newsletter_spec.rb] ( spec/features/subscribe_to_newsletter_spec.rb )
236
- - [ Feature specs API] ( https://relishapp.com/rspec/rspec-rails/v/3-1/docs/feature-specs/feature-spec )
245
+ - [ Feature specs API] ( https://relishapp.com/rspec/rspec-rails/docs/feature-specs/feature-spec )
246
+
247
+ ## API Request Specs, Docs, & Helpers
248
+ - [ spec/api/v1/token_spec.rb] ( spec/api/v1/token_spec.rb )
249
+ - [ spec/support/json_helper.rb] ( spec/support/json_helper.rb )
250
+ - [ spec/support/error_responses.rb] ( spec/support/error_responses.rb )
251
+ - [ Request specs API] ( https://relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec )
237
252
238
253
## Mailer Specs & Docs
239
254
- [ spec/mailers/subscription_mailer_spec.rb] ( spec/mailers/subscription_mailer_spec.rb )
240
- - [ Mailer specs API] ( https://relishapp.com/rspec/rspec-rails/v/3-1/ docs/mailer-specs/url-helpers-in-mailer-examples )
255
+ - [ Mailer specs API] ( https://relishapp.com/rspec/rspec-rails/docs/mailer-specs/url-helpers-in-mailer-examples )
241
256
242
257
## Controller Specs & Docs
243
258
- [ spec/controllers/subscriptions_controller_spec.rb] ( spec/controllers/subscriptions_controller_spec.rb )
244
- - [ Controller specs API] ( https://relishapp.com/rspec/rspec-rails/v/3-1/ docs/controller-specs )
259
+ - [ Controller specs API] ( https://relishapp.com/rspec/rspec-rails/docs/controller-specs )
245
260
- [ Controller specs cheatsheet] ( https://gist.github.com/eliotsykes/5b71277b0813fbc0df56 )
246
261
247
262
## View Specs & Docs
248
263
- [ The Big List of View Specs] ( https://eliotsykes.com/view-specs )
249
- - [ View specs API] ( https://relishapp.com/rspec/rspec-rails/v/3-3/ docs/view-specs )
264
+ - [ View specs API] ( https://relishapp.com/rspec/rspec-rails/docs/view-specs )
250
265
251
266
## Helper Specs & Docs
252
267
- [ spec/helpers/application_helper_spec.rb] ( spec/helpers/application_helper_spec.rb )
253
- - [ Helper specs API] ( https://relishapp.com/rspec/rspec-rails/v/3-1/ docs/helper-specs/helper-spec )
268
+ - [ Helper specs API] ( https://relishapp.com/rspec/rspec-rails/docs/helper-specs/helper-spec )
254
269
255
270
## Routing Specs & Docs
256
271
- [ spec/routing/subscriptions_routing_spec.rb] ( spec/routing/subscriptions_routing_spec.rb )
257
- - [ Routing specs API] ( https://relishapp.com/rspec/rspec-rails/v/3-1/ docs/routing-specs )
272
+ - [ Routing specs API] ( https://relishapp.com/rspec/rspec-rails/docs/routing-specs )
258
273
259
274
260
275
# Enable Spring for RSpec
0 commit comments