rspec-rails 6.1.0 → 7.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 +89 -3
- data/README.md +27 -25
- data/lib/generators/rspec/generator/generator_generator.rb +2 -2
- data/lib/generators/rspec/generator/templates/generator_spec.rb +1 -2
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +17 -10
- data/lib/generators/rspec/mailer/mailer_generator.rb +4 -2
- data/lib/generators/rspec/mailer/templates/preview.rb +3 -3
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +0 -15
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/request_spec.rb +0 -15
- data/lib/rspec/rails/configuration.rb +4 -2
- data/lib/rspec/rails/example/mailbox_example_group.rb +1 -1
- data/lib/rspec/rails/example/rails_example_group.rb +5 -7
- data/lib/rspec/rails/example/routing_example_group.rb +0 -2
- data/lib/rspec/rails/example/system_example_group.rb +9 -1
- data/lib/rspec/rails/fixture_support.rb +5 -6
- data/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +10 -3
- data/lib/rspec/rails/matchers/action_cable.rb +6 -1
- data/lib/rspec/rails/matchers/active_job.rb +67 -8
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +34 -2
- data/lib/rspec/rails/matchers/have_http_status.rb +3 -7
- data/lib/rspec/rails/tasks/rspec.rake +3 -1
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec-rails.rb +17 -0
- data.tar.gz.sig +0 -0
- metadata +20 -21
- metadata.gz.sig +0 -0
- data/lib/generators/rspec/integration/integration_generator.rb +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 725cbfd52d9f763648a595bba0a46d7c0905548e04b988f7c451a0b23ec5e283
|
|
4
|
+
data.tar.gz: ae2f038303eca35e63674c059e4ebe3b3788c47e52bd397ed67c5b857b8f2e19
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3949cffce869076c1b3d84806c76ce5c609b8ae7cc5cd906b44ed09d8df3be4c7d7603c4a2d0430d2337fe7d828b8879025bf32fcacecbb2da010f2108949479
|
|
7
|
+
data.tar.gz: 0a9c1d5d4968a49d52d6d68078761241431a28c8e2f023d3228536839c7a550d637996b050fbc771f475cc2b3951f0846be429a31fba9d124138f3d8b67d66e3
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/Changelog.md
CHANGED
|
@@ -1,5 +1,91 @@
|
|
|
1
1
|
### Development
|
|
2
|
-
[Full Changelog](https://github.com/rspec/rspec-rails/compare/
|
|
2
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.1.0...7-1-maintenance)
|
|
3
|
+
|
|
4
|
+
### 7.1.0 / 2024-11-09
|
|
5
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.0.2...v7.1.0)
|
|
6
|
+
|
|
7
|
+
Enhancements:
|
|
8
|
+
|
|
9
|
+
* Improve implicit description for ActionCable matchers `have_broadcasted_to` /
|
|
10
|
+
`have_broadcast`. (Simon Fish, #2795)
|
|
11
|
+
* Comment out `infer_spec_type_from_file_location!` in newly generated
|
|
12
|
+
`rails_helper.rb` files. (Jon Rowe, #2804)
|
|
13
|
+
* Allow turning off active job / mailer argument validation.
|
|
14
|
+
(Oli Peate, #2808)
|
|
15
|
+
|
|
16
|
+
### 7.0.2 / 2024-11-09
|
|
17
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.0.1...v7.0.2)
|
|
18
|
+
|
|
19
|
+
Bug Fixes:
|
|
20
|
+
|
|
21
|
+
* Fix issue with `have_enqueued_mail` when jobs were incorrectly matched due
|
|
22
|
+
to refactoring in #2780. (David Runger, #2793)
|
|
23
|
+
|
|
24
|
+
### 7.0.1 / 2024-09-03
|
|
25
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.0.0...v7.0.1)
|
|
26
|
+
|
|
27
|
+
Bug Fixes:
|
|
28
|
+
|
|
29
|
+
* Remove mutation of Rails constant in favour of public api. (Petrik de Heus, #2789)
|
|
30
|
+
* Cleanup Rails scaffold for unsupported versions. (Matt Jankowski, #2790)
|
|
31
|
+
* Remove deprecated scaffold that was unintentionally included in 7.0.0
|
|
32
|
+
(Jon Rowe, #2791)
|
|
33
|
+
|
|
34
|
+
### 7.0.0 / 2024-09-02
|
|
35
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.5...v7.0.0)
|
|
36
|
+
|
|
37
|
+
Enhancements:
|
|
38
|
+
|
|
39
|
+
* Change default driver for system specs on Rails 7.2 to match its default.
|
|
40
|
+
(Steve Polito, #2746)
|
|
41
|
+
* Verify ActiveJob arguments by comparing to the method signature. (Oli Peate, #2745)
|
|
42
|
+
* Add suggestion to rails_helper.rb to skip when not in test mode. (Glauco Custódio, #2751)
|
|
43
|
+
* Add `at_priority` qualifier to `have_enqueued_job` set of matchers. (mbajur, #2759)
|
|
44
|
+
* Add spec directories to `rails stats` on Rails main / 8.0.0. (Petrik de Heus, #2781)
|
|
45
|
+
|
|
46
|
+
### 6.1.5 / 2024-09-02
|
|
47
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.4...v6.1.5)
|
|
48
|
+
|
|
49
|
+
Bug Fixes:
|
|
50
|
+
|
|
51
|
+
* Restore old order of requiring support files. (Franz Liedke, #2785)
|
|
52
|
+
* Prevent running `rake spec:statsetup` on Rails main / 8.0.0. (Petrik de Heus, #2781)
|
|
53
|
+
|
|
54
|
+
### 6.1.4 / 2024-08-15
|
|
55
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.3...v6.1.4)
|
|
56
|
+
|
|
57
|
+
Bug Fixes:
|
|
58
|
+
|
|
59
|
+
* Prevent `have_http_status` matcher raising an error when encountering a raw `Rack::MockResponse`.
|
|
60
|
+
(Christophe Bliard, #2771)
|
|
61
|
+
* Move Rails version conditional from index scaffold generated file to template. (Matt Jankowski, #2777)
|
|
62
|
+
|
|
63
|
+
### 6.1.3 / 2024-06-19
|
|
64
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.2...v6.1.3)
|
|
65
|
+
|
|
66
|
+
Bug Fixes:
|
|
67
|
+
|
|
68
|
+
* Reset `ActiveSupport::CurrentAttributes` between examples. (Javier Julio, #2752)
|
|
69
|
+
* Fix a broken link in generated mailer previews. (Chiara Núñez, #2764)
|
|
70
|
+
* Fix `have_status_code` behaviour with deprecated status names by delegating
|
|
71
|
+
to `Rack::Utils.status_code/1` to set the expected status code. (Darren Boyd, #2765)
|
|
72
|
+
|
|
73
|
+
### 6.1.2 / 2024-03-19
|
|
74
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.1...v6.1.2)
|
|
75
|
+
|
|
76
|
+
Bug Fixes:
|
|
77
|
+
|
|
78
|
+
* Fix generated mailer paths to match Rails convention. (Patrício dos Santos, #2735)
|
|
79
|
+
* Fix class in template for generator specs. (Nicolas Buduroi, #2744)
|
|
80
|
+
|
|
81
|
+
### 6.1.1 / 2024-01-25
|
|
82
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.0...v6.1.1)
|
|
83
|
+
|
|
84
|
+
Bug Fixes:
|
|
85
|
+
|
|
86
|
+
* Improved deprecation message for `RSpec::Rails::Configuration.fixture_paths`
|
|
87
|
+
(Benoit Tigeot, #2720)
|
|
88
|
+
* Fix support for namespaced fixtures in Rails 7.1. (Benedikt Deicke, #2716)
|
|
3
89
|
|
|
4
90
|
### 6.1.0 / 2023-11-21
|
|
5
91
|
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.4...v6.1.0)
|
|
@@ -172,7 +258,7 @@ Enhancements:
|
|
|
172
258
|
(Eloy Espinaco, Luka Lüdicke, #2355, #2356, #2378)
|
|
173
259
|
* Generated scaffold now includes engine route helpers when inside a mountable engine.
|
|
174
260
|
(Andrew W. Lee, #2372)
|
|
175
|
-
* Improve request spec "controller"
|
|
261
|
+
* Improve request spec "controller" scaffold when no action is specified.
|
|
176
262
|
(Thomas Hareau, #2399)
|
|
177
263
|
* Introduce testing snippets concept (Phil Pirozhkov, Benoit Tigeot, #2423)
|
|
178
264
|
* Prevent collisions with `let(:name)` for Rails 6.1 and `let(:method_name)` on older
|
|
@@ -575,7 +661,7 @@ Enhancements:
|
|
|
575
661
|
* Add support for PATCH to route specs created via scaffold. (Igor Zubkov, #1336)
|
|
576
662
|
* Improve controller and routing spec calls to `routes` by using `yield`
|
|
577
663
|
instead of `call`. (Anton Davydov, #1308)
|
|
578
|
-
* Add support for `ActiveJob` specs as standard `RSpec::Rails::
|
|
664
|
+
* Add support for `ActiveJob` specs as standard `RSpec::Rails::RailsExampleGroup`s
|
|
579
665
|
via both `type: :job` and inferring type from spec directory `spec/jobs`.
|
|
580
666
|
(Gabe Martin-Dempesy, #1361)
|
|
581
667
|
* Include `RSpec::Rails::FixtureSupport` into example groups using metadata
|
data/README.md
CHANGED
|
@@ -9,7 +9,8 @@ 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` 7.x][]** for Rails 7.x.
|
|
13
|
+
* **[`rspec-rails` 6.x][]** for Rails 6.1, 7.0 or 7.1.
|
|
13
14
|
* **[`rspec-rails` 5.x][]** for Rails 5.2 or 6.x.
|
|
14
15
|
* **[`rspec-rails` 4.x][]** for Rails from 5.x or 6.x.
|
|
15
16
|
* **[`rspec-rails` 3.x][]** for Rails earlier than 5.0.
|
|
@@ -26,11 +27,12 @@ According to [RSpec Rails new versioning strategy][] use:
|
|
|
26
27
|
[`rspec-rails` 4.x]: https://github.com/rspec/rspec-rails/tree/4-1-maintenance
|
|
27
28
|
[`rspec-rails` 5.x]: https://github.com/rspec/rspec-rails/tree/5-1-maintenance
|
|
28
29
|
[`rspec-rails` 6.x]: https://github.com/rspec/rspec-rails/tree/6-1-maintenance
|
|
30
|
+
[`rspec-rails` 7.x]: https://github.com/rspec/rspec-rails/tree/7-0-maintenance
|
|
29
31
|
[RSpec Rails new versioning strategy]: https://github.com/rspec/rspec-rails/blob/main/rfcs/versioning-strategy.md
|
|
30
32
|
|
|
31
33
|
## Installation
|
|
32
34
|
|
|
33
|
-
**IMPORTANT** This README / branch refers to the
|
|
35
|
+
**IMPORTANT** This README / branch refers to the 7.1.x stable release series, only bugfixes from this series will
|
|
34
36
|
be added here. See the [`main` branch on Github](https://github.com/rspec/rspec-rails/tree/main) if you want or
|
|
35
37
|
require the latest unstable features.
|
|
36
38
|
|
|
@@ -40,7 +42,7 @@ require the latest unstable features.
|
|
|
40
42
|
```ruby
|
|
41
43
|
# Run against this stable release
|
|
42
44
|
group :development, :test do
|
|
43
|
-
gem 'rspec-rails', '~>
|
|
45
|
+
gem 'rspec-rails', '~> 7.0.0'
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
# Or, run against the main branch
|
|
@@ -87,7 +89,7 @@ read the [`rspec-rails` upgrade notes][] to find out what to watch out for.
|
|
|
87
89
|
|
|
88
90
|
Be sure to check the general [RSpec upgrade notes][] as well.
|
|
89
91
|
|
|
90
|
-
[`rspec-rails` upgrade notes]: https://rspec.info/features/
|
|
92
|
+
[`rspec-rails` upgrade notes]: https://rspec.info/features/7-0/rspec-rails/upgrade
|
|
91
93
|
[RSpec upgrade notes]: https://rspec.info/upgrading-from-rspec-2/
|
|
92
94
|
|
|
93
95
|
## Usage
|
|
@@ -209,22 +211,22 @@ to test the various parts of a Rails system:
|
|
|
209
211
|
Follow the links above for examples of how each matcher is used.
|
|
210
212
|
|
|
211
213
|
[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/
|
|
213
|
-
[`render_template`]: https://rspec.info/features/
|
|
214
|
-
[`redirect_to`]: https://rspec.info/features/
|
|
215
|
-
[`route_to`]: https://rspec.info/features/
|
|
216
|
-
[`be_routable`]: https://rspec.info/features/
|
|
217
|
-
[`have_http_status`]: https://rspec.info/features/
|
|
218
|
-
[`match_array`]: https://rspec.info/features/
|
|
219
|
-
[`have_been_enqueued`]: https://rspec.info/features/
|
|
220
|
-
[`have_enqueued_job`]: https://rspec.info/features/
|
|
214
|
+
[`be_a_new`]: https://rspec.info/features/7-0/rspec-rails/matchers/new-record-matcher
|
|
215
|
+
[`render_template`]: https://rspec.info/features/7-0/rspec-rails/matchers/render-template-matcher
|
|
216
|
+
[`redirect_to`]: https://rspec.info/features/7-0/rspec-rails/matchers/redirect-to-matcher
|
|
217
|
+
[`route_to`]: https://rspec.info/features/7-0/rspec-rails/routing-specs/route-to-matcher
|
|
218
|
+
[`be_routable`]: https://rspec.info/features/7-0/rspec-rails/routing-specs/be-routable-matcher
|
|
219
|
+
[`have_http_status`]: https://rspec.info/features/7-0/rspec-rails/matchers/have-http-status-matcher
|
|
220
|
+
[`match_array`]: https://rspec.info/features/7-0/rspec-rails/matchers/relation-match-array
|
|
221
|
+
[`have_been_enqueued`]: https://rspec.info/features/7-0/rspec-rails/matchers/have-been-enqueued-matcher
|
|
222
|
+
[`have_enqueued_job`]: https://rspec.info/features/7-0/rspec-rails/matchers/have-enqueued-job-matcher
|
|
221
223
|
|
|
222
224
|
### What else does RSpec Rails add?
|
|
223
225
|
|
|
224
226
|
For a comprehensive look at RSpec Rails’ features,
|
|
225
227
|
read the [official Cucumber documentation][].
|
|
226
228
|
|
|
227
|
-
[official Cucumber documentation]: https://rspec.info/features/
|
|
229
|
+
[official Cucumber documentation]: https://rspec.info/features/7-0/rspec-rails
|
|
228
230
|
|
|
229
231
|
## What tests should I write?
|
|
230
232
|
|
|
@@ -269,20 +271,20 @@ RSpec.describe User, type: :model do
|
|
|
269
271
|
...
|
|
270
272
|
```
|
|
271
273
|
|
|
272
|
-
[request]: https://rspec.info/features/
|
|
273
|
-
[feature]: https://rspec.info/features/
|
|
274
|
-
[system]: https://rspec.info/features/
|
|
275
|
-
[model]: https://rspec.info/features/
|
|
276
|
-
[controller]: https://rspec.info/features/
|
|
277
|
-
[mailer]: https://rspec.info/features/
|
|
278
|
-
[job]: https://rspec.info/features/
|
|
279
|
-
[view]: https://rspec.info/features/
|
|
280
|
-
[routing]: https://rspec.info/features/
|
|
281
|
-
[helper]: https://rspec.info/features/
|
|
274
|
+
[request]: https://rspec.info/features/7-0/rspec-rails/request-specs/request-spec
|
|
275
|
+
[feature]: https://rspec.info/features/7-0/rspec-rails/feature-specs/feature-spec
|
|
276
|
+
[system]: https://rspec.info/features/7-0/rspec-rails/system-specs/system-specs
|
|
277
|
+
[model]: https://rspec.info/features/7-0/rspec-rails/model-specs
|
|
278
|
+
[controller]: https://rspec.info/features/7-0/rspec-rails/controller-specs
|
|
279
|
+
[mailer]: https://rspec.info/features/7-0/rspec-rails/mailer-specs
|
|
280
|
+
[job]: https://rspec.info/features/7-0/rspec-rails/job-specs/job-spec
|
|
281
|
+
[view]: https://rspec.info/features/7-0/rspec-rails/view-specs/view-spec
|
|
282
|
+
[routing]: https://rspec.info/features/7-0/rspec-rails/routing-specs
|
|
283
|
+
[helper]: https://rspec.info/features/7-0/rspec-rails/helper-specs/helper-spec
|
|
282
284
|
[`ActionDispatch::IntegrationTest`]: https://api.rubyonrails.org/classes/ActionDispatch/IntegrationTest.html
|
|
283
285
|
[`ActionDispatch::SystemTestCase`]: https://api.rubyonrails.org/classes/ActionDispatch/SystemTestCase.html
|
|
284
286
|
[`ActionController::TestCase`]: https://api.rubyonrails.org/classes/ActionController/TestCase.html
|
|
285
|
-
[in the appropriate folder]: https://rspec.info/features/
|
|
287
|
+
[in the appropriate folder]: https://rspec.info/features/7-0/rspec-rails/directory-structure
|
|
286
288
|
|
|
287
289
|
### System specs, feature specs, request specs–what’s the difference?
|
|
288
290
|
|
|
@@ -4,7 +4,7 @@ module Rspec
|
|
|
4
4
|
module Generators
|
|
5
5
|
# @private
|
|
6
6
|
class GeneratorGenerator < Base
|
|
7
|
-
class_option :generator_specs, type: :boolean, default: true,
|
|
7
|
+
class_option :generator_specs, type: :boolean, default: true, desc: 'Generate generator specs'
|
|
8
8
|
|
|
9
9
|
def generate_generator_spec
|
|
10
10
|
return unless options[:generator_specs]
|
|
@@ -17,7 +17,7 @@ module Rspec
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def filename
|
|
20
|
-
"#{
|
|
20
|
+
"#{file_name}_generator_spec.rb"
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -4,6 +4,11 @@ ENV['RAILS_ENV'] ||= 'test'
|
|
|
4
4
|
require_relative '../config/environment'
|
|
5
5
|
# Prevent database truncation if the environment is production
|
|
6
6
|
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
|
7
|
+
<% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%>
|
|
8
|
+
# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file
|
|
9
|
+
# that will avoid rails generators crashing because migrations haven't been run yet
|
|
10
|
+
# return unless Rails.env.test?
|
|
11
|
+
<% end -%>
|
|
7
12
|
require 'rspec/rails'
|
|
8
13
|
# Add additional requires below this line. Rails is not loaded until this point!
|
|
9
14
|
|
|
@@ -20,7 +25,7 @@ require 'rspec/rails'
|
|
|
20
25
|
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
|
21
26
|
# require only the support files necessary.
|
|
22
27
|
#
|
|
23
|
-
# Rails.root.glob('spec/support/**/*.rb').
|
|
28
|
+
# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f }
|
|
24
29
|
|
|
25
30
|
<% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%>
|
|
26
31
|
# Checks for pending migrations and applies them before tests are run.
|
|
@@ -62,20 +67,22 @@ RSpec.configure do |config|
|
|
|
62
67
|
# config.use_transactional_fixtures = true
|
|
63
68
|
|
|
64
69
|
<% end -%>
|
|
65
|
-
# RSpec Rails
|
|
66
|
-
#
|
|
67
|
-
# `post` in specs under `spec/controllers`.
|
|
68
|
-
#
|
|
69
|
-
# You can disable this behaviour by removing the line below, and instead
|
|
70
|
-
# explicitly tag your specs with their type, e.g.:
|
|
70
|
+
# RSpec Rails uses metadata to mix in different behaviours to your tests,
|
|
71
|
+
# for example enabling you to call `get` and `post` in request specs. e.g.:
|
|
71
72
|
#
|
|
72
|
-
# RSpec.describe UsersController, type: :
|
|
73
|
+
# RSpec.describe UsersController, type: :request do
|
|
73
74
|
# # ...
|
|
74
75
|
# end
|
|
75
76
|
#
|
|
76
77
|
# The different available types are documented in the features, such as in
|
|
77
|
-
# https://rspec.info/features/
|
|
78
|
-
|
|
78
|
+
# https://rspec.info/features/7-0/rspec-rails
|
|
79
|
+
#
|
|
80
|
+
# You can also this infer these behaviours automatically by location, e.g.
|
|
81
|
+
# /spec/models would pull in the same behaviour as `type: :model` but this
|
|
82
|
+
# behaviour is considered legacy and will be removed in a future version.
|
|
83
|
+
#
|
|
84
|
+
# To enable this behaviour uncomment the line below.
|
|
85
|
+
# config.infer_spec_type_from_file_location!
|
|
79
86
|
|
|
80
87
|
# Filter lines from Rails gems in backtraces.
|
|
81
88
|
config.filter_rails_from_backtrace!
|
|
@@ -8,7 +8,8 @@ module Rspec
|
|
|
8
8
|
argument :actions, type: :array, default: [], banner: "method method"
|
|
9
9
|
|
|
10
10
|
def generate_mailer_spec
|
|
11
|
-
|
|
11
|
+
file_suffix = file_name.end_with?('mailer') ? 'spec.rb' : 'mailer_spec.rb'
|
|
12
|
+
template "mailer_spec.rb", target_path('mailers', class_path, [file_name, file_suffix].join('_'))
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def generate_fixtures_files
|
|
@@ -21,7 +22,8 @@ module Rspec
|
|
|
21
22
|
def generate_preview_files
|
|
22
23
|
return unless RSpec::Rails::FeatureCheck.has_action_mailer_preview?
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
file_suffix = file_name.end_with?('mailer') ? 'preview.rb' : 'mailer_preview.rb'
|
|
26
|
+
template "preview.rb", target_path("mailers/previews", class_path, [file_name, file_suffix].join('_'))
|
|
25
27
|
end
|
|
26
28
|
end
|
|
27
29
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<% module_namespacing do -%>
|
|
2
|
-
# Preview all emails at http://localhost:3000/rails/mailers/<%= file_path %>
|
|
3
|
-
class <%= class_name %>Preview < ActionMailer::Preview
|
|
2
|
+
# Preview all emails at http://localhost:3000/rails/mailers/<%= file_path %>_mailer
|
|
3
|
+
class <%= class_name %><%= 'Mailer' unless class_name.end_with?('Mailer') %>Preview < ActionMailer::Preview
|
|
4
4
|
<% actions.each do |action| -%>
|
|
5
5
|
|
|
6
|
-
# Preview this email at http://localhost:3000/rails/mailers/<%= file_path
|
|
6
|
+
# Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>_mailer/<%= action %>
|
|
7
7
|
def <%= action %>
|
|
8
8
|
<%= class_name.sub(/(Mailer)?$/, 'Mailer') %>.<%= action %>
|
|
9
9
|
end
|
|
@@ -90,17 +90,10 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
context "with invalid params" do
|
|
93
|
-
<% if Rails.version.to_f < 7.0 %>
|
|
94
|
-
it "returns a success response (i.e. to display the 'new' template)" do
|
|
95
|
-
post :create, params: {<%= singular_table_name %>: invalid_attributes}, session: valid_session
|
|
96
|
-
expect(response).to be_successful
|
|
97
|
-
end
|
|
98
|
-
<% else %>
|
|
99
93
|
it "renders a response with 422 status (i.e. to display the 'new' template)" do
|
|
100
94
|
post :create, params: {<%= singular_table_name %>: invalid_attributes}, session: valid_session
|
|
101
95
|
expect(response).to have_http_status(:unprocessable_entity)
|
|
102
96
|
end
|
|
103
|
-
<% end %>
|
|
104
97
|
end
|
|
105
98
|
end
|
|
106
99
|
|
|
@@ -125,19 +118,11 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
|
125
118
|
end
|
|
126
119
|
|
|
127
120
|
context "with invalid params" do
|
|
128
|
-
<% if Rails.version.to_f < 7.0 %>
|
|
129
|
-
it "returns a success response (i.e. to display the 'edit' template)" do
|
|
130
|
-
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
|
131
|
-
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: invalid_attributes}, session: valid_session
|
|
132
|
-
expect(response).to be_successful
|
|
133
|
-
end
|
|
134
|
-
<% else %>
|
|
135
121
|
it "renders a response with 422 status (i.e. to display the 'edit' template)" do
|
|
136
122
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
|
137
123
|
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: invalid_attributes}, session: valid_session
|
|
138
124
|
expect(response).to have_http_status(:unprocessable_entity)
|
|
139
125
|
end
|
|
140
|
-
<% end %>
|
|
141
126
|
end
|
|
142
127
|
end
|
|
143
128
|
|
|
@@ -18,7 +18,7 @@ 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
|
-
cell_selector =
|
|
21
|
+
cell_selector = 'div>p'
|
|
22
22
|
<% for attribute in output_attributes -%>
|
|
23
23
|
assert_select cell_selector, text: Regexp.new(<%= value_for(attribute) %>.to_s), count: 2
|
|
24
24
|
<% end -%>
|
|
@@ -83,17 +83,10 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
|
|
|
83
83
|
}.to change(<%= class_name %>, :count).by(0)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
<% if Rails.version.to_f < 7.0 %>
|
|
87
|
-
it "renders a successful response (i.e. to display the 'new' template)" do
|
|
88
|
-
post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
|
|
89
|
-
expect(response).to be_successful
|
|
90
|
-
end
|
|
91
|
-
<% else %>
|
|
92
86
|
it "renders a response with 422 status (i.e. to display the 'new' template)" do
|
|
93
87
|
post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
|
|
94
88
|
expect(response).to have_http_status(:unprocessable_entity)
|
|
95
89
|
end
|
|
96
|
-
<% end %>
|
|
97
90
|
end
|
|
98
91
|
end
|
|
99
92
|
|
|
@@ -119,19 +112,11 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
|
|
|
119
112
|
end
|
|
120
113
|
|
|
121
114
|
context "with invalid parameters" do
|
|
122
|
-
<% if Rails.version.to_f < 7.0 %>
|
|
123
|
-
it "renders a successful response (i.e. to display the 'edit' template)" do
|
|
124
|
-
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
|
125
|
-
patch <%= show_helper %>, params: { <%= singular_table_name %>: invalid_attributes }
|
|
126
|
-
expect(response).to be_successful
|
|
127
|
-
end
|
|
128
|
-
<% else %>
|
|
129
115
|
it "renders a response with 422 status (i.e. to display the 'edit' template)" do
|
|
130
116
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
|
131
117
|
patch <%= show_helper %>, params: { <%= singular_table_name %>: invalid_attributes }
|
|
132
118
|
expect(response).to have_http_status(:unprocessable_entity)
|
|
133
119
|
end
|
|
134
|
-
<% end %>
|
|
135
120
|
end
|
|
136
121
|
end
|
|
137
122
|
|
|
@@ -170,7 +170,8 @@ module RSpec
|
|
|
170
170
|
RSpec.deprecate(
|
|
171
171
|
"config.fixture_path",
|
|
172
172
|
replacement: "config.fixture_paths",
|
|
173
|
-
message: "Rails 7.1 has deprecated the singular fixture_path in favour of an array"
|
|
173
|
+
message: "Rails 7.1 has deprecated the singular fixture_path in favour of an array." \
|
|
174
|
+
"You should migrate to plural:"
|
|
174
175
|
)
|
|
175
176
|
fixture_paths&.first
|
|
176
177
|
end
|
|
@@ -179,7 +180,8 @@ module RSpec
|
|
|
179
180
|
RSpec.deprecate(
|
|
180
181
|
"config.fixture_path = #{path.inspect}",
|
|
181
182
|
replacement: "config.fixture_paths = [#{path.inspect}]",
|
|
182
|
-
message: "Rails 7.1 has deprecated the singular fixture_path in favour of an array"
|
|
183
|
+
message: "Rails 7.1 has deprecated the singular fixture_path in favour of an array." \
|
|
184
|
+
"You should migrate to plural:"
|
|
183
185
|
)
|
|
184
186
|
self.fixture_paths = Array(path)
|
|
185
187
|
end
|
|
@@ -69,7 +69,7 @@ module RSpec
|
|
|
69
69
|
#
|
|
70
70
|
# @param message [Hash, Mail::Message] a mail message or hash of
|
|
71
71
|
# attributes used to build one
|
|
72
|
-
# @return [
|
|
72
|
+
# @return [ActionMailbox::InboundMessage]
|
|
73
73
|
def process(message)
|
|
74
74
|
MailboxExampleGroup.create_inbound_email(message).tap do |mail|
|
|
75
75
|
self.class.mailbox_class.receive(mail)
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
# suite and ammeter.
|
|
3
3
|
require 'rspec/rails/matchers'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
end
|
|
5
|
+
require 'active_support/current_attributes/test_helper'
|
|
6
|
+
require 'active_support/execution_context/test_helper'
|
|
8
7
|
|
|
9
8
|
module RSpec
|
|
10
9
|
module Rails
|
|
@@ -16,10 +15,9 @@ module RSpec
|
|
|
16
15
|
include RSpec::Rails::MinitestLifecycleAdapter
|
|
17
16
|
include RSpec::Rails::MinitestAssertionAdapter
|
|
18
17
|
include RSpec::Rails::FixtureSupport
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
end
|
|
18
|
+
include RSpec::Rails::TaggedLoggingAdapter
|
|
19
|
+
include ActiveSupport::CurrentAttributes::TestHelper
|
|
20
|
+
include ActiveSupport::ExecutionContext::TestHelper
|
|
23
21
|
end
|
|
24
22
|
end
|
|
25
23
|
end
|
|
@@ -95,6 +95,14 @@ module RSpec
|
|
|
95
95
|
::Rails.application
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
+
# 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
|
|
105
|
+
|
|
98
106
|
included do |other|
|
|
99
107
|
ActiveSupport.on_load(:action_dispatch_system_test_case) do
|
|
100
108
|
ActionDispatch::SystemTesting::Server.silence_puma = true
|
|
@@ -137,7 +145,7 @@ module RSpec
|
|
|
137
145
|
self.class.before do
|
|
138
146
|
# A user may have already set the driver, so only default if driver
|
|
139
147
|
# is not set
|
|
140
|
-
driven_by(
|
|
148
|
+
driven_by(DEFAULT_DRIVER) unless @driver
|
|
141
149
|
end
|
|
142
150
|
end
|
|
143
151
|
|
|
@@ -10,8 +10,7 @@ module RSpec
|
|
|
10
10
|
include ActiveRecord::TestFixtures
|
|
11
11
|
|
|
12
12
|
# @private prevent ActiveSupport::TestFixtures to start a DB transaction.
|
|
13
|
-
# Monkey patched to avoid collisions with 'let(:name)'
|
|
14
|
-
# and let(:method_name) before Rails 6.1.
|
|
13
|
+
# Monkey patched to avoid collisions with 'let(:name)' since Rails 6.1
|
|
15
14
|
def run_in_transaction?
|
|
16
15
|
current_example_name = (RSpec.current_example && RSpec.current_example.metadata[:description])
|
|
17
16
|
use_transactional_tests && !self.class.uses_transaction?(current_example_name)
|
|
@@ -43,14 +42,14 @@ module RSpec
|
|
|
43
42
|
if ::Rails.version.to_f >= 7.1
|
|
44
43
|
def fixtures(*args)
|
|
45
44
|
super.tap do
|
|
46
|
-
fixture_sets.
|
|
47
|
-
proxy_method_warning_if_called_in_before_context_scope(fixture_name)
|
|
45
|
+
fixture_sets.each_pair do |method_name, fixture_name|
|
|
46
|
+
proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)
|
|
48
47
|
end
|
|
49
48
|
end
|
|
50
49
|
end
|
|
51
50
|
|
|
52
|
-
def proxy_method_warning_if_called_in_before_context_scope(fixture_name)
|
|
53
|
-
define_method(
|
|
51
|
+
def proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)
|
|
52
|
+
define_method(method_name) do |*args, **kwargs, &blk|
|
|
54
53
|
if RSpec.current_scope == :before_context_hook
|
|
55
54
|
RSpec.warn_with("Calling fixture method in before :context ")
|
|
56
55
|
else
|
|
@@ -51,6 +51,10 @@ module RSpec
|
|
|
51
51
|
exactly(:thrice)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
def description
|
|
55
|
+
"have broadcasted #{base_description}"
|
|
56
|
+
end
|
|
57
|
+
|
|
54
58
|
def failure_message
|
|
55
59
|
"expected to broadcast #{base_message}".tap do |msg|
|
|
56
60
|
if @unmatching_msgs.any?
|
|
@@ -140,18 +144,21 @@ module RSpec
|
|
|
140
144
|
end
|
|
141
145
|
end
|
|
142
146
|
|
|
143
|
-
def
|
|
147
|
+
def base_description
|
|
144
148
|
"#{message_expectation_modifier} #{@expected_number} messages to #{stream}".tap do |msg|
|
|
145
149
|
msg << " with #{data_description(@data)}" unless @data.nil?
|
|
146
|
-
msg << ", but broadcast #{@matching_msgs_count}"
|
|
147
150
|
end
|
|
148
151
|
end
|
|
149
152
|
|
|
153
|
+
def base_message
|
|
154
|
+
"#{base_description}, but broadcast #{@matching_msgs_count}"
|
|
155
|
+
end
|
|
156
|
+
|
|
150
157
|
def data_description(data)
|
|
151
158
|
if data.is_a?(RSpec::Matchers::Composable)
|
|
152
159
|
data.description
|
|
153
160
|
else
|
|
154
|
-
data
|
|
161
|
+
data.inspect
|
|
155
162
|
end
|
|
156
163
|
end
|
|
157
164
|
|
|
@@ -3,6 +3,8 @@ require "rspec/rails/matchers/action_cable/have_broadcasted_to"
|
|
|
3
3
|
module RSpec
|
|
4
4
|
module Rails
|
|
5
5
|
module Matchers
|
|
6
|
+
extend RSpec::Matchers::DSL
|
|
7
|
+
|
|
6
8
|
# Namespace for various implementations of ActionCable features
|
|
7
9
|
#
|
|
8
10
|
# @api private
|
|
@@ -50,7 +52,10 @@ module RSpec
|
|
|
50
52
|
|
|
51
53
|
ActionCable::HaveBroadcastedTo.new(target, channel: described_class)
|
|
52
54
|
end
|
|
53
|
-
|
|
55
|
+
|
|
56
|
+
alias_matcher :broadcast_to, :have_broadcasted_to do |desc|
|
|
57
|
+
desc.gsub("have broadcasted", "broadcast")
|
|
58
|
+
end
|
|
54
59
|
|
|
55
60
|
private
|
|
56
61
|
|
|
@@ -14,6 +14,7 @@ module RSpec
|
|
|
14
14
|
def initialize
|
|
15
15
|
@args = []
|
|
16
16
|
@queue = nil
|
|
17
|
+
@priority = nil
|
|
17
18
|
@at = nil
|
|
18
19
|
@block = proc { }
|
|
19
20
|
set_expected_number(:exactly, 1)
|
|
@@ -30,6 +31,11 @@ module RSpec
|
|
|
30
31
|
self
|
|
31
32
|
end
|
|
32
33
|
|
|
34
|
+
def at_priority(priority)
|
|
35
|
+
@priority = priority.to_i
|
|
36
|
+
self
|
|
37
|
+
end
|
|
38
|
+
|
|
33
39
|
def at(time_or_date)
|
|
34
40
|
case time_or_date
|
|
35
41
|
when Time then @at = Time.at(time_or_date.to_f)
|
|
@@ -71,6 +77,8 @@ module RSpec
|
|
|
71
77
|
end
|
|
72
78
|
|
|
73
79
|
def failure_message
|
|
80
|
+
return @failure_message if defined?(@failure_message)
|
|
81
|
+
|
|
74
82
|
"expected to #{self.class::FAILURE_MESSAGE_EXPECTATION_ACTION} #{base_message}".tap do |msg|
|
|
75
83
|
if @unmatching_jobs.any?
|
|
76
84
|
msg << "\nQueued jobs:"
|
|
@@ -101,7 +109,7 @@ module RSpec
|
|
|
101
109
|
|
|
102
110
|
def check(jobs)
|
|
103
111
|
@matching_jobs, @unmatching_jobs = jobs.partition do |job|
|
|
104
|
-
if
|
|
112
|
+
if matches_constraints?(job)
|
|
105
113
|
args = deserialize_arguments(job)
|
|
106
114
|
@block.call(*args)
|
|
107
115
|
true
|
|
@@ -109,6 +117,12 @@ module RSpec
|
|
|
109
117
|
false
|
|
110
118
|
end
|
|
111
119
|
end
|
|
120
|
+
|
|
121
|
+
if (signature_mismatch = detect_args_signature_mismatch(@matching_jobs))
|
|
122
|
+
@failure_message = signature_mismatch
|
|
123
|
+
return false
|
|
124
|
+
end
|
|
125
|
+
|
|
112
126
|
@matching_jobs_count = @matching_jobs.size
|
|
113
127
|
|
|
114
128
|
case @expectation_type
|
|
@@ -123,6 +137,7 @@ module RSpec
|
|
|
123
137
|
msg << " with #{@args}," if @args.any?
|
|
124
138
|
msg << " on queue #{@queue}," if @queue
|
|
125
139
|
msg << " at #{@at.inspect}," if @at
|
|
140
|
+
msg << " with priority #{@priority}," if @priority
|
|
126
141
|
msg << " but #{self.class::MESSAGE_EXPECTATION_ACTION} #{@matching_jobs_count}"
|
|
127
142
|
end
|
|
128
143
|
end
|
|
@@ -132,13 +147,23 @@ module RSpec
|
|
|
132
147
|
msg_parts << "with #{deserialize_arguments(job)}" if job[:args].any?
|
|
133
148
|
msg_parts << "on queue #{job[:queue]}" if job[:queue]
|
|
134
149
|
msg_parts << "at #{Time.at(job[:at])}" if job[:at]
|
|
150
|
+
msg_parts <<
|
|
151
|
+
if job[:priority]
|
|
152
|
+
"with priority #{job[:priority]}"
|
|
153
|
+
else
|
|
154
|
+
"with no priority specified"
|
|
155
|
+
end
|
|
135
156
|
|
|
136
157
|
"#{job[:job].name} job".tap do |msg|
|
|
137
158
|
msg << " #{msg_parts.join(', ')}" if msg_parts.any?
|
|
138
159
|
end
|
|
139
160
|
end
|
|
140
161
|
|
|
141
|
-
def
|
|
162
|
+
def matches_constraints?(job)
|
|
163
|
+
job_matches?(job) && arguments_match?(job) && queue_match?(job) && at_match?(job) && priority_match?(job)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def job_matches?(job)
|
|
142
167
|
@job ? @job == job[:job] : true
|
|
143
168
|
end
|
|
144
169
|
|
|
@@ -152,12 +177,46 @@ module RSpec
|
|
|
152
177
|
end
|
|
153
178
|
end
|
|
154
179
|
|
|
180
|
+
def detect_args_signature_mismatch(jobs)
|
|
181
|
+
return if skip_signature_verification?
|
|
182
|
+
|
|
183
|
+
jobs.each do |job|
|
|
184
|
+
args = deserialize_arguments(job)
|
|
185
|
+
|
|
186
|
+
if (signature_mismatch = check_args_signature_mismatch(job.fetch(:job), :perform, args))
|
|
187
|
+
return signature_mismatch
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
nil
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def skip_signature_verification?
|
|
195
|
+
!RSpec::Mocks.configuration.verify_partial_doubles? ||
|
|
196
|
+
RSpec::Mocks.configuration.temporarily_suppress_partial_double_verification
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def check_args_signature_mismatch(job_class, job_method, args)
|
|
200
|
+
signature = Support::MethodSignature.new(job_class.public_instance_method(job_method))
|
|
201
|
+
verifier = Support::StrictSignatureVerifier.new(signature, args)
|
|
202
|
+
|
|
203
|
+
unless verifier.valid?
|
|
204
|
+
"Incorrect arguments passed to #{job_class.name}: #{verifier.error_message}"
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
155
208
|
def queue_match?(job)
|
|
156
209
|
return true unless @queue
|
|
157
210
|
|
|
158
211
|
@queue == job[:queue]
|
|
159
212
|
end
|
|
160
213
|
|
|
214
|
+
def priority_match?(job)
|
|
215
|
+
return true unless @priority
|
|
216
|
+
|
|
217
|
+
@priority == job[:priority]
|
|
218
|
+
end
|
|
219
|
+
|
|
161
220
|
def at_match?(job)
|
|
162
221
|
return true unless @at
|
|
163
222
|
return job[:at].nil? if @at == :no_wait
|
|
@@ -384,33 +443,33 @@ module RSpec
|
|
|
384
443
|
#
|
|
385
444
|
# @example
|
|
386
445
|
# expect {
|
|
387
|
-
#
|
|
446
|
+
# perform_enqueued_jobs { HeavyLiftingJob.perform_later }
|
|
388
447
|
# }.to have_performed_job
|
|
389
448
|
#
|
|
390
449
|
# expect {
|
|
391
|
-
#
|
|
450
|
+
# perform_enqueued_jobs {
|
|
392
451
|
# HelloJob.perform_later
|
|
393
452
|
# HeavyLiftingJob.perform_later
|
|
394
453
|
# }
|
|
395
454
|
# }.to have_performed_job(HelloJob).exactly(:once)
|
|
396
455
|
#
|
|
397
456
|
# expect {
|
|
398
|
-
#
|
|
457
|
+
# perform_enqueued_jobs { 3.times { HelloJob.perform_later } }
|
|
399
458
|
# }.to have_performed_job(HelloJob).at_least(2).times
|
|
400
459
|
#
|
|
401
460
|
# expect {
|
|
402
|
-
#
|
|
461
|
+
# perform_enqueued_jobs { HelloJob.perform_later }
|
|
403
462
|
# }.to have_performed_job(HelloJob).at_most(:twice)
|
|
404
463
|
#
|
|
405
464
|
# expect {
|
|
406
|
-
#
|
|
465
|
+
# perform_enqueued_jobs {
|
|
407
466
|
# HelloJob.perform_later
|
|
408
467
|
# HeavyLiftingJob.perform_later
|
|
409
468
|
# }
|
|
410
469
|
# }.to have_performed_job(HelloJob).and have_performed_job(HeavyLiftingJob)
|
|
411
470
|
#
|
|
412
471
|
# expect {
|
|
413
|
-
#
|
|
472
|
+
# perform_enqueued_jobs {
|
|
414
473
|
# HelloJob.set(wait_until: Date.tomorrow.noon, queue: "low").perform_later(42)
|
|
415
474
|
# }
|
|
416
475
|
# }.to have_performed_job.with(42).on_queue("low").at(Date.tomorrow.noon)
|
|
@@ -41,6 +41,8 @@ module RSpec
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def failure_message
|
|
44
|
+
return @failure_message if defined?(@failure_message)
|
|
45
|
+
|
|
44
46
|
"expected to enqueue #{base_message}".tap do |msg|
|
|
45
47
|
msg << "\n#{unmatching_mail_jobs_message}" if unmatching_mail_jobs.any?
|
|
46
48
|
end
|
|
@@ -70,7 +72,7 @@ module RSpec
|
|
|
70
72
|
@mailer_class ? @mailer_class.name : 'ActionMailer::Base'
|
|
71
73
|
end
|
|
72
74
|
|
|
73
|
-
def
|
|
75
|
+
def job_matches?(job)
|
|
74
76
|
legacy_mail?(job) || parameterized_mail?(job) || unified_mail?(job)
|
|
75
77
|
end
|
|
76
78
|
|
|
@@ -89,6 +91,23 @@ module RSpec
|
|
|
89
91
|
super(job)
|
|
90
92
|
end
|
|
91
93
|
|
|
94
|
+
def detect_args_signature_mismatch(jobs)
|
|
95
|
+
return if @method_name.nil?
|
|
96
|
+
return if skip_signature_verification?
|
|
97
|
+
|
|
98
|
+
mailer_class = mailer_class_name.constantize
|
|
99
|
+
|
|
100
|
+
jobs.each do |job|
|
|
101
|
+
mailer_args = extract_args_without_parameterized_params(job)
|
|
102
|
+
|
|
103
|
+
if (signature_mismatch = check_args_signature_mismatch(mailer_class, @method_name, mailer_args))
|
|
104
|
+
return signature_mismatch
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
nil
|
|
109
|
+
end
|
|
110
|
+
|
|
92
111
|
def base_mailer_args
|
|
93
112
|
[mailer_class_name, @method_name.to_s, MAILER_JOB_METHOD]
|
|
94
113
|
end
|
|
@@ -105,7 +124,7 @@ module RSpec
|
|
|
105
124
|
|
|
106
125
|
def unmatching_mail_jobs
|
|
107
126
|
@unmatching_jobs.select do |job|
|
|
108
|
-
|
|
127
|
+
job_matches?(job)
|
|
109
128
|
end
|
|
110
129
|
end
|
|
111
130
|
|
|
@@ -157,6 +176,19 @@ module RSpec
|
|
|
157
176
|
end
|
|
158
177
|
end
|
|
159
178
|
|
|
179
|
+
def extract_args_without_parameterized_params(job)
|
|
180
|
+
args = deserialize_arguments(job)
|
|
181
|
+
mailer_args = args - base_mailer_args
|
|
182
|
+
|
|
183
|
+
if parameterized_mail?(job)
|
|
184
|
+
mailer_args = mailer_args[1..-1] # ignore parameterized params
|
|
185
|
+
elsif mailer_args.last.is_a?(Hash) && mailer_args.last.key?(:args)
|
|
186
|
+
mailer_args = args.last[:args]
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
mailer_args
|
|
190
|
+
end
|
|
191
|
+
|
|
160
192
|
def legacy_mail?(job)
|
|
161
193
|
RSpec::Rails::FeatureCheck.has_action_mailer_legacy_delivery_job? && job[:job] <= ActionMailer::DeliveryJob
|
|
162
194
|
end
|
|
@@ -33,7 +33,7 @@ module RSpec
|
|
|
33
33
|
# @param obj [Object] object to convert to a response
|
|
34
34
|
# @return [ActionDispatch::TestResponse]
|
|
35
35
|
def as_test_response(obj)
|
|
36
|
-
if ::ActionDispatch::Response === obj
|
|
36
|
+
if ::ActionDispatch::Response === obj || ::Rack::MockResponse === obj
|
|
37
37
|
::ActionDispatch::TestResponse.from_response(obj)
|
|
38
38
|
elsif ::ActionDispatch::TestResponse === obj
|
|
39
39
|
obj
|
|
@@ -216,11 +216,7 @@ module RSpec
|
|
|
216
216
|
# @see Rack::Utils::SYMBOL_TO_STATUS_CODE
|
|
217
217
|
# @raise [ArgumentError] if an associated code could not be found
|
|
218
218
|
def set_expected_code!
|
|
219
|
-
@expected ||=
|
|
220
|
-
Rack::Utils::SYMBOL_TO_STATUS_CODE.fetch(expected_status) do
|
|
221
|
-
raise ArgumentError,
|
|
222
|
-
"Invalid HTTP status: #{expected_status.inspect}"
|
|
223
|
-
end
|
|
219
|
+
@expected ||= Rack::Utils.status_code(expected_status)
|
|
224
220
|
end
|
|
225
221
|
end
|
|
226
222
|
|
|
@@ -237,7 +233,7 @@ module RSpec
|
|
|
237
233
|
# expect(response).to have_http_status(:redirect)
|
|
238
234
|
#
|
|
239
235
|
# @see RSpec::Rails::Matchers#have_http_status
|
|
240
|
-
# @see https://github.com/rails/rails/blob/
|
|
236
|
+
# @see https://github.com/rails/rails/blob/7-2-stable/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
|
|
241
237
|
class GenericStatus < RSpec::Rails::Matchers::BaseMatcher
|
|
242
238
|
include HaveHttpStatus
|
|
243
239
|
|
data/lib/rspec/rails/version.rb
CHANGED
data/lib/rspec-rails.rb
CHANGED
|
@@ -9,6 +9,23 @@ module RSpec
|
|
|
9
9
|
# As of Rails 5.1.0 you can register directories to work with `rake notes`
|
|
10
10
|
require 'rails/source_annotation_extractor'
|
|
11
11
|
::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec")
|
|
12
|
+
|
|
13
|
+
# As of Rails 8.0.0 you can register directories to work with `rails stats`
|
|
14
|
+
if ::Rails::VERSION::STRING >= "8.0.0"
|
|
15
|
+
require 'rails/code_statistics'
|
|
16
|
+
|
|
17
|
+
dirs = Dir['./spec/**/*_spec.rb']
|
|
18
|
+
.map { |f| f.sub(/^\.\/(spec\/\w+)\/.*/, '\\1') }
|
|
19
|
+
.uniq
|
|
20
|
+
.select { |f| File.directory?(f) }
|
|
21
|
+
|
|
22
|
+
Hash[dirs.map { |d| [d.split('/').last, d] }].each do |type, dir|
|
|
23
|
+
name = type.singularize.capitalize
|
|
24
|
+
|
|
25
|
+
::Rails::CodeStatistics.register_directory "#{name} specs", dir, test_directory: true
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
12
29
|
generators = config.app_generators
|
|
13
30
|
generators.integration_tool :rspec
|
|
14
31
|
generators.test_framework :rspec
|
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: 7.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Chelimsky
|
|
@@ -44,7 +44,7 @@ cert_chain:
|
|
|
44
44
|
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
|
|
45
45
|
F3MdtaDehhjC
|
|
46
46
|
-----END CERTIFICATE-----
|
|
47
|
-
date:
|
|
47
|
+
date: 2024-11-09 00:00:00.000000000 Z
|
|
48
48
|
dependencies:
|
|
49
49
|
- !ruby/object:Gem::Dependency
|
|
50
50
|
name: actionpack
|
|
@@ -52,98 +52,98 @@ dependencies:
|
|
|
52
52
|
requirements:
|
|
53
53
|
- - ">="
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
|
-
version: '
|
|
55
|
+
version: '7.0'
|
|
56
56
|
type: :runtime
|
|
57
57
|
prerelease: false
|
|
58
58
|
version_requirements: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
|
60
60
|
- - ">="
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: '
|
|
62
|
+
version: '7.0'
|
|
63
63
|
- !ruby/object:Gem::Dependency
|
|
64
64
|
name: activesupport
|
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
|
67
67
|
- - ">="
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: '
|
|
69
|
+
version: '7.0'
|
|
70
70
|
type: :runtime
|
|
71
71
|
prerelease: false
|
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
73
|
requirements:
|
|
74
74
|
- - ">="
|
|
75
75
|
- !ruby/object:Gem::Version
|
|
76
|
-
version: '
|
|
76
|
+
version: '7.0'
|
|
77
77
|
- !ruby/object:Gem::Dependency
|
|
78
78
|
name: railties
|
|
79
79
|
requirement: !ruby/object:Gem::Requirement
|
|
80
80
|
requirements:
|
|
81
81
|
- - ">="
|
|
82
82
|
- !ruby/object:Gem::Version
|
|
83
|
-
version: '
|
|
83
|
+
version: '7.0'
|
|
84
84
|
type: :runtime
|
|
85
85
|
prerelease: false
|
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
|
87
87
|
requirements:
|
|
88
88
|
- - ">="
|
|
89
89
|
- !ruby/object:Gem::Version
|
|
90
|
-
version: '
|
|
90
|
+
version: '7.0'
|
|
91
91
|
- !ruby/object:Gem::Dependency
|
|
92
92
|
name: rspec-core
|
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
|
94
94
|
requirements:
|
|
95
95
|
- - "~>"
|
|
96
96
|
- !ruby/object:Gem::Version
|
|
97
|
-
version: '3.
|
|
97
|
+
version: '3.13'
|
|
98
98
|
type: :runtime
|
|
99
99
|
prerelease: false
|
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
|
101
101
|
requirements:
|
|
102
102
|
- - "~>"
|
|
103
103
|
- !ruby/object:Gem::Version
|
|
104
|
-
version: '3.
|
|
104
|
+
version: '3.13'
|
|
105
105
|
- !ruby/object:Gem::Dependency
|
|
106
106
|
name: rspec-expectations
|
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
|
108
108
|
requirements:
|
|
109
109
|
- - "~>"
|
|
110
110
|
- !ruby/object:Gem::Version
|
|
111
|
-
version: '3.
|
|
111
|
+
version: '3.13'
|
|
112
112
|
type: :runtime
|
|
113
113
|
prerelease: false
|
|
114
114
|
version_requirements: !ruby/object:Gem::Requirement
|
|
115
115
|
requirements:
|
|
116
116
|
- - "~>"
|
|
117
117
|
- !ruby/object:Gem::Version
|
|
118
|
-
version: '3.
|
|
118
|
+
version: '3.13'
|
|
119
119
|
- !ruby/object:Gem::Dependency
|
|
120
120
|
name: rspec-mocks
|
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
|
122
122
|
requirements:
|
|
123
123
|
- - "~>"
|
|
124
124
|
- !ruby/object:Gem::Version
|
|
125
|
-
version: '3.
|
|
125
|
+
version: '3.13'
|
|
126
126
|
type: :runtime
|
|
127
127
|
prerelease: false
|
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
|
129
129
|
requirements:
|
|
130
130
|
- - "~>"
|
|
131
131
|
- !ruby/object:Gem::Version
|
|
132
|
-
version: '3.
|
|
132
|
+
version: '3.13'
|
|
133
133
|
- !ruby/object:Gem::Dependency
|
|
134
134
|
name: rspec-support
|
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
|
136
136
|
requirements:
|
|
137
137
|
- - "~>"
|
|
138
138
|
- !ruby/object:Gem::Version
|
|
139
|
-
version: '3.
|
|
139
|
+
version: '3.13'
|
|
140
140
|
type: :runtime
|
|
141
141
|
prerelease: false
|
|
142
142
|
version_requirements: !ruby/object:Gem::Requirement
|
|
143
143
|
requirements:
|
|
144
144
|
- - "~>"
|
|
145
145
|
- !ruby/object:Gem::Version
|
|
146
|
-
version: '3.
|
|
146
|
+
version: '3.13'
|
|
147
147
|
- !ruby/object:Gem::Dependency
|
|
148
148
|
name: ammeter
|
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -186,7 +186,7 @@ dependencies:
|
|
|
186
186
|
- - "~>"
|
|
187
187
|
- !ruby/object:Gem::Version
|
|
188
188
|
version: '7.0'
|
|
189
|
-
description: rspec-rails
|
|
189
|
+
description: rspec-rails integrates the Rails testing helpers into RSpec.
|
|
190
190
|
email: rspec@googlegroups.com
|
|
191
191
|
executables: []
|
|
192
192
|
extensions: []
|
|
@@ -215,7 +215,6 @@ files:
|
|
|
215
215
|
- lib/generators/rspec/helper/templates/helper_spec.rb
|
|
216
216
|
- lib/generators/rspec/install/install_generator.rb
|
|
217
217
|
- lib/generators/rspec/install/templates/spec/rails_helper.rb
|
|
218
|
-
- lib/generators/rspec/integration/integration_generator.rb
|
|
219
218
|
- lib/generators/rspec/job/job_generator.rb
|
|
220
219
|
- lib/generators/rspec/job/templates/job_spec.rb.erb
|
|
221
220
|
- lib/generators/rspec/mailbox/mailbox_generator.rb
|
|
@@ -297,7 +296,7 @@ licenses:
|
|
|
297
296
|
- MIT
|
|
298
297
|
metadata:
|
|
299
298
|
bug_tracker_uri: https://github.com/rspec/rspec-rails/issues
|
|
300
|
-
changelog_uri: https://github.com/rspec/rspec-rails/blob/
|
|
299
|
+
changelog_uri: https://github.com/rspec/rspec-rails/blob/v7.1.0/Changelog.md
|
|
301
300
|
documentation_uri: https://rspec.info/documentation/
|
|
302
301
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
|
303
302
|
source_code_uri: https://github.com/rspec/rspec-rails
|
|
@@ -310,14 +309,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
310
309
|
requirements:
|
|
311
310
|
- - ">="
|
|
312
311
|
- !ruby/object:Gem::Version
|
|
313
|
-
version: 2.
|
|
312
|
+
version: 2.7.0
|
|
314
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
314
|
requirements:
|
|
316
315
|
- - ">="
|
|
317
316
|
- !ruby/object:Gem::Version
|
|
318
317
|
version: '0'
|
|
319
318
|
requirements: []
|
|
320
|
-
rubygems_version: 3.
|
|
319
|
+
rubygems_version: 3.5.22
|
|
321
320
|
signing_key:
|
|
322
321
|
specification_version: 4
|
|
323
322
|
summary: RSpec for Rails
|
metadata.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require 'generators/rspec'
|
|
2
|
-
require 'rspec/core/warnings'
|
|
3
|
-
|
|
4
|
-
module Rspec
|
|
5
|
-
module Generators
|
|
6
|
-
# @private
|
|
7
|
-
class IntegrationGenerator < Base
|
|
8
|
-
class_option :request_specs,
|
|
9
|
-
type: :boolean,
|
|
10
|
-
default: true,
|
|
11
|
-
desc: "Generate request specs"
|
|
12
|
-
|
|
13
|
-
source_paths << File.expand_path('../request/templates', __dir__)
|
|
14
|
-
|
|
15
|
-
def generate_request_spec
|
|
16
|
-
return unless options[:request_specs]
|
|
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
|
-
|
|
24
|
-
template 'request_spec.rb',
|
|
25
|
-
target_path('requests', "#{name.underscore.pluralize}_spec.rb")
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|