rspec-rails 7.1.1 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Changelog.md +72 -1
- data/README.md +35 -29
- data/lib/generators/rspec/authentication/authentication_generator.rb +25 -0
- data/lib/generators/rspec/authentication/templates/user_spec.rb +5 -0
- data/lib/generators/rspec/authentication/templates/users.yml +11 -0
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +8 -8
- data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +2 -2
- data/lib/generators/rspec/scaffold/templates/api_request_spec.rb +2 -2
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +2 -2
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +4 -0
- data/lib/generators/rspec/scaffold/templates/request_spec.rb +2 -2
- data/lib/rspec/rails/configuration.rb +3 -67
- data/lib/rspec/rails/example/feature_example_group.rb +4 -1
- data/lib/rspec/rails/example/mailer_example_group.rb +2 -2
- data/lib/rspec/rails/example/rails_example_group.rb +4 -0
- data/lib/rspec/rails/example/system_example_group.rb +38 -41
- data/lib/rspec/rails/example/view_example_group.rb +1 -1
- data/lib/rspec/rails/fixture_file_upload_support.rb +2 -8
- data/lib/rspec/rails/fixture_support.rb +12 -42
- data/lib/rspec/rails/matchers/active_job.rb +8 -0
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +3 -3
- data/lib/rspec/rails/matchers/send_email.rb +1 -1
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_rendering.rb +12 -11
- data/lib/rspec-rails.rb +16 -22
- data.tar.gz.sig +0 -0
- metadata +74 -47
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d88929c04dcfe23886634c2cee7b781424809e2a0936279d57845f6e2db1d0b4
|
|
4
|
+
data.tar.gz: 84b5f02cdbbf7d4f5d3ed10157d03f82482bda4a7703056c4eb226203d58d308
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4118ac91cd9e2c0967477276b276d044e716a744b5cccad10dc0dc70f64f0a96b9665f5b3a17443dcd96ebe2bbcbc05d48cd036ab05d840492819296d4b5b811
|
|
7
|
+
data.tar.gz: d244ab16568c9101c1e1b4c541095417c36c408247d1841ac5a42a1f5ebbf53b75df960878f0abcf4438523c683b957daa7989bc8ef43d75b692a68a63bd74e8
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/Changelog.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
### Development
|
|
2
|
-
[Full Changelog](https://github.com/rspec/rspec-rails/compare/
|
|
2
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v8.1.0...8-1-maintenance)
|
|
3
|
+
|
|
4
|
+
### 8.1.0 / 2026-11-06
|
|
5
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v8.0.5...v8.1.0)
|
|
6
|
+
|
|
7
|
+
Enhancements:
|
|
8
|
+
|
|
9
|
+
* Officially support Rails 8.1, there are no changes to the behaviour of Rails 8.1 from rspec-rails 8.0.x
|
|
10
|
+
this release fulfils our versioning strategy and kepts CI up to date.
|
|
11
|
+
|
|
12
|
+
Bug Fixes:
|
|
13
|
+
|
|
14
|
+
* Handle having a frozen hash for `default_url_options` by assigning rather than mutating it.
|
|
15
|
+
(Federico Carrocera, rspec/rspec-rails#2907)
|
|
16
|
+
* Fix view specs manipulating a frozen array (for template prefixes) in `actionview` internals.
|
|
17
|
+
(Iliana Hadzhiatanasova, rspec/rspec-rails#2915)
|
|
18
|
+
* Refactor template rendering to prepare for future Rails releases. (Saïd M., Phil Pirozhkov, rspec/rspec-rails#2927)
|
|
19
|
+
|
|
20
|
+
### 8.0.5 / 2026-11-06
|
|
21
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v8.0.4...v8.0.5)
|
|
22
|
+
|
|
23
|
+
Bug Fixes:
|
|
24
|
+
|
|
25
|
+
* Include `ActiveJob::TestHelper` in all rails example groups to ensure jobs are reset
|
|
26
|
+
between examples matching Rails in-build behaviour. (Hammad Khan, rspec/rspec-rails#2901)
|
|
27
|
+
* Fix `have_enqueued_mail` argument matching for mail enqueued by `ActionMailer.deliver_all_later`
|
|
28
|
+
without params. (Andrew Fader, rspec/rspec-rails#2931)
|
|
29
|
+
|
|
30
|
+
### 8.0.4 / 2026-03-10
|
|
31
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v8.0.3...v8.0.4)
|
|
32
|
+
|
|
33
|
+
Released to relax version constraint for rspec to allow 4.0.0.beta1.
|
|
34
|
+
|
|
35
|
+
### 8.0.3 / 2026-02-17
|
|
36
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v8.0.2...v8.0.3)
|
|
37
|
+
|
|
38
|
+
Bug Fixes:
|
|
39
|
+
|
|
40
|
+
* Fix insertion order of controller prefix in the view `lookup_context`. (Stephen Nelson, #2749)
|
|
41
|
+
* Ensure `rails stats` looks for specs using application root rather than working directory.
|
|
42
|
+
(Marvin Tangpos, #2879)
|
|
43
|
+
|
|
44
|
+
### 8.0.2 / 2025-08-12
|
|
45
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v8.0.1...v8.0.2)
|
|
46
|
+
|
|
47
|
+
Bug Fixes:
|
|
48
|
+
|
|
49
|
+
* Fix scaffold generator producing deprecated Rack http statuses.
|
|
50
|
+
(Taketo Takashima, rspec/rspec-rails#2860)
|
|
51
|
+
|
|
52
|
+
### 8.0.1 / 2025-06-19
|
|
53
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v8.0.0...v8.0.1)
|
|
54
|
+
|
|
55
|
+
Bug Fixes:
|
|
56
|
+
|
|
57
|
+
* Make the `have_been_performed` / `have_been_enqueued` return `false` for
|
|
58
|
+
`supports_block_expectations?` as they don't supporting block expectations.
|
|
59
|
+
(Sam Kidman, rspec/rspec-rails#2851)
|
|
60
|
+
|
|
61
|
+
### 8.0.0 / 2025-04-30
|
|
62
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.1.1...v8.0.0)
|
|
63
|
+
|
|
64
|
+
Enhancements:
|
|
65
|
+
|
|
66
|
+
* Add Rails 8 authentication generator support. (Jerome Dalbert, rspec/rspec-rails#2811)
|
|
67
|
+
* Improve install generator comment for `ActiveRecord::Migration.maintain_test_schema!`
|
|
68
|
+
(rspec/rspec-rails#2832)
|
|
69
|
+
* Add support for `served_by` in system specs. (Sam Giffney, rspec/rspec-rails#2841)
|
|
70
|
+
|
|
71
|
+
Breaking Changes:
|
|
72
|
+
|
|
73
|
+
* Minimum supported Rails version is 7.2.0
|
|
3
74
|
|
|
4
75
|
### 7.1.1 / 2025-02-06
|
|
5
76
|
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.1.0...v7.1.1)
|
data/README.md
CHANGED
|
@@ -8,7 +8,15 @@ They’re also specifications (or _specs,_ for short):
|
|
|
8
8
|
detailed explanations of how the application is supposed to behave,
|
|
9
9
|
expressed in plain English.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Supported Versions
|
|
12
|
+
|
|
13
|
+
We follow a versioning strategy as defined by [RSpec Rails versioning strategy][] the
|
|
14
|
+
TL;DR of which is that we support currently supported versions of Rails, and will
|
|
15
|
+
issue a major version change when removing older versions from support.
|
|
16
|
+
|
|
17
|
+
Accordingly you should use:
|
|
18
|
+
|
|
19
|
+
* **[`rspec-rails` 8.x][]** for Rails 8.1, 8.0 or 7.2.
|
|
12
20
|
* **[`rspec-rails` 7.x][]** for Rails 7.x.
|
|
13
21
|
* **[`rspec-rails` 6.x][]** for Rails 6.1, 7.0 or 7.1.
|
|
14
22
|
* **[`rspec-rails` 5.x][]** for Rails 5.2 or 6.x.
|
|
@@ -28,11 +36,12 @@ According to [RSpec Rails new versioning strategy][] use:
|
|
|
28
36
|
[`rspec-rails` 5.x]: https://github.com/rspec/rspec-rails/tree/5-1-maintenance
|
|
29
37
|
[`rspec-rails` 6.x]: https://github.com/rspec/rspec-rails/tree/6-1-maintenance
|
|
30
38
|
[`rspec-rails` 7.x]: https://github.com/rspec/rspec-rails/tree/7-1-maintenance
|
|
31
|
-
[
|
|
39
|
+
[`rspec-rails` 8.x]: https://github.com/rspec/rspec-rails/tree/8-0-maintenance
|
|
40
|
+
[RSpec Rails versioning strategy]: https://github.com/rspec/rspec-rails/blob/main/rfcs/versioning-strategy.md
|
|
32
41
|
|
|
33
42
|
## Installation
|
|
34
43
|
|
|
35
|
-
**IMPORTANT** This README / branch refers to the
|
|
44
|
+
**IMPORTANT** This README / branch refers to the 8.1.x stable release series, only bugfixes from this series will
|
|
36
45
|
be added here. See the [`main` branch on Github](https://github.com/rspec/rspec-rails/tree/main) if you want or
|
|
37
46
|
require the latest unstable features.
|
|
38
47
|
|
|
@@ -42,7 +51,7 @@ require the latest unstable features.
|
|
|
42
51
|
```ruby
|
|
43
52
|
# Run against this stable release
|
|
44
53
|
group :development, :test do
|
|
45
|
-
gem 'rspec-rails', '~>
|
|
54
|
+
gem 'rspec-rails', '~> 8.0.0'
|
|
46
55
|
end
|
|
47
56
|
|
|
48
57
|
# Or, run against the main branch
|
|
@@ -86,7 +95,7 @@ read the [`rspec-rails` upgrade notes][] to find out what to watch out for.
|
|
|
86
95
|
|
|
87
96
|
Be sure to check the general [RSpec upgrade notes][] as well.
|
|
88
97
|
|
|
89
|
-
[`rspec-rails` upgrade notes]: https://rspec.info/features/
|
|
98
|
+
[`rspec-rails` upgrade notes]: https://rspec.info/features/8-0/rspec-rails/upgrade
|
|
90
99
|
[RSpec upgrade notes]: https://rspec.info/upgrading-from-rspec-2/
|
|
91
100
|
|
|
92
101
|
## Usage
|
|
@@ -208,22 +217,22 @@ to test the various parts of a Rails system:
|
|
|
208
217
|
Follow the links above for examples of how each matcher is used.
|
|
209
218
|
|
|
210
219
|
[the matchers that come standard in RSpec]: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers
|
|
211
|
-
[`be_a_new`]: https://rspec.info/features/
|
|
212
|
-
[`render_template`]: https://rspec.info/features/
|
|
213
|
-
[`redirect_to`]: https://rspec.info/features/
|
|
214
|
-
[`route_to`]: https://rspec.info/features/
|
|
215
|
-
[`be_routable`]: https://rspec.info/features/
|
|
216
|
-
[`have_http_status`]: https://rspec.info/features/
|
|
217
|
-
[`match_array`]: https://rspec.info/features/
|
|
218
|
-
[`have_been_enqueued`]: https://rspec.info/features/
|
|
219
|
-
[`have_enqueued_job`]: https://rspec.info/features/
|
|
220
|
+
[`be_a_new`]: https://rspec.info/features/8-0/rspec-rails/matchers/new-record-matcher
|
|
221
|
+
[`render_template`]: https://rspec.info/features/8-0/rspec-rails/matchers/render-template-matcher
|
|
222
|
+
[`redirect_to`]: https://rspec.info/features/8-0/rspec-rails/matchers/redirect-to-matcher
|
|
223
|
+
[`route_to`]: https://rspec.info/features/8-0/rspec-rails/routing-specs/route-to-matcher
|
|
224
|
+
[`be_routable`]: https://rspec.info/features/8-0/rspec-rails/routing-specs/be-routable-matcher
|
|
225
|
+
[`have_http_status`]: https://rspec.info/features/8-0/rspec-rails/matchers/have-http-status-matcher
|
|
226
|
+
[`match_array`]: https://rspec.info/features/8-0/rspec-rails/matchers/relation-match-array
|
|
227
|
+
[`have_been_enqueued`]: https://rspec.info/features/8-0/rspec-rails/matchers/have-been-enqueued-matcher
|
|
228
|
+
[`have_enqueued_job`]: https://rspec.info/features/8-0/rspec-rails/matchers/have-enqueued-job-matcher
|
|
220
229
|
|
|
221
230
|
### What else does RSpec Rails add?
|
|
222
231
|
|
|
223
232
|
For a comprehensive look at RSpec Rails’ features,
|
|
224
233
|
read the [official Cucumber documentation][].
|
|
225
234
|
|
|
226
|
-
[official Cucumber documentation]: https://rspec.info/features/
|
|
235
|
+
[official Cucumber documentation]: https://rspec.info/features/8-0/rspec-rails
|
|
227
236
|
|
|
228
237
|
## What tests should I write?
|
|
229
238
|
|
|
@@ -268,20 +277,20 @@ RSpec.describe User, type: :model do
|
|
|
268
277
|
...
|
|
269
278
|
```
|
|
270
279
|
|
|
271
|
-
[request]: https://rspec.info/features/
|
|
272
|
-
[feature]: https://rspec.info/features/
|
|
273
|
-
[system]: https://rspec.info/features/
|
|
274
|
-
[model]: https://rspec.info/features/
|
|
275
|
-
[controller]: https://rspec.info/features/
|
|
276
|
-
[mailer]: https://rspec.info/features/
|
|
277
|
-
[job]: https://rspec.info/features/
|
|
278
|
-
[view]: https://rspec.info/features/
|
|
279
|
-
[routing]: https://rspec.info/features/
|
|
280
|
-
[helper]: https://rspec.info/features/
|
|
280
|
+
[request]: https://rspec.info/features/8-0/rspec-rails/request-specs/request-spec
|
|
281
|
+
[feature]: https://rspec.info/features/8-0/rspec-rails/feature-specs/feature-spec
|
|
282
|
+
[system]: https://rspec.info/features/8-0/rspec-rails/system-specs/system-specs
|
|
283
|
+
[model]: https://rspec.info/features/8-0/rspec-rails/model-specs
|
|
284
|
+
[controller]: https://rspec.info/features/8-0/rspec-rails/controller-specs
|
|
285
|
+
[mailer]: https://rspec.info/features/8-0/rspec-rails/mailer-specs
|
|
286
|
+
[job]: https://rspec.info/features/8-0/rspec-rails/job-specs/job-spec
|
|
287
|
+
[view]: https://rspec.info/features/8-0/rspec-rails/view-specs/view-spec
|
|
288
|
+
[routing]: https://rspec.info/features/8-0/rspec-rails/routing-specs
|
|
289
|
+
[helper]: https://rspec.info/features/8-0/rspec-rails/helper-specs/helper-spec
|
|
281
290
|
[`ActionDispatch::IntegrationTest`]: https://api.rubyonrails.org/classes/ActionDispatch/IntegrationTest.html
|
|
282
291
|
[`ActionDispatch::SystemTestCase`]: https://api.rubyonrails.org/classes/ActionDispatch/SystemTestCase.html
|
|
283
292
|
[`ActionController::TestCase`]: https://api.rubyonrails.org/classes/ActionController/TestCase.html
|
|
284
|
-
[in the appropriate folder]: https://rspec.info/features/
|
|
293
|
+
[in the appropriate folder]: https://rspec.info/features/8-0/rspec-rails/directory-structure
|
|
285
294
|
|
|
286
295
|
### System specs, feature specs, request specs–what’s the difference?
|
|
287
296
|
|
|
@@ -365,9 +374,6 @@ you can run the specs and Cucumber features, or submit a pull request.
|
|
|
365
374
|
### RSpec base libraries
|
|
366
375
|
|
|
367
376
|
* https://github.com/rspec/rspec
|
|
368
|
-
* https://github.com/rspec/rspec-core
|
|
369
|
-
* https://github.com/rspec/rspec-expectations
|
|
370
|
-
* https://github.com/rspec/rspec-mocks
|
|
371
377
|
|
|
372
378
|
### Recommended third-party extensions
|
|
373
379
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'generators/rspec'
|
|
2
|
+
|
|
3
|
+
module Rspec
|
|
4
|
+
module Generators
|
|
5
|
+
# @private
|
|
6
|
+
class AuthenticationGenerator < Base
|
|
7
|
+
def initialize(args, *options)
|
|
8
|
+
args.replace(['User'])
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def create_user_spec
|
|
13
|
+
template 'user_spec.rb', target_path('models', 'user_spec.rb')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
hook_for :fixture_replacement
|
|
17
|
+
|
|
18
|
+
def create_fixture_file
|
|
19
|
+
return if options[:fixture_replacement]
|
|
20
|
+
|
|
21
|
+
template 'users.yml', target_path('fixtures', 'users.yml')
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
|
2
|
+
|
|
3
|
+
<%% password_digest = BCrypt::Password.create("password") %>
|
|
4
|
+
|
|
5
|
+
one:
|
|
6
|
+
email_address: one@example.com
|
|
7
|
+
password_digest: <%%= password_digest %>
|
|
8
|
+
|
|
9
|
+
two:
|
|
10
|
+
email_address: two@example.com
|
|
11
|
+
password_digest: <%%= password_digest %>
|
|
@@ -28,7 +28,9 @@ require 'rspec/rails'
|
|
|
28
28
|
# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f }
|
|
29
29
|
|
|
30
30
|
<% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%>
|
|
31
|
-
#
|
|
31
|
+
# Ensures that the test database schema matches the current schema file.
|
|
32
|
+
# If there are pending migrations it will invoke `db:test:prepare` to
|
|
33
|
+
# recreate the test database by loading the schema.
|
|
32
34
|
# If you are not using ActiveRecord, you can remove these lines.
|
|
33
35
|
begin
|
|
34
36
|
ActiveRecord::Migration.maintain_test_schema!
|
|
@@ -39,13 +41,9 @@ end
|
|
|
39
41
|
RSpec.configure do |config|
|
|
40
42
|
<% if RSpec::Rails::FeatureCheck.has_active_record? -%>
|
|
41
43
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
42
|
-
<% if ::Rails::VERSION::STRING < "7.1.0" -%>
|
|
43
|
-
config.fixture_path = Rails.root.join('spec/fixtures')
|
|
44
|
-
<% else -%>
|
|
45
44
|
config.fixture_paths = [
|
|
46
45
|
Rails.root.join('spec/fixtures')
|
|
47
46
|
]
|
|
48
|
-
<% end -%>
|
|
49
47
|
|
|
50
48
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
51
49
|
# examples within a transaction, remove the following line or assign false
|
|
@@ -63,7 +61,9 @@ RSpec.configure do |config|
|
|
|
63
61
|
# note if you'd prefer not to run each example within a transaction, you
|
|
64
62
|
# should set use_transactional_fixtures to false.
|
|
65
63
|
#
|
|
66
|
-
# config.
|
|
64
|
+
# config.fixture_paths = [
|
|
65
|
+
# Rails.root.join('spec/fixtures')
|
|
66
|
+
# ]
|
|
67
67
|
# config.use_transactional_fixtures = true
|
|
68
68
|
|
|
69
69
|
<% end -%>
|
|
@@ -75,9 +75,9 @@ RSpec.configure do |config|
|
|
|
75
75
|
# end
|
|
76
76
|
#
|
|
77
77
|
# The different available types are documented in the features, such as in
|
|
78
|
-
# https://rspec.info/features/
|
|
78
|
+
# https://rspec.info/features/8-0/rspec-rails
|
|
79
79
|
#
|
|
80
|
-
# You can also
|
|
80
|
+
# You can also infer these behaviours automatically by location, e.g.
|
|
81
81
|
# /spec/models would pull in the same behaviour as `type: :model` but this
|
|
82
82
|
# behaviour is considered legacy and will be removed in a future version.
|
|
83
83
|
#
|
|
@@ -79,7 +79,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
|
79
79
|
context "with invalid params" do
|
|
80
80
|
it "renders a JSON response with errors for the new <%= singular_table_name %>" do
|
|
81
81
|
post :create, params: {<%= singular_table_name %>: invalid_attributes}, session: valid_session
|
|
82
|
-
expect(response).to have_http_status(
|
|
82
|
+
expect(response).to have_http_status(<%= Rack::Utils::SYMBOL_TO_STATUS_CODE.key(422).inspect %>)
|
|
83
83
|
expect(response.content_type).to eq('application/json')
|
|
84
84
|
end
|
|
85
85
|
end
|
|
@@ -110,7 +110,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
|
110
110
|
it "renders a JSON response with errors for the <%= singular_table_name %>" do
|
|
111
111
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
|
112
112
|
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: invalid_attributes}, session: valid_session
|
|
113
|
-
expect(response).to have_http_status(
|
|
113
|
+
expect(response).to have_http_status(<%= Rack::Utils::SYMBOL_TO_STATUS_CODE.key(422).inspect %>)
|
|
114
114
|
expect(response.content_type).to eq('application/json')
|
|
115
115
|
end
|
|
116
116
|
end
|
|
@@ -79,7 +79,7 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
|
|
|
79
79
|
it "renders a JSON response with errors for the new <%= singular_table_name %>" do
|
|
80
80
|
post <%= index_helper %>_url,
|
|
81
81
|
params: { <%= singular_table_name %>: invalid_attributes }, headers: valid_headers, as: :json
|
|
82
|
-
expect(response).to have_http_status(
|
|
82
|
+
expect(response).to have_http_status(<%= Rack::Utils::SYMBOL_TO_STATUS_CODE.key(422).inspect %>)
|
|
83
83
|
expect(response.content_type).to match(a_string_including("application/json"))
|
|
84
84
|
end
|
|
85
85
|
end
|
|
@@ -113,7 +113,7 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
|
|
|
113
113
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
|
114
114
|
patch <%= show_helper %>,
|
|
115
115
|
params: { <%= singular_table_name %>: invalid_attributes }, headers: valid_headers, as: :json
|
|
116
|
-
expect(response).to have_http_status(
|
|
116
|
+
expect(response).to have_http_status(<%= Rack::Utils::SYMBOL_TO_STATUS_CODE.key(422).inspect %>)
|
|
117
117
|
expect(response.content_type).to match(a_string_including("application/json"))
|
|
118
118
|
end
|
|
119
119
|
end
|
|
@@ -92,7 +92,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
|
92
92
|
context "with invalid params" do
|
|
93
93
|
it "renders a response with 422 status (i.e. to display the 'new' template)" do
|
|
94
94
|
post :create, params: {<%= singular_table_name %>: invalid_attributes}, session: valid_session
|
|
95
|
-
expect(response).to have_http_status(
|
|
95
|
+
expect(response).to have_http_status(<%= Rack::Utils::SYMBOL_TO_STATUS_CODE.key(422).inspect %>)
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
end
|
|
@@ -121,7 +121,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
|
121
121
|
it "renders a response with 422 status (i.e. to display the 'edit' template)" do
|
|
122
122
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
|
123
123
|
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: invalid_attributes}, session: valid_session
|
|
124
|
-
expect(response).to have_http_status(
|
|
124
|
+
expect(response).to have_http_status(<%= Rack::Utils::SYMBOL_TO_STATUS_CODE.key(422).inspect %>)
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
127
|
end
|
|
@@ -18,7 +18,11 @@ RSpec.describe "<%= ns_table_name %>/index", <%= type_metatag(:view) %> do
|
|
|
18
18
|
|
|
19
19
|
it "renders a list of <%= ns_table_name %>" do
|
|
20
20
|
render
|
|
21
|
+
<% if Rails.version.to_f < 8.1 -%>
|
|
21
22
|
cell_selector = 'div>p'
|
|
23
|
+
<% else -%>
|
|
24
|
+
cell_selector = 'div>div>div'
|
|
25
|
+
<% end -%>
|
|
22
26
|
<% for attribute in output_attributes -%>
|
|
23
27
|
assert_select cell_selector, text: Regexp.new(<%= value_for(attribute) %>.to_s), count: 2
|
|
24
28
|
<% end -%>
|
|
@@ -85,7 +85,7 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
|
|
|
85
85
|
|
|
86
86
|
it "renders a response with 422 status (i.e. to display the 'new' template)" do
|
|
87
87
|
post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
|
|
88
|
-
expect(response).to have_http_status(
|
|
88
|
+
expect(response).to have_http_status(<%= Rack::Utils::SYMBOL_TO_STATUS_CODE.key(422).inspect %>)
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
end
|
|
@@ -115,7 +115,7 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
|
|
|
115
115
|
it "renders a response with 422 status (i.e. to display the 'edit' template)" do
|
|
116
116
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
|
117
117
|
patch <%= show_helper %>, params: { <%= singular_table_name %>: invalid_attributes }
|
|
118
|
-
expect(response).to have_http_status(
|
|
118
|
+
expect(response).to have_http_status(<%= Rack::Utils::SYMBOL_TO_STATUS_CODE.key(422).inspect %>)
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
end
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# rubocop: disable Metrics/ModuleLength
|
|
2
1
|
module RSpec
|
|
3
2
|
module Rails
|
|
4
3
|
# Fake class to document RSpec Rails configuration options. In practice,
|
|
@@ -57,7 +56,7 @@ module RSpec
|
|
|
57
56
|
end
|
|
58
57
|
|
|
59
58
|
# @private
|
|
60
|
-
def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength
|
|
59
|
+
def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength
|
|
61
60
|
config.backtrace_exclusion_patterns << /vendor\//
|
|
62
61
|
config.backtrace_exclusion_patterns << %r{lib/rspec/rails}
|
|
63
62
|
|
|
@@ -69,12 +68,7 @@ module RSpec
|
|
|
69
68
|
config.add_setting :use_transactional_fixtures, alias_with: :use_transactional_examples
|
|
70
69
|
config.add_setting :use_instantiated_fixtures
|
|
71
70
|
config.add_setting :global_fixtures
|
|
72
|
-
|
|
73
|
-
if ::Rails::VERSION::STRING < "7.1.0"
|
|
74
|
-
config.add_setting :fixture_path
|
|
75
|
-
else
|
|
76
|
-
config.add_setting :fixture_paths
|
|
77
|
-
end
|
|
71
|
+
config.add_setting :fixture_paths
|
|
78
72
|
|
|
79
73
|
config.include RSpec::Rails::FixtureSupport, :use_fixtures
|
|
80
74
|
|
|
@@ -90,7 +84,7 @@ module RSpec
|
|
|
90
84
|
config.add_setting :file_fixture_path, default: 'spec/fixtures/files'
|
|
91
85
|
config.include RSpec::Rails::FileFixtureSupport
|
|
92
86
|
|
|
93
|
-
# Add support for
|
|
87
|
+
# Add support for fixture_paths on fixture_file_upload
|
|
94
88
|
config.include RSpec::Rails::FixtureFileUploadSupport
|
|
95
89
|
|
|
96
90
|
# This allows us to expose `render_views` as a config option even though it
|
|
@@ -114,40 +108,6 @@ module RSpec
|
|
|
114
108
|
rendering_views?
|
|
115
109
|
end
|
|
116
110
|
|
|
117
|
-
undef :rendering_views? if respond_to?(:rendering_views?)
|
|
118
|
-
def rendering_views?
|
|
119
|
-
!!rendering_views
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
# Define boolean predicates rather than relying on rspec-core due
|
|
123
|
-
# to the bug fix in rspec/rspec-core#2736, note some of these
|
|
124
|
-
# predicates are a bit nonsensical, but they exist for backwards
|
|
125
|
-
# compatibility, we can tidy these up in `rspec-rails` 5.
|
|
126
|
-
undef :fixture_path? if respond_to?(:fixture_path?)
|
|
127
|
-
def fixture_path?
|
|
128
|
-
!!fixture_path
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
undef :global_fixtures? if respond_to?(:global_fixtures?)
|
|
132
|
-
def global_fixtures?
|
|
133
|
-
!!global_fixtures
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
undef :infer_base_class_for_anonymous_controllers? if respond_to?(:infer_base_class_for_anonymous_controllers?)
|
|
137
|
-
def infer_base_class_for_anonymous_controllers?
|
|
138
|
-
!!infer_base_class_for_anonymous_controllers
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
undef :use_instantiated_fixtures? if respond_to?(:use_instantiated_fixtures?)
|
|
142
|
-
def use_instantiated_fixtures?
|
|
143
|
-
!!use_instantiated_fixtures
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
undef :use_transactional_fixtures? if respond_to?(:use_transactional_fixtures?)
|
|
147
|
-
def use_transactional_fixtures?
|
|
148
|
-
!!use_transactional_fixtures
|
|
149
|
-
end
|
|
150
|
-
|
|
151
111
|
def infer_spec_type_from_file_location!
|
|
152
112
|
DIRECTORY_MAPPINGS.each do |type, dir_parts|
|
|
153
113
|
escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]')
|
|
@@ -163,29 +123,6 @@ module RSpec
|
|
|
163
123
|
filter_gems_from_backtrace "activemodel", "activerecord",
|
|
164
124
|
"activesupport", "activejob"
|
|
165
125
|
end
|
|
166
|
-
|
|
167
|
-
# @deprecated TestFixtures#fixture_path is deprecated and will be removed in Rails 7.2
|
|
168
|
-
if ::Rails::VERSION::STRING >= "7.1.0"
|
|
169
|
-
def fixture_path
|
|
170
|
-
RSpec.deprecate(
|
|
171
|
-
"config.fixture_path",
|
|
172
|
-
replacement: "config.fixture_paths",
|
|
173
|
-
message: "Rails 7.1 has deprecated the singular fixture_path in favour of an array." \
|
|
174
|
-
"You should migrate to plural:"
|
|
175
|
-
)
|
|
176
|
-
fixture_paths&.first
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
def fixture_path=(path)
|
|
180
|
-
RSpec.deprecate(
|
|
181
|
-
"config.fixture_path = #{path.inspect}",
|
|
182
|
-
replacement: "config.fixture_paths = [#{path.inspect}]",
|
|
183
|
-
message: "Rails 7.1 has deprecated the singular fixture_path in favour of an array." \
|
|
184
|
-
"You should migrate to plural:"
|
|
185
|
-
)
|
|
186
|
-
self.fixture_paths = Array(path)
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
126
|
end
|
|
190
127
|
|
|
191
128
|
add_test_type_configurations(config)
|
|
@@ -219,4 +156,3 @@ module RSpec
|
|
|
219
156
|
initialize_configuration RSpec.configuration
|
|
220
157
|
end
|
|
221
158
|
end
|
|
222
|
-
# rubocop: enable Metrics/ModuleLength
|
|
@@ -9,6 +9,9 @@ module RSpec
|
|
|
9
9
|
# Default host to be used in Rails route helpers if none is specified.
|
|
10
10
|
DEFAULT_HOST = "www.example.com"
|
|
11
11
|
|
|
12
|
+
# Default url options, merged into those of the example group.
|
|
13
|
+
DEFAULT_OPTIONS = { host: DEFAULT_HOST }.freeze
|
|
14
|
+
|
|
12
15
|
included do
|
|
13
16
|
app = ::Rails.application
|
|
14
17
|
if app.respond_to?(:routes)
|
|
@@ -16,7 +19,7 @@ module RSpec
|
|
|
16
19
|
include app.routes.mounted_helpers if app.routes.respond_to?(:mounted_helpers)
|
|
17
20
|
|
|
18
21
|
if respond_to?(:default_url_options)
|
|
19
|
-
default_url_options
|
|
22
|
+
self.default_url_options = DEFAULT_OPTIONS.merge(default_url_options)
|
|
20
23
|
end
|
|
21
24
|
end
|
|
22
25
|
end
|
|
@@ -21,8 +21,8 @@ if defined?(ActionMailer)
|
|
|
21
21
|
|
|
22
22
|
included do
|
|
23
23
|
include ::Rails.application.routes.url_helpers
|
|
24
|
-
options = ::Rails.configuration.action_mailer.default_url_options
|
|
25
|
-
|
|
24
|
+
options = ::Rails.configuration.action_mailer.default_url_options
|
|
25
|
+
self.default_url_options = default_url_options.merge(options) if options.present?
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# Class-level DSL for mailer specs.
|
|
@@ -18,6 +18,10 @@ module RSpec
|
|
|
18
18
|
include RSpec::Rails::TaggedLoggingAdapter
|
|
19
19
|
include ActiveSupport::CurrentAttributes::TestHelper
|
|
20
20
|
include ActiveSupport::ExecutionContext::TestHelper
|
|
21
|
+
|
|
22
|
+
if RSpec::Rails::FeatureCheck.has_active_job?
|
|
23
|
+
include ActiveJob::TestHelper
|
|
24
|
+
end
|
|
21
25
|
end
|
|
22
26
|
end
|
|
23
27
|
end
|
|
@@ -44,64 +44,57 @@ module RSpec
|
|
|
44
44
|
].join("_").tr(CHARS_TO_TRANSLATE.join, "_").byteslice(0...200).scrub("") + "_#{rand(1000)}"
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def [](key)
|
|
56
|
-
if @example_data.key?(key)
|
|
57
|
-
@example_data[key]
|
|
58
|
-
else
|
|
59
|
-
raise_wrong_scope_error
|
|
60
|
-
end
|
|
61
|
-
end
|
|
47
|
+
# @private
|
|
48
|
+
# Allows failure screenshot to work whilst not exposing metadata
|
|
49
|
+
class SuppressRailsScreenshotMetadata
|
|
50
|
+
def initialize
|
|
51
|
+
@example_data = {}
|
|
52
|
+
end
|
|
62
53
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
end
|
|
54
|
+
def [](key)
|
|
55
|
+
if @example_data.key?(key)
|
|
56
|
+
@example_data[key]
|
|
57
|
+
else
|
|
58
|
+
raise_wrong_scope_error
|
|
69
59
|
end
|
|
60
|
+
end
|
|
70
61
|
|
|
71
|
-
|
|
62
|
+
def []=(key, value)
|
|
63
|
+
if key == :failure_screenshot_path
|
|
64
|
+
@example_data[key] = value
|
|
65
|
+
else
|
|
72
66
|
raise_wrong_scope_error
|
|
73
67
|
end
|
|
68
|
+
end
|
|
74
69
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def raise_wrong_scope_error
|
|
78
|
-
raise RSpec::Core::ExampleGroup::WrongScopeError,
|
|
79
|
-
"`metadata` is not available from within an example " \
|
|
80
|
-
"(e.g. an `it` block) or from constructs that run in the " \
|
|
81
|
-
"scope of an example (e.g. `before`, `let`, etc). It is " \
|
|
82
|
-
"only available on an example group (e.g. a `describe` or "\
|
|
83
|
-
"`context` block)"
|
|
84
|
-
end
|
|
70
|
+
def method_missing(_name, *_args, &_block)
|
|
71
|
+
raise_wrong_scope_error
|
|
85
72
|
end
|
|
86
73
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
def raise_wrong_scope_error
|
|
77
|
+
raise RSpec::Core::ExampleGroup::WrongScopeError,
|
|
78
|
+
"`metadata` is not available from within an example " \
|
|
79
|
+
"(e.g. an `it` block) or from constructs that run in the " \
|
|
80
|
+
"scope of an example (e.g. `before`, `let`, etc). It is " \
|
|
81
|
+
"only available on an example group (e.g. a `describe` or "\
|
|
82
|
+
"`context` block)"
|
|
90
83
|
end
|
|
91
84
|
end
|
|
92
85
|
|
|
86
|
+
# @private
|
|
87
|
+
def metadata
|
|
88
|
+
@metadata ||= SuppressRailsScreenshotMetadata.new
|
|
89
|
+
end
|
|
90
|
+
|
|
93
91
|
# Delegates to `Rails.application`.
|
|
94
92
|
def app
|
|
95
93
|
::Rails.application
|
|
96
94
|
end
|
|
97
95
|
|
|
98
96
|
# Default driver to assign if none specified.
|
|
99
|
-
DEFAULT_DRIVER =
|
|
100
|
-
if ::Rails::VERSION::STRING.to_f >= 7.2
|
|
101
|
-
:selenium_chrome_headless
|
|
102
|
-
else
|
|
103
|
-
:selenium
|
|
104
|
-
end
|
|
97
|
+
DEFAULT_DRIVER = :selenium_chrome_headless
|
|
105
98
|
|
|
106
99
|
included do |other|
|
|
107
100
|
ActiveSupport.on_load(:action_dispatch_system_test_case) do
|
|
@@ -153,6 +146,10 @@ module RSpec
|
|
|
153
146
|
@driver = ::ActionDispatch::SystemTestCase.driven_by(driver, **driver_options, &blk).tap(&:use)
|
|
154
147
|
end
|
|
155
148
|
|
|
149
|
+
def served_by(**options)
|
|
150
|
+
::ActionDispatch::SystemTestCase.served_by(**options)
|
|
151
|
+
end
|
|
152
|
+
|
|
156
153
|
before do
|
|
157
154
|
@routes = ::Rails.application.routes
|
|
158
155
|
end
|
|
@@ -186,7 +186,7 @@ module RSpec
|
|
|
186
186
|
|
|
187
187
|
before do
|
|
188
188
|
_include_controller_helpers
|
|
189
|
-
view.lookup_context.prefixes
|
|
189
|
+
view.lookup_context.prefixes = [_controller_path] + view.lookup_context.prefixes
|
|
190
190
|
|
|
191
191
|
controller.controller_path = _controller_path
|
|
192
192
|
|
|
@@ -14,10 +14,8 @@ module RSpec
|
|
|
14
14
|
resolved_fixture_path =
|
|
15
15
|
if respond_to?(:file_fixture_path) && !file_fixture_path.nil?
|
|
16
16
|
file_fixture_path.to_s
|
|
17
|
-
elsif respond_to?(:fixture_paths)
|
|
18
|
-
(RSpec.configuration.fixture_paths&.first || '').to_s
|
|
19
17
|
else
|
|
20
|
-
(RSpec.configuration.
|
|
18
|
+
(RSpec.configuration.fixture_paths&.first || '').to_s
|
|
21
19
|
end
|
|
22
20
|
RailsFixtureFileWrapper.file_fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
|
|
23
21
|
RailsFixtureFileWrapper.instance
|
|
@@ -28,11 +26,7 @@ module RSpec
|
|
|
28
26
|
include ActiveSupport::Testing::FileFixtures
|
|
29
27
|
|
|
30
28
|
class << self
|
|
31
|
-
|
|
32
|
-
attr_accessor :fixture_path
|
|
33
|
-
else
|
|
34
|
-
attr_accessor :fixture_paths
|
|
35
|
-
end
|
|
29
|
+
attr_accessor :fixture_paths
|
|
36
30
|
|
|
37
31
|
# Get instance of wrapper
|
|
38
32
|
def instance
|
|
@@ -20,12 +20,7 @@ module RSpec
|
|
|
20
20
|
if RSpec.configuration.use_active_record?
|
|
21
21
|
include Fixtures
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
if respond_to?(:fixture_paths=)
|
|
25
|
-
self.fixture_paths = RSpec.configuration.fixture_paths
|
|
26
|
-
else
|
|
27
|
-
self.fixture_path = RSpec.configuration.fixture_path
|
|
28
|
-
end
|
|
23
|
+
self.fixture_paths = RSpec.configuration.fixture_paths
|
|
29
24
|
|
|
30
25
|
self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
|
|
31
26
|
self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures
|
|
@@ -37,50 +32,25 @@ module RSpec
|
|
|
37
32
|
module Fixtures
|
|
38
33
|
extend ActiveSupport::Concern
|
|
39
34
|
|
|
40
|
-
# rubocop:disable Metrics/BlockLength
|
|
41
35
|
class_methods do
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)
|
|
52
|
-
define_method(method_name) do |*args, **kwargs, &blk|
|
|
53
|
-
if RSpec.current_scope == :before_context_hook
|
|
54
|
-
RSpec.warn_with("Calling fixture method in before :context ")
|
|
55
|
-
else
|
|
56
|
-
access_fixture(fixture_name, *args, **kwargs, &blk)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
else
|
|
61
|
-
def fixtures(*args)
|
|
62
|
-
orig_methods = private_instance_methods
|
|
63
|
-
super.tap do
|
|
64
|
-
new_methods = private_instance_methods - orig_methods
|
|
65
|
-
new_methods.each do |method_name|
|
|
66
|
-
proxy_method_warning_if_called_in_before_context_scope(method_name)
|
|
67
|
-
end
|
|
36
|
+
def fixtures(*args)
|
|
37
|
+
super.tap do
|
|
38
|
+
fixture_sets.each_pair do |method_name, fixture_name|
|
|
39
|
+
proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)
|
|
68
40
|
end
|
|
69
41
|
end
|
|
42
|
+
end
|
|
70
43
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
orig_implementation.bind(self).call(*args, &blk)
|
|
78
|
-
end
|
|
44
|
+
def proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)
|
|
45
|
+
define_method(method_name) do |*args, **kwargs, &blk|
|
|
46
|
+
if RSpec.current_scope == :before_context_hook
|
|
47
|
+
RSpec.warn_with("Calling fixture method in before :context ")
|
|
48
|
+
else
|
|
49
|
+
access_fixture(fixture_name, *args, **kwargs, &blk)
|
|
79
50
|
end
|
|
80
51
|
end
|
|
81
52
|
end
|
|
82
53
|
end
|
|
83
|
-
# rubocop:enable Metrics/BlockLength
|
|
84
54
|
end
|
|
85
55
|
end
|
|
86
56
|
end
|
|
@@ -320,6 +320,10 @@ module RSpec
|
|
|
320
320
|
|
|
321
321
|
!matches?(proc)
|
|
322
322
|
end
|
|
323
|
+
|
|
324
|
+
def supports_block_expectations?
|
|
325
|
+
false
|
|
326
|
+
end
|
|
323
327
|
end
|
|
324
328
|
|
|
325
329
|
# @private
|
|
@@ -352,6 +356,10 @@ module RSpec
|
|
|
352
356
|
@job = job
|
|
353
357
|
check(queue_adapter.performed_jobs)
|
|
354
358
|
end
|
|
359
|
+
|
|
360
|
+
def supports_block_expectations?
|
|
361
|
+
false
|
|
362
|
+
end
|
|
355
363
|
end
|
|
356
364
|
end
|
|
357
365
|
|
|
@@ -142,7 +142,7 @@ module RSpec
|
|
|
142
142
|
job_args = deserialize_arguments(job)
|
|
143
143
|
|
|
144
144
|
mailer_method = job_args[0..1].join('.')
|
|
145
|
-
mailer_args = job_args[3
|
|
145
|
+
mailer_args = job_args[3..]
|
|
146
146
|
|
|
147
147
|
msg_parts = []
|
|
148
148
|
msg_parts << "with #{mailer_args}" if mailer_args.any?
|
|
@@ -167,7 +167,7 @@ module RSpec
|
|
|
167
167
|
original_hash = keywords.each_with_object({}) { |keyword, new_hash| new_hash[keyword.to_sym] = hash[keyword] }
|
|
168
168
|
|
|
169
169
|
args + [original_hash]
|
|
170
|
-
elsif hash.key?(:args) && hash.
|
|
170
|
+
elsif hash.key?(:args) && !hash[:params].nil?
|
|
171
171
|
args + [hash]
|
|
172
172
|
elsif hash.key?(:args)
|
|
173
173
|
args + hash[:args]
|
|
@@ -181,7 +181,7 @@ module RSpec
|
|
|
181
181
|
mailer_args = args - base_mailer_args
|
|
182
182
|
|
|
183
183
|
if parameterized_mail?(job)
|
|
184
|
-
mailer_args = mailer_args[1
|
|
184
|
+
mailer_args = mailer_args[1..] # ignore parameterized params
|
|
185
185
|
elsif mailer_args.last.is_a?(Hash) && mailer_args.last.key?(:args)
|
|
186
186
|
mailer_args = args.last[:args]
|
|
187
187
|
end
|
data/lib/rspec/rails/version.rb
CHANGED
|
@@ -86,29 +86,30 @@ module RSpec
|
|
|
86
86
|
|
|
87
87
|
def method_missing(name, *args, &block)
|
|
88
88
|
result = @resolver.send(name, *args, &block)
|
|
89
|
-
|
|
89
|
+
|
|
90
|
+
if result.is_a?(Enumerable) && result.all? { |element| element.is_a?(::ActionView::Template) }
|
|
91
|
+
nullify_templates(result)
|
|
92
|
+
elsif result.is_a?(::ActionView::Template)
|
|
93
|
+
nullify_templates([result]).first
|
|
94
|
+
else
|
|
95
|
+
result
|
|
96
|
+
end
|
|
90
97
|
end
|
|
91
98
|
|
|
92
99
|
private
|
|
93
100
|
|
|
94
101
|
def nullify_templates(collection)
|
|
95
|
-
return collection unless collection.is_a?(Enumerable)
|
|
96
|
-
return collection unless collection.all? { |element| element.is_a?(::ActionView::Template) }
|
|
97
|
-
|
|
98
102
|
EmptyTemplateResolver.nullify_template_rendering(collection)
|
|
99
103
|
end
|
|
100
104
|
end
|
|
101
105
|
|
|
102
|
-
#
|
|
103
|
-
#
|
|
106
|
+
# Looks templates up on the file system and then returns them with
|
|
107
|
+
# modified source
|
|
104
108
|
#
|
|
105
109
|
# @private
|
|
106
110
|
class FileSystemResolver < ::ActionView::FileSystemResolver
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def find_templates(*args)
|
|
110
|
-
templates = super
|
|
111
|
-
EmptyTemplateResolver.nullify_template_rendering(templates)
|
|
111
|
+
def find_all(*_args)
|
|
112
|
+
EmptyTemplateResolver.nullify_template_rendering(super)
|
|
112
113
|
end
|
|
113
114
|
end
|
|
114
115
|
end
|
data/lib/rspec-rails.rb
CHANGED
|
@@ -12,17 +12,19 @@ module RSpec
|
|
|
12
12
|
|
|
13
13
|
# As of Rails 8.0.0 you can register directories to work with `rails stats`
|
|
14
14
|
if ::Rails::VERSION::STRING >= "8.0.0"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
initializer "rspec_rails.code_statistics" do
|
|
16
|
+
require 'rails/code_statistics'
|
|
17
|
+
|
|
18
|
+
root = ::Rails.root
|
|
19
|
+
dirs = Dir[root.join('spec', '**', '*_spec.rb').to_s]
|
|
20
|
+
.map { |f| f.sub(%r{^#{Regexp.escape(root.to_s)}/(spec/\w+)/.*}, '\\1') }
|
|
21
|
+
.uniq
|
|
22
|
+
.select { |f| File.directory?(root.join(f)) }
|
|
23
|
+
|
|
24
|
+
Hash[dirs.map { |d| [d.split('/').last, d] }].each do |type, dir|
|
|
25
|
+
name = type.singularize.capitalize
|
|
26
|
+
::Rails::CodeStatistics.register_directory "#{name} specs", root.join(dir).to_s, test_directory: true
|
|
27
|
+
end
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
|
|
@@ -64,18 +66,10 @@ module RSpec
|
|
|
64
66
|
end
|
|
65
67
|
end
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return unless options.preview_paths.empty?
|
|
69
|
+
def config_default_preview_path(options)
|
|
70
|
+
return unless options.preview_paths.empty?
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
else
|
|
74
|
-
def config_default_preview_path(options)
|
|
75
|
-
return unless options.preview_path.blank?
|
|
76
|
-
|
|
77
|
-
options.preview_path = "#{::Rails.root}/spec/mailers/previews"
|
|
78
|
-
end
|
|
72
|
+
options.preview_paths << "#{::Rails.root}/spec/mailers/previews"
|
|
79
73
|
end
|
|
80
74
|
|
|
81
75
|
def supports_action_mailer_previews?(config)
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 8.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Chelimsky
|
|
@@ -10,11 +10,11 @@ bindir: bin
|
|
|
10
10
|
cert_chain:
|
|
11
11
|
- |
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
|
13
|
-
|
|
13
|
+
MIIFvjCCA6agAwIBAgIJAPXjfUbCjdXWMA0GCSqGSIb3DQEBCwUAMIGAMQswCQYD
|
|
14
14
|
VQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEO
|
|
15
15
|
MAwGA1UECgwFUlNwZWMxEzARBgNVBAMMCnJzcGVjLmluZm8xJTAjBgkqhkiG9w0B
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
CQEWFnJzcGVjQGdvb2dsZWdyb3Vwcy5jb20wHhcNMjYwMjE3MTE0ODM0WhcNMjcw
|
|
17
|
+
MjE3MTE0ODM0WjCBgDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24x
|
|
18
18
|
EDAOBgNVBAcMB1NlYXR0bGUxDjAMBgNVBAoMBVJTcGVjMRMwEQYDVQQDDApyc3Bl
|
|
19
19
|
Yy5pbmZvMSUwIwYJKoZIhvcNAQkBFhZyc3BlY0Bnb29nbGVncm91cHMuY29tMIIC
|
|
20
20
|
IjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsSmjgcHaKlD0jizRJowi2bGI
|
|
@@ -30,19 +30,19 @@ cert_chain:
|
|
|
30
30
|
gpEMqf80lEmhX59VUsm0Pv6OEo+ZPHBvXPiJA6DShQh9t3YtpwyA8uVDMbT/i32u
|
|
31
31
|
2FUsqZbbJcCmkBrGposCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
|
32
32
|
HQYDVR0OBBYEFPPvQ5XT0Nvuhi6k+hrWVv35J+TeMA0GCSqGSIb3DQEBCwUAA4IC
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
AQBaeeGIZtBFDP33D1/4sXldSgwntVcL5qC5pcjamLWM4HK4/a6ePMy1uoX+dEnJ
|
|
34
|
+
J+BjZWURsUfFOob+xnUe8AMSbv9gupckfVehZoBzOvJDaWcALo8GKjJlmVtzEIqZ
|
|
35
|
+
TvBLO5zQwR4cWIrg0NWjkDOSQOrNNQ2Degv/aOFrR8dFPJSgxZG/IC0/t6s72cEt
|
|
36
|
+
V4SIe/NLIU4RyBzfgn/RBsalDEF1yIVlDWspMa78clS3bPmntkNyfLwIUwINDHhn
|
|
37
|
+
swFA8bEKMQWqRlupuRmEiy3nGe6az46YlPXzK5UWfXJ6Lb1wIE8W80TRx0HpSC7j
|
|
38
|
+
JfXPfQ0PLgiU4nnQqain2bIn96Ooco8kspeqp8rSJ8sbaMPTNmcFuwD3gzWsRnJ3
|
|
39
|
+
rIaJbmrUcq6DlJ7jfv3u5TPt4JWzDP7oDPf3nXNiF2Cn48Ne598G5lHH6Heyxe39
|
|
40
|
+
pYZdhEptKJWPHxbJWHXD02omKprkNuQKHpnXrW+mmbiO4IcqAMggiud+DaEQg20x
|
|
41
|
+
Dae4cNbvK5p3D+5xqvcEO2G4uCMDmJjrSd61kvTLBnm1qroHqrpi9GauEVWZZmD0
|
|
42
|
+
n0ph8oFAXOsKQWxZ+4uh6yGISk+WhngCZEVPZUjq7SIGAuVhQy2ZgwdjnLEz//lD
|
|
43
|
+
x0Qexp5yGeoxAL9qKM/RXYKtuRZBJV1z+L9A1YOtwaXXNg==
|
|
44
44
|
-----END CERTIFICATE-----
|
|
45
|
-
date:
|
|
45
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
46
46
|
dependencies:
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: actionpack
|
|
@@ -50,98 +50,122 @@ dependencies:
|
|
|
50
50
|
requirements:
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '7.
|
|
53
|
+
version: '7.2'
|
|
54
54
|
type: :runtime
|
|
55
55
|
prerelease: false
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - ">="
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '7.
|
|
60
|
+
version: '7.2'
|
|
61
61
|
- !ruby/object:Gem::Dependency
|
|
62
62
|
name: activesupport
|
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - ">="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '7.
|
|
67
|
+
version: '7.2'
|
|
68
68
|
type: :runtime
|
|
69
69
|
prerelease: false
|
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
72
|
- - ">="
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '7.
|
|
74
|
+
version: '7.2'
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
76
|
name: railties
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
79
|
- - ">="
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '7.
|
|
81
|
+
version: '7.2'
|
|
82
82
|
type: :runtime
|
|
83
83
|
prerelease: false
|
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
|
86
86
|
- - ">="
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '7.
|
|
88
|
+
version: '7.2'
|
|
89
89
|
- !ruby/object:Gem::Dependency
|
|
90
90
|
name: rspec-core
|
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
|
-
- - "
|
|
93
|
+
- - ">="
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version:
|
|
95
|
+
version: 3.13.0
|
|
96
|
+
- - "<"
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: 5.0.0
|
|
96
99
|
type: :runtime
|
|
97
100
|
prerelease: false
|
|
98
101
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
102
|
requirements:
|
|
100
|
-
- - "
|
|
103
|
+
- - ">="
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: 3.13.0
|
|
106
|
+
- - "<"
|
|
101
107
|
- !ruby/object:Gem::Version
|
|
102
|
-
version:
|
|
108
|
+
version: 5.0.0
|
|
103
109
|
- !ruby/object:Gem::Dependency
|
|
104
110
|
name: rspec-expectations
|
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
|
106
112
|
requirements:
|
|
107
|
-
- - "
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: 3.13.0
|
|
116
|
+
- - "<"
|
|
108
117
|
- !ruby/object:Gem::Version
|
|
109
|
-
version:
|
|
118
|
+
version: 5.0.0
|
|
110
119
|
type: :runtime
|
|
111
120
|
prerelease: false
|
|
112
121
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
122
|
requirements:
|
|
114
|
-
- - "
|
|
123
|
+
- - ">="
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: 3.13.0
|
|
126
|
+
- - "<"
|
|
115
127
|
- !ruby/object:Gem::Version
|
|
116
|
-
version:
|
|
128
|
+
version: 5.0.0
|
|
117
129
|
- !ruby/object:Gem::Dependency
|
|
118
130
|
name: rspec-mocks
|
|
119
131
|
requirement: !ruby/object:Gem::Requirement
|
|
120
132
|
requirements:
|
|
121
|
-
- - "
|
|
133
|
+
- - ">="
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
version: 3.13.0
|
|
136
|
+
- - "<"
|
|
122
137
|
- !ruby/object:Gem::Version
|
|
123
|
-
version:
|
|
138
|
+
version: 5.0.0
|
|
124
139
|
type: :runtime
|
|
125
140
|
prerelease: false
|
|
126
141
|
version_requirements: !ruby/object:Gem::Requirement
|
|
127
142
|
requirements:
|
|
128
|
-
- - "
|
|
143
|
+
- - ">="
|
|
129
144
|
- !ruby/object:Gem::Version
|
|
130
|
-
version:
|
|
145
|
+
version: 3.13.0
|
|
146
|
+
- - "<"
|
|
147
|
+
- !ruby/object:Gem::Version
|
|
148
|
+
version: 5.0.0
|
|
131
149
|
- !ruby/object:Gem::Dependency
|
|
132
150
|
name: rspec-support
|
|
133
151
|
requirement: !ruby/object:Gem::Requirement
|
|
134
152
|
requirements:
|
|
135
|
-
- - "
|
|
153
|
+
- - ">="
|
|
136
154
|
- !ruby/object:Gem::Version
|
|
137
|
-
version:
|
|
155
|
+
version: 3.13.0
|
|
156
|
+
- - "<"
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: 5.0.0
|
|
138
159
|
type: :runtime
|
|
139
160
|
prerelease: false
|
|
140
161
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
162
|
requirements:
|
|
142
|
-
- - "
|
|
163
|
+
- - ">="
|
|
143
164
|
- !ruby/object:Gem::Version
|
|
144
|
-
version:
|
|
165
|
+
version: 3.13.0
|
|
166
|
+
- - "<"
|
|
167
|
+
- !ruby/object:Gem::Version
|
|
168
|
+
version: 5.0.0
|
|
145
169
|
- !ruby/object:Gem::Dependency
|
|
146
170
|
name: ammeter
|
|
147
171
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -162,28 +186,28 @@ dependencies:
|
|
|
162
186
|
requirements:
|
|
163
187
|
- - "~>"
|
|
164
188
|
- !ruby/object:Gem::Version
|
|
165
|
-
version:
|
|
189
|
+
version: 2.3.1
|
|
166
190
|
type: :development
|
|
167
191
|
prerelease: false
|
|
168
192
|
version_requirements: !ruby/object:Gem::Requirement
|
|
169
193
|
requirements:
|
|
170
194
|
- - "~>"
|
|
171
195
|
- !ruby/object:Gem::Version
|
|
172
|
-
version:
|
|
196
|
+
version: 2.3.1
|
|
173
197
|
- !ruby/object:Gem::Dependency
|
|
174
198
|
name: cucumber
|
|
175
199
|
requirement: !ruby/object:Gem::Requirement
|
|
176
200
|
requirements:
|
|
177
|
-
- - "
|
|
201
|
+
- - ">="
|
|
178
202
|
- !ruby/object:Gem::Version
|
|
179
|
-
version: '
|
|
203
|
+
version: '10.0'
|
|
180
204
|
type: :development
|
|
181
205
|
prerelease: false
|
|
182
206
|
version_requirements: !ruby/object:Gem::Requirement
|
|
183
207
|
requirements:
|
|
184
|
-
- - "
|
|
208
|
+
- - ">="
|
|
185
209
|
- !ruby/object:Gem::Version
|
|
186
|
-
version: '
|
|
210
|
+
version: '10.0'
|
|
187
211
|
description: rspec-rails integrates the Rails testing helpers into RSpec.
|
|
188
212
|
email: rspec@googlegroups.com
|
|
189
213
|
executables: []
|
|
@@ -197,6 +221,9 @@ files:
|
|
|
197
221
|
- LICENSE.md
|
|
198
222
|
- README.md
|
|
199
223
|
- lib/generators/rspec.rb
|
|
224
|
+
- lib/generators/rspec/authentication/authentication_generator.rb
|
|
225
|
+
- lib/generators/rspec/authentication/templates/user_spec.rb
|
|
226
|
+
- lib/generators/rspec/authentication/templates/users.yml
|
|
200
227
|
- lib/generators/rspec/channel/channel_generator.rb
|
|
201
228
|
- lib/generators/rspec/channel/templates/channel_spec.rb.erb
|
|
202
229
|
- lib/generators/rspec/controller/controller_generator.rb
|
|
@@ -294,7 +321,7 @@ licenses:
|
|
|
294
321
|
- MIT
|
|
295
322
|
metadata:
|
|
296
323
|
bug_tracker_uri: https://github.com/rspec/rspec-rails/issues
|
|
297
|
-
changelog_uri: https://github.com/rspec/rspec-rails/blob/
|
|
324
|
+
changelog_uri: https://github.com/rspec/rspec-rails/blob/v8.1.0/Changelog.md
|
|
298
325
|
documentation_uri: https://rspec.info/documentation/
|
|
299
326
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
|
300
327
|
source_code_uri: https://github.com/rspec/rspec-rails
|
|
@@ -306,14 +333,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
306
333
|
requirements:
|
|
307
334
|
- - ">="
|
|
308
335
|
- !ruby/object:Gem::Version
|
|
309
|
-
version:
|
|
336
|
+
version: 3.0.0
|
|
310
337
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
311
338
|
requirements:
|
|
312
339
|
- - ">="
|
|
313
340
|
- !ruby/object:Gem::Version
|
|
314
341
|
version: '0'
|
|
315
342
|
requirements: []
|
|
316
|
-
rubygems_version:
|
|
343
|
+
rubygems_version: 4.0.20
|
|
317
344
|
specification_version: 4
|
|
318
345
|
summary: RSpec for Rails
|
|
319
346
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|