rspec-rails 5.1.2 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Changelog.md +103 -6
- data/README.md +37 -36
- data/lib/generators/rspec/channel/channel_generator.rb +1 -1
- data/lib/generators/rspec/controller/controller_generator.rb +4 -4
- data/lib/generators/rspec/feature/feature_generator.rb +1 -1
- data/lib/generators/rspec/generator/generator_generator.rb +1 -1
- data/lib/generators/rspec/helper/helper_generator.rb +1 -1
- data/lib/generators/rspec/install/install_generator.rb +19 -2
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +12 -7
- data/lib/generators/rspec/integration/integration_generator.rb +10 -3
- data/lib/generators/rspec/job/job_generator.rb +1 -1
- data/lib/generators/rspec/mailbox/mailbox_generator.rb +1 -1
- data/lib/generators/rspec/mailer/mailer_generator.rb +3 -3
- data/lib/generators/rspec/model/model_generator.rb +3 -3
- data/lib/generators/rspec/request/request_generator.rb +10 -3
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +4 -4
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +15 -0
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +8 -4
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -1
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/request_spec.rb +15 -0
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +1 -1
- data/lib/generators/rspec/system/system_generator.rb +1 -1
- data/lib/generators/rspec/view/view_generator.rb +2 -2
- data/lib/generators/rspec.rb +18 -1
- data/lib/rspec/rails/adapters.rb +11 -0
- data/lib/rspec/rails/configuration.rb +43 -14
- data/lib/rspec/rails/example/rails_example_group.rb +8 -0
- data/lib/rspec/rails/example/system_example_group.rb +58 -11
- data/lib/rspec/rails/example/view_example_group.rb +6 -5
- data/lib/rspec/rails/feature_check.rb +6 -2
- data/lib/rspec/rails/file_fixture_support.rb +3 -0
- data/lib/rspec/rails/fixture_file_upload_support.rb +20 -31
- data/lib/rspec/rails/fixture_support.rb +43 -15
- data/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +6 -3
- data/lib/rspec/rails/matchers/active_job.rb +4 -4
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +3 -2
- data/lib/rspec/rails/matchers/have_http_status.rb +1 -1
- data/lib/rspec/rails/matchers/routing_matchers.rb +2 -2
- data/lib/rspec/rails/matchers/send_email.rb +122 -0
- data/lib/rspec/rails/matchers.rb +1 -0
- data/lib/rspec/rails/vendor/capybara.rb +1 -3
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_assigns.rb +0 -18
- data/lib/rspec/rails/view_rendering.rb +13 -11
- data/lib/rspec-rails.rb +12 -8
- data.tar.gz.sig +0 -0
- metadata +28 -39
- metadata.gz.sig +0 -0
- /data/lib/generators/rspec/{integration → request}/templates/request_spec.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5ff6b0dc14db86b07e0cc46cd193329c85e21d15c9863ccbb5b73c54972daa6
|
4
|
+
data.tar.gz: c7bd505a3bfd16f881fb04b04e98ff7df9910d230eb17183fc68621a74d4b9d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6abbc3617dd82480b86c99c5d9347c94f8ac62bb944cf4ce1a223bea60046d9108be76fc3045a2e5f8549ad9813f7e831882f9ddee31de9d4215f643ce8a6d43
|
7
|
+
data.tar.gz: 07b551b367df408eaaa847307a6abd28a566a6a17ee4b552dc99a8bad95794f262884dc6e34a4d5717146fa001f89f6060cd1784818ed29f11f5361753fa606d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,5 +1,101 @@
|
|
1
1
|
### Development
|
2
|
-
[Full Changelog](https://github.com/rspec/rspec-rails/compare/
|
2
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.1...6-1-maintenance)
|
3
|
+
|
4
|
+
### 6.1.1 / 2024-01-25
|
5
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.0...v6.1.1)
|
6
|
+
|
7
|
+
Bug Fixes:
|
8
|
+
|
9
|
+
* Improved deprecation message for `RSpec::Rails::Configuration.fixture_paths`
|
10
|
+
(Benoit Tigeot, #2720)
|
11
|
+
* Fix support for namespaced fixtures in Rails 7.1. (Benedikt Deicke, #2716)
|
12
|
+
|
13
|
+
### 6.1.0 / 2023-11-21
|
14
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.4...v6.1.0)
|
15
|
+
|
16
|
+
Enhancements:
|
17
|
+
|
18
|
+
* Support for Rails 7.1
|
19
|
+
* Minor tweak to generated `rails_helper.rb` to use `Rails.root.join`.
|
20
|
+
(@masato-bkn, Ryo Nakamura, #2640, #2678)
|
21
|
+
* Add `RSpec::Rails::Configuration.fixture_paths` configuration to support
|
22
|
+
the matching change to `ActiveRecord::TestFixtures`, previous singular
|
23
|
+
form is deprecated and will be removed in Rails 7.2. (Juan Gueçaimburu, #2673)
|
24
|
+
* Add `send_email` matcher to match emails rather than specific jobs.
|
25
|
+
(Andrei Kaleshka, #2670)
|
26
|
+
* When using `render` in view specs, `:locals` will now be merged into the
|
27
|
+
default implicit template, allowing `render locals: {...}` style calls.
|
28
|
+
(Jon Rowe, #2686)
|
29
|
+
* Add support for `Rails.config.action_mailer.preview_paths` on Rails 7.1/
|
30
|
+
(Jon Rowe, #2706)
|
31
|
+
|
32
|
+
### 6.0.4 / 2023-11-21
|
33
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.3...v6.0.4)
|
34
|
+
|
35
|
+
Bug Fixes:
|
36
|
+
|
37
|
+
* Fuzzy match `have_broadcasted_to` so that argument matchers can be used.
|
38
|
+
(Timothy Peraza, #2684)
|
39
|
+
* Fix fixture warning during `:context` hooks on Rails `main`. (Jon Rowe, #2685)
|
40
|
+
* Fix `stub_template` on Rails `main`. (Jon Rowe, #2685)
|
41
|
+
* Fix variable name in scaffolded view specs when namespaced. (Taketo Takashima, #2694)
|
42
|
+
* Prevent `take_failed_screenshot` producing an additional error through `metadata`
|
43
|
+
access. (Jon Rowe, #2704)
|
44
|
+
* Use `ActiveSupport::ExecutionContext::TestHelper` on Rails 7+. (Jon Rowe, #2711)
|
45
|
+
* Fix leak of templates stubbed with `stub_template` on Rails 7.1. (Jon Rowe, #2714)
|
46
|
+
|
47
|
+
### 6.0.3 / 2023-05-31
|
48
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.2...v6.0.3)
|
49
|
+
|
50
|
+
Bug Fixes:
|
51
|
+
|
52
|
+
* Set `ActiveStorage::FixtureSet.file_fixture_path` when including file fixture support.
|
53
|
+
(Jason Yates, #2671)
|
54
|
+
* Allow `broadcast_to` matcher to take Symbols. (@Vagab, #2680)
|
55
|
+
|
56
|
+
### 6.0.2 / 2023-05-04
|
57
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.1...v6.0.2)
|
58
|
+
|
59
|
+
Bug Fixes:
|
60
|
+
|
61
|
+
* Fix ActionView::PathSet when `render_views` is off for Rails 7.1.
|
62
|
+
(Eugene Kenny, Iliana, #2631)
|
63
|
+
* Support Rails 7.1's `#fixtures_paths` in example groups (removes a deprecation warning).
|
64
|
+
(Nicholas Simmons, #2664)
|
65
|
+
* Fix `have_enqueued_job` to properly detect enqueued jobs when other jobs were
|
66
|
+
performed inside the expectation block. (Slava Kardakov, Phil Pirozhkov, #2573)
|
67
|
+
|
68
|
+
### 6.0.1 / 2022-10-18
|
69
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.0...v6.0.1)
|
70
|
+
|
71
|
+
Bug Fixes:
|
72
|
+
|
73
|
+
* Prevent tagged logged support in Rails 7 calling `#name`. (Jon Rowe, #2625)
|
74
|
+
|
75
|
+
### 6.0.0 / 2022-10-10
|
76
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.1.2...v6.0.0)
|
77
|
+
|
78
|
+
Enhancements:
|
79
|
+
|
80
|
+
* Support Rails 7
|
81
|
+
* Template tweaks to remove instance variables from generated specs. (Takuma Ishikawa, #2599)
|
82
|
+
* Generators now respects default path configuration option. (@vivekmiyani, #2508)
|
83
|
+
|
84
|
+
Breaking Changes:
|
85
|
+
|
86
|
+
* Drop support for Rails below 6.1
|
87
|
+
* Drop support for Ruby below 2.5 (following supported versions of Rails 6.1)
|
88
|
+
* Change the order of `after_teardown` from `after` to `around` in system
|
89
|
+
specs to improve compatibility with extensions and Capybara. (Tim Diggins, #2596)
|
90
|
+
|
91
|
+
Deprecations:
|
92
|
+
|
93
|
+
* Deprecates integration spec generator (`rspec:integration`)
|
94
|
+
which was an alias of request spec generator (`rspec:request`)
|
95
|
+
(Luka Lüdicke, #2374)
|
96
|
+
|
97
|
+
### 5.1.2 / 2022-04-24
|
98
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.1.1...v5.1.2)
|
3
99
|
|
4
100
|
Bug Fixes:
|
5
101
|
|
@@ -31,8 +127,9 @@ Bug Fixes:
|
|
31
127
|
|
32
128
|
* Properly name params in controller and request spec templates when
|
33
129
|
using the `--model-name` parameter. (@kenzo-tanaka, #2534)
|
34
|
-
* Fix
|
35
|
-
(Fabio Napoleoni,
|
130
|
+
* Fix parameter matching with mail delivery job and
|
131
|
+
ActionMailer::MailDeliveryJob. (Fabio Napoleoni, #2516, #2546)
|
132
|
+
* Fix Rails 7 `have_enqueued_mail` compatibility (Mikael Henriksson, #2537, #2546)
|
36
133
|
|
37
134
|
### 5.0.2 / 2021-08-14
|
38
135
|
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.1...v5.0.2)
|
@@ -78,7 +175,7 @@ Bug Fixes:
|
|
78
175
|
|
79
176
|
Enhancements:
|
80
177
|
|
81
|
-
* Issue a warning when using job matchers with `#at`
|
178
|
+
* Issue a warning when using job matchers with `#at` mismatch on `usec` precision.
|
82
179
|
(Jon Rowe, #2350)
|
83
180
|
* Generated request specs now have a bare `_spec` suffix instead of `request_spec`.
|
84
181
|
(Eloy Espinaco, Luka Lüdicke, #2355, #2356, #2378)
|
@@ -205,7 +302,7 @@ Bug Fixes:
|
|
205
302
|
|
206
303
|
Bug Fixes:
|
207
304
|
|
208
|
-
* Namespaced fixtures now generate a `/`
|
305
|
+
* Namespaced fixtures now generate a `/` separated path rather than an `_`.
|
209
306
|
(@nxlith, #2077)
|
210
307
|
* Check the arity of `errors` before attempting to use it to generate the `be_valid`
|
211
308
|
error message. (Kevin Kuchta, #2096)
|
@@ -365,7 +462,7 @@ Enhancements:
|
|
365
462
|
|
366
463
|
Bug fixes:
|
367
464
|
|
368
|
-
* Prevent asset helpers from taking
|
465
|
+
* Prevent asset helpers from taking precedence over route helpers. (Prem Sichanugrist, #1496)
|
369
466
|
* Prevent `NoMethodError` during failed `have_rendered` assertions on weird templates.
|
370
467
|
(Jon Rowe, #1623).
|
371
468
|
|
data/README.md
CHANGED
@@ -9,13 +9,12 @@ detailed explanations of how the application is supposed to behave,
|
|
9
9
|
expressed in plain English.
|
10
10
|
|
11
11
|
According to [RSpec Rails new versioning strategy][] use:
|
12
|
-
* **[`rspec-rails`
|
12
|
+
* **[`rspec-rails` 6.x][]** for Rails 6.1 or 7.x.
|
13
|
+
* **[`rspec-rails` 5.x][]** for Rails 5.2 or 6.x.
|
13
14
|
* **[`rspec-rails` 4.x][]** for Rails from 5.x or 6.x.
|
14
15
|
* **[`rspec-rails` 3.x][]** for Rails earlier than 5.0.
|
15
16
|
* **[`rspec-rails` 1.x][]** for Rails 2.x.
|
16
17
|
|
17
|
-
[Build Status]: https://secure.travis-ci.org/rspec/rspec-rails.svg?branch=main
|
18
|
-
[travis-ci]: https://travis-ci.org/rspec/rspec-rails
|
19
18
|
[Code Climate]: https://codeclimate.com/github/rspec/rspec-rails.svg
|
20
19
|
[code-climate]: https://codeclimate.com/github/rspec/rspec-rails
|
21
20
|
[Gem Version]: https://badge.fury.io/rb/rspec-rails.svg
|
@@ -25,13 +24,15 @@ According to [RSpec Rails new versioning strategy][] use:
|
|
25
24
|
[`rspec-rails` 1.x]: https://github.com/dchelimsky/rspec-rails
|
26
25
|
[`rspec-rails` 3.x]: https://github.com/rspec/rspec-rails/tree/3-9-maintenance
|
27
26
|
[`rspec-rails` 4.x]: https://github.com/rspec/rspec-rails/tree/4-1-maintenance
|
28
|
-
[`rspec-rails` 5.x]: https://github.com/rspec/rspec-rails/tree/5-
|
27
|
+
[`rspec-rails` 5.x]: https://github.com/rspec/rspec-rails/tree/5-1-maintenance
|
28
|
+
[`rspec-rails` 6.x]: https://github.com/rspec/rspec-rails/tree/6-1-maintenance
|
29
29
|
[RSpec Rails new versioning strategy]: https://github.com/rspec/rspec-rails/blob/main/rfcs/versioning-strategy.md
|
30
30
|
|
31
31
|
## Installation
|
32
32
|
|
33
|
-
**IMPORTANT** This README / branch refers to the
|
34
|
-
See the [`
|
33
|
+
**IMPORTANT** This README / branch refers to the 6.1.x stable release series, only bugfixes from this series will
|
34
|
+
be added here. See the [`main` branch on Github](https://github.com/rspec/rspec-rails/tree/main) if you want or
|
35
|
+
require the latest unstable features.
|
35
36
|
|
36
37
|
1. Add `rspec-rails` to **both** the `:development` and `:test` groups
|
37
38
|
of your app’s `Gemfile`:
|
@@ -39,7 +40,7 @@ See the [`5-0-maintenance` branch on Github](https://github.com/rspec/rspec-rail
|
|
39
40
|
```ruby
|
40
41
|
# Run against this stable release
|
41
42
|
group :development, :test do
|
42
|
-
gem 'rspec-rails', '~>
|
43
|
+
gem 'rspec-rails', '~> 6.1.0'
|
43
44
|
end
|
44
45
|
|
45
46
|
# Or, run against the main branch
|
@@ -86,8 +87,8 @@ read the [`rspec-rails` upgrade notes][] to find out what to watch out for.
|
|
86
87
|
|
87
88
|
Be sure to check the general [RSpec upgrade notes][] as well.
|
88
89
|
|
89
|
-
[`rspec-rails` upgrade notes]: https://
|
90
|
-
[RSpec upgrade notes]: https://
|
90
|
+
[`rspec-rails` upgrade notes]: https://rspec.info/features/6-0/rspec-rails/upgrade
|
91
|
+
[RSpec upgrade notes]: https://rspec.info/upgrading-from-rspec-2/
|
91
92
|
|
92
93
|
## Usage
|
93
94
|
|
@@ -181,7 +182,7 @@ rspec ./spec/models/post_spec.rb:3 # Post before publication cannot have comment
|
|
181
182
|
For an in-depth look at the RSpec DSL, including lots of examples,
|
182
183
|
read the official Cucumber documentation for [RSpec Core][].
|
183
184
|
|
184
|
-
[RSpec Core]: https://
|
185
|
+
[RSpec Core]: https://rspec.info/features/3-12/rspec-core
|
185
186
|
|
186
187
|
### Helpful Rails Matchers
|
187
188
|
|
@@ -207,23 +208,23 @@ to test the various parts of a Rails system:
|
|
207
208
|
|
208
209
|
Follow the links above for examples of how each matcher is used.
|
209
210
|
|
210
|
-
[the matchers that come standard in RSpec]: https://
|
211
|
-
[`be_a_new`]: https://
|
212
|
-
[`render_template`]: https://
|
213
|
-
[`redirect_to`]: https://
|
214
|
-
[`route_to`]: https://
|
215
|
-
[`be_routable`]: https://
|
216
|
-
[`have_http_status`]: https://
|
217
|
-
[`match_array`]: https://
|
218
|
-
[`have_been_enqueued`]: https://
|
219
|
-
[`have_enqueued_job`]: https://
|
211
|
+
[the matchers that come standard in RSpec]: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers
|
212
|
+
[`be_a_new`]: https://rspec.info/features/6-0/rspec-rails/matchers/new-record-matcher
|
213
|
+
[`render_template`]: https://rspec.info/features/6-0/rspec-rails/matchers/render-template-matcher
|
214
|
+
[`redirect_to`]: https://rspec.info/features/6-0/rspec-rails/matchers/redirect-to-matcher
|
215
|
+
[`route_to`]: https://rspec.info/features/6-0/rspec-rails/routing-specs/route-to-matcher
|
216
|
+
[`be_routable`]: https://rspec.info/features/6-0/rspec-rails/routing-specs/be-routable-matcher
|
217
|
+
[`have_http_status`]: https://rspec.info/features/6-0/rspec-rails/matchers/have-http-status-matcher
|
218
|
+
[`match_array`]: https://rspec.info/features/6-0/rspec-rails/matchers/relation-match-array
|
219
|
+
[`have_been_enqueued`]: https://rspec.info/features/6-0/rspec-rails/matchers/have-been-enqueued-matcher
|
220
|
+
[`have_enqueued_job`]: https://rspec.info/features/6-0/rspec-rails/matchers/have-enqueued-job-matcher
|
220
221
|
|
221
222
|
### What else does RSpec Rails add?
|
222
223
|
|
223
224
|
For a comprehensive look at RSpec Rails’ features,
|
224
225
|
read the [official Cucumber documentation][].
|
225
226
|
|
226
|
-
[official Cucumber documentation]: https://
|
227
|
+
[official Cucumber documentation]: https://rspec.info/features/6-0/rspec-rails
|
227
228
|
|
228
229
|
## What tests should I write?
|
229
230
|
|
@@ -268,20 +269,20 @@ RSpec.describe User, type: :model do
|
|
268
269
|
...
|
269
270
|
```
|
270
271
|
|
271
|
-
[request]: https://
|
272
|
-
[feature]: https://
|
273
|
-
[system]: https://
|
274
|
-
[model]: https://
|
275
|
-
[controller]: https://
|
276
|
-
[mailer]: https://
|
277
|
-
[job]: https://
|
278
|
-
[view]: https://
|
279
|
-
[routing]: https://
|
280
|
-
[helper]: https://
|
272
|
+
[request]: https://rspec.info/features/6-0/rspec-rails/request-specs/request-spec
|
273
|
+
[feature]: https://rspec.info/features/6-0/rspec-rails/feature-specs/feature-spec
|
274
|
+
[system]: https://rspec.info/features/6-0/rspec-rails/system-specs/system-specs
|
275
|
+
[model]: https://rspec.info/features/6-0/rspec-rails/model-specs
|
276
|
+
[controller]: https://rspec.info/features/6-0/rspec-rails/controller-specs
|
277
|
+
[mailer]: https://rspec.info/features/6-0/rspec-rails/mailer-specs
|
278
|
+
[job]: https://rspec.info/features/6-0/rspec-rails/job-specs/job-spec
|
279
|
+
[view]: https://rspec.info/features/6-0/rspec-rails/view-specs/view-spec
|
280
|
+
[routing]: https://rspec.info/features/6-0/rspec-rails/routing-specs
|
281
|
+
[helper]: https://rspec.info/features/6-0/rspec-rails/helper-specs/helper-spec
|
281
282
|
[`ActionDispatch::IntegrationTest`]: https://api.rubyonrails.org/classes/ActionDispatch/IntegrationTest.html
|
282
283
|
[`ActionDispatch::SystemTestCase`]: https://api.rubyonrails.org/classes/ActionDispatch/SystemTestCase.html
|
283
284
|
[`ActionController::TestCase`]: https://api.rubyonrails.org/classes/ActionController/TestCase.html
|
284
|
-
[in the appropriate folder]: https://
|
285
|
+
[in the appropriate folder]: https://rspec.info/features/6-0/rspec-rails/directory-structure
|
285
286
|
|
286
287
|
### System specs, feature specs, request specs–what’s the difference?
|
287
288
|
|
@@ -364,10 +365,10 @@ you can run the specs and Cucumber features, or submit a pull request.
|
|
364
365
|
|
365
366
|
### RSpec base libraries
|
366
367
|
|
367
|
-
*
|
368
|
-
*
|
369
|
-
*
|
370
|
-
*
|
368
|
+
* https://github.com/rspec/rspec
|
369
|
+
* https://github.com/rspec/rspec-core
|
370
|
+
* https://github.com/rspec/rspec-expectations
|
371
|
+
* https://github.com/rspec/rspec-mocks
|
371
372
|
|
372
373
|
### Recommended third-party extensions
|
373
374
|
|
@@ -5,7 +5,7 @@ module Rspec
|
|
5
5
|
# @private
|
6
6
|
class ChannelGenerator < Base
|
7
7
|
def create_channel_spec
|
8
|
-
template 'channel_spec.rb.erb',
|
8
|
+
template 'channel_spec.rb.erb', target_path('channels', class_path, "#{file_name}_channel_spec.rb")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -16,14 +16,14 @@ module Rspec
|
|
16
16
|
return unless options[:request_specs]
|
17
17
|
|
18
18
|
template 'request_spec.rb',
|
19
|
-
|
19
|
+
target_path('requests', class_path, "#{file_name}_spec.rb")
|
20
20
|
end
|
21
21
|
|
22
22
|
def generate_controller_spec
|
23
23
|
return unless options[:controller_specs]
|
24
24
|
|
25
25
|
template 'controller_spec.rb',
|
26
|
-
|
26
|
+
target_path('controllers', class_path, "#{file_name}_controller_spec.rb")
|
27
27
|
end
|
28
28
|
|
29
29
|
def generate_view_specs
|
@@ -35,7 +35,7 @@ module Rspec
|
|
35
35
|
actions.each do |action|
|
36
36
|
@action = action
|
37
37
|
template 'view_spec.rb',
|
38
|
-
|
38
|
+
target_path('views', file_path, "#{@action}.html.#{options[:template_engine]}_spec.rb")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -44,7 +44,7 @@ module Rspec
|
|
44
44
|
return unless options[:routing_specs]
|
45
45
|
|
46
46
|
template 'routing_spec.rb',
|
47
|
-
|
47
|
+
target_path('routing', class_path, "#{file_name}_routing_spec.rb")
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -10,7 +10,7 @@ module Rspec
|
|
10
10
|
def generate_feature_spec
|
11
11
|
return unless options[:feature_specs]
|
12
12
|
|
13
|
-
template template_name,
|
13
|
+
template template_name, target_path('features', class_path, filename)
|
14
14
|
end
|
15
15
|
|
16
16
|
def template_name
|
@@ -9,7 +9,7 @@ module Rspec
|
|
9
9
|
def generate_generator_spec
|
10
10
|
return unless options[:generator_specs]
|
11
11
|
|
12
|
-
template template_name,
|
12
|
+
template template_name, target_path('generator', class_path, filename)
|
13
13
|
end
|
14
14
|
|
15
15
|
def template_name
|
@@ -9,7 +9,7 @@ module Rspec
|
|
9
9
|
def generate_helper_spec
|
10
10
|
return unless options[:helper_specs]
|
11
11
|
|
12
|
-
template 'helper_spec.rb',
|
12
|
+
template 'helper_spec.rb', target_path('helpers', class_path, "#{file_name}_helper_spec.rb")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -12,6 +12,8 @@ Description:
|
|
12
12
|
Copy rspec files to your application.
|
13
13
|
DESC
|
14
14
|
|
15
|
+
class_option :default_path, type: :string, default: 'spec'
|
16
|
+
|
15
17
|
def self.source_root
|
16
18
|
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
17
19
|
end
|
@@ -20,12 +22,12 @@ DESC
|
|
20
22
|
Dir.mktmpdir do |dir|
|
21
23
|
generate_rspec_init dir
|
22
24
|
template File.join(dir, '.rspec'), '.rspec'
|
23
|
-
directory File.join(dir, 'spec'),
|
25
|
+
directory File.join(dir, 'spec'), default_path
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
def copy_rails_files
|
28
|
-
template 'spec/rails_helper.rb'
|
30
|
+
template 'spec/rails_helper.rb', "#{default_path}/rails_helper.rb"
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
@@ -41,6 +43,12 @@ DESC
|
|
41
43
|
|
42
44
|
replace_generator_command(spec_helper_path)
|
43
45
|
remove_warnings_configuration(spec_helper_path)
|
46
|
+
|
47
|
+
unless default_path == "spec"
|
48
|
+
dot_rspec_path = File.join(tmpdir, '.rspec')
|
49
|
+
|
50
|
+
append_default_path(dot_rspec_path)
|
51
|
+
end
|
44
52
|
end
|
45
53
|
|
46
54
|
def replace_generator_command(spec_helper_path)
|
@@ -58,6 +66,15 @@ DESC
|
|
58
66
|
'',
|
59
67
|
verbose: false
|
60
68
|
end
|
69
|
+
|
70
|
+
def append_default_path(dot_rspec_path)
|
71
|
+
append_to_file dot_rspec_path,
|
72
|
+
"--default-path #{default_path}"
|
73
|
+
end
|
74
|
+
|
75
|
+
def default_path
|
76
|
+
options[:default_path]
|
77
|
+
end
|
61
78
|
end
|
62
79
|
end
|
63
80
|
end
|
@@ -20,7 +20,7 @@ require 'rspec/rails'
|
|
20
20
|
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
21
21
|
# require only the support files necessary.
|
22
22
|
#
|
23
|
-
#
|
23
|
+
# Rails.root.glob('spec/support/**/*.rb').sort.each { |f| require f }
|
24
24
|
|
25
25
|
<% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%>
|
26
26
|
# Checks for pending migrations and applies them before tests are run.
|
@@ -28,14 +28,19 @@ require 'rspec/rails'
|
|
28
28
|
begin
|
29
29
|
ActiveRecord::Migration.maintain_test_schema!
|
30
30
|
rescue ActiveRecord::PendingMigrationError => e
|
31
|
-
|
32
|
-
exit 1
|
31
|
+
abort e.to_s.strip
|
33
32
|
end
|
34
33
|
<% end -%>
|
35
34
|
RSpec.configure do |config|
|
36
35
|
<% if RSpec::Rails::FeatureCheck.has_active_record? -%>
|
37
36
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
38
|
-
|
37
|
+
<% if ::Rails::VERSION::STRING < "7.1.0" -%>
|
38
|
+
config.fixture_path = Rails.root.join('spec/fixtures')
|
39
|
+
<% else -%>
|
40
|
+
config.fixture_paths = [
|
41
|
+
Rails.root.join('spec/fixtures')
|
42
|
+
]
|
43
|
+
<% end -%>
|
39
44
|
|
40
45
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
41
46
|
# examples within a transaction, remove the following line or assign false
|
@@ -49,11 +54,11 @@ RSpec.configure do |config|
|
|
49
54
|
# Remove this line to enable support for ActiveRecord
|
50
55
|
config.use_active_record = false
|
51
56
|
|
52
|
-
# If you enable ActiveRecord support you should
|
57
|
+
# If you enable ActiveRecord support you should uncomment these lines,
|
53
58
|
# note if you'd prefer not to run each example within a transaction, you
|
54
59
|
# should set use_transactional_fixtures to false.
|
55
60
|
#
|
56
|
-
# config.fixture_path =
|
61
|
+
# config.fixture_path = Rails.root.join('spec/fixtures')
|
57
62
|
# config.use_transactional_fixtures = true
|
58
63
|
|
59
64
|
<% end -%>
|
@@ -69,7 +74,7 @@ RSpec.configure do |config|
|
|
69
74
|
# end
|
70
75
|
#
|
71
76
|
# The different available types are documented in the features, such as in
|
72
|
-
# https://
|
77
|
+
# https://rspec.info/features/6-0/rspec-rails
|
73
78
|
config.infer_spec_type_from_file_location!
|
74
79
|
|
75
80
|
# Filter lines from Rails gems in backtraces.
|
@@ -1,21 +1,28 @@
|
|
1
1
|
require 'generators/rspec'
|
2
|
+
require 'rspec/core/warnings'
|
2
3
|
|
3
4
|
module Rspec
|
4
5
|
module Generators
|
5
6
|
# @private
|
6
7
|
class IntegrationGenerator < Base
|
7
|
-
# Add a deprecation for this class, before rspec-rails 4, to use the
|
8
|
-
# `RequestGenerator` instead
|
9
8
|
class_option :request_specs,
|
10
9
|
type: :boolean,
|
11
10
|
default: true,
|
12
11
|
desc: "Generate request specs"
|
13
12
|
|
13
|
+
source_paths << File.expand_path('../request/templates', __dir__)
|
14
|
+
|
14
15
|
def generate_request_spec
|
15
16
|
return unless options[:request_specs]
|
16
17
|
|
18
|
+
RSpec.warn_deprecation <<-WARNING.gsub(/\s*\|/, ' ')
|
19
|
+
|The integration generator is deprecated
|
20
|
+
|and will be deleted in RSpec-Rails 7.
|
21
|
+
|Please use the request generator instead.
|
22
|
+
WARNING
|
23
|
+
|
17
24
|
template 'request_spec.rb',
|
18
|
-
|
25
|
+
target_path('requests', "#{name.underscore.pluralize}_spec.rb")
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
@@ -6,7 +6,7 @@ module Rspec
|
|
6
6
|
class JobGenerator < Base
|
7
7
|
def create_job_spec
|
8
8
|
file_suffix = file_name.end_with?('job') ? 'spec.rb' : 'job_spec.rb'
|
9
|
-
template 'job_spec.rb.erb',
|
9
|
+
template 'job_spec.rb.erb', target_path('jobs', class_path, [file_name, file_suffix].join('_'))
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -6,7 +6,7 @@ module Rspec
|
|
6
6
|
class MailboxGenerator < Base
|
7
7
|
def create_mailbox_spec
|
8
8
|
template('mailbox_spec.rb.erb',
|
9
|
-
|
9
|
+
target_path('mailboxes', class_path, "#{file_name}_mailbox_spec.rb")
|
10
10
|
)
|
11
11
|
end
|
12
12
|
end
|
@@ -8,20 +8,20 @@ module Rspec
|
|
8
8
|
argument :actions, type: :array, default: [], banner: "method method"
|
9
9
|
|
10
10
|
def generate_mailer_spec
|
11
|
-
template "mailer_spec.rb",
|
11
|
+
template "mailer_spec.rb", target_path('mailers', class_path, "#{file_name}_spec.rb")
|
12
12
|
end
|
13
13
|
|
14
14
|
def generate_fixtures_files
|
15
15
|
actions.each do |action|
|
16
16
|
@action, @path = action, File.join(file_path, action)
|
17
|
-
template "fixture",
|
17
|
+
template "fixture", target_path("fixtures", @path)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
def generate_preview_files
|
22
22
|
return unless RSpec::Rails::FeatureCheck.has_action_mailer_preview?
|
23
23
|
|
24
|
-
template "preview.rb",
|
24
|
+
template "preview.rb", target_path("mailers/previews", class_path, "#{file_name}_preview.rb")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -11,8 +11,8 @@ module Rspec
|
|
11
11
|
class_option :fixture, type: :boolean
|
12
12
|
|
13
13
|
def create_model_spec
|
14
|
-
template_file =
|
15
|
-
'
|
14
|
+
template_file = target_path(
|
15
|
+
'models',
|
16
16
|
class_path,
|
17
17
|
"#{file_name}_spec.rb"
|
18
18
|
)
|
@@ -24,7 +24,7 @@ module Rspec
|
|
24
24
|
def create_fixture_file
|
25
25
|
return unless missing_fixture_replacement?
|
26
26
|
|
27
|
-
template 'fixtures.yml',
|
27
|
+
template 'fixtures.yml', target_path('fixtures', class_path, "#{(pluralize_table_names? ? plural_file_name : file_name)}.yml")
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
@@ -1,10 +1,17 @@
|
|
1
|
-
require 'generators/rspec
|
1
|
+
require 'generators/rspec'
|
2
2
|
|
3
3
|
module Rspec
|
4
4
|
module Generators
|
5
5
|
# @private
|
6
|
-
class RequestGenerator <
|
7
|
-
|
6
|
+
class RequestGenerator < Base
|
7
|
+
class_option :request_specs, type: :boolean, default: true, desc: 'Generate request specs'
|
8
|
+
|
9
|
+
def generate_request_spec
|
10
|
+
return unless options[:request_specs]
|
11
|
+
|
12
|
+
template 'request_spec.rb',
|
13
|
+
target_path('requests', "#{name.underscore.pluralize}_spec.rb")
|
14
|
+
end
|
8
15
|
end
|
9
16
|
end
|
10
17
|
end
|
@@ -58,8 +58,8 @@ module Rspec
|
|
58
58
|
def generate_routing_spec
|
59
59
|
return unless options[:routing_specs]
|
60
60
|
|
61
|
-
template_file =
|
62
|
-
'
|
61
|
+
template_file = target_path(
|
62
|
+
'routing',
|
63
63
|
controller_class_path,
|
64
64
|
"#{controller_file_name}_routing_spec.rb"
|
65
65
|
)
|
@@ -72,7 +72,7 @@ module Rspec
|
|
72
72
|
|
73
73
|
def copy_view(view)
|
74
74
|
template "#{view}_spec.rb",
|
75
|
-
|
75
|
+
target_path("views", controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
|
76
76
|
end
|
77
77
|
|
78
78
|
# support for namespaced-resources
|
@@ -121,7 +121,7 @@ module Rspec
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def template_file(folder:, suffix: '')
|
124
|
-
|
124
|
+
target_path(folder, controller_class_path, "#{controller_file_name}#{suffix}_spec.rb")
|
125
125
|
end
|
126
126
|
|
127
127
|
def banner
|