rspec-rails 7.0.1 → 7.1.1
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 +238 -210
- data/README.md +26 -29
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +11 -9
- 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 +9 -0
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +6 -5
- data/lib/rspec/rails/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +22 -26
- metadata.gz.sig +0 -0
data/README.md
CHANGED
@@ -10,7 +10,7 @@ expressed in plain English.
|
|
10
10
|
|
11
11
|
According to [RSpec Rails new versioning strategy][] use:
|
12
12
|
* **[`rspec-rails` 7.x][]** for Rails 7.x.
|
13
|
-
* **[`rspec-rails` 6.x][]** for Rails 6.1.
|
13
|
+
* **[`rspec-rails` 6.x][]** for Rails 6.1, 7.0 or 7.1.
|
14
14
|
* **[`rspec-rails` 5.x][]** for Rails 5.2 or 6.x.
|
15
15
|
* **[`rspec-rails` 4.x][]** for Rails from 5.x or 6.x.
|
16
16
|
* **[`rspec-rails` 3.x][]** for Rails earlier than 5.0.
|
@@ -27,12 +27,12 @@ According to [RSpec Rails new versioning strategy][] use:
|
|
27
27
|
[`rspec-rails` 4.x]: https://github.com/rspec/rspec-rails/tree/4-1-maintenance
|
28
28
|
[`rspec-rails` 5.x]: https://github.com/rspec/rspec-rails/tree/5-1-maintenance
|
29
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-
|
30
|
+
[`rspec-rails` 7.x]: https://github.com/rspec/rspec-rails/tree/7-1-maintenance
|
31
31
|
[RSpec Rails new versioning strategy]: https://github.com/rspec/rspec-rails/blob/main/rfcs/versioning-strategy.md
|
32
32
|
|
33
33
|
## Installation
|
34
34
|
|
35
|
-
**IMPORTANT** This README / branch refers to the 7.
|
35
|
+
**IMPORTANT** This README / branch refers to the 7.1.x stable release series, only bugfixes from this series will
|
36
36
|
be added here. See the [`main` branch on Github](https://github.com/rspec/rspec-rails/tree/main) if you want or
|
37
37
|
require the latest unstable features.
|
38
38
|
|
@@ -46,11 +46,8 @@ require the latest unstable features.
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Or, run against the main branch
|
49
|
-
# (requires main-branch versions of all related RSpec libraries)
|
50
49
|
group :development, :test do
|
51
|
-
|
52
|
-
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'main'
|
53
|
-
end
|
50
|
+
gem 'rspec-rails', git: 'https://github.com/rspec/rspec-rails'
|
54
51
|
end
|
55
52
|
```
|
56
53
|
|
@@ -89,7 +86,7 @@ read the [`rspec-rails` upgrade notes][] to find out what to watch out for.
|
|
89
86
|
|
90
87
|
Be sure to check the general [RSpec upgrade notes][] as well.
|
91
88
|
|
92
|
-
[`rspec-rails` upgrade notes]: https://rspec.info/features/7-
|
89
|
+
[`rspec-rails` upgrade notes]: https://rspec.info/features/7-1/rspec-rails/upgrade
|
93
90
|
[RSpec upgrade notes]: https://rspec.info/upgrading-from-rspec-2/
|
94
91
|
|
95
92
|
## Usage
|
@@ -211,22 +208,22 @@ to test the various parts of a Rails system:
|
|
211
208
|
Follow the links above for examples of how each matcher is used.
|
212
209
|
|
213
210
|
[the matchers that come standard in RSpec]: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers
|
214
|
-
[`be_a_new`]: https://rspec.info/features/7-
|
215
|
-
[`render_template`]: https://rspec.info/features/7-
|
216
|
-
[`redirect_to`]: https://rspec.info/features/7-
|
217
|
-
[`route_to`]: https://rspec.info/features/7-
|
218
|
-
[`be_routable`]: https://rspec.info/features/7-
|
219
|
-
[`have_http_status`]: https://rspec.info/features/7-
|
220
|
-
[`match_array`]: https://rspec.info/features/7-
|
221
|
-
[`have_been_enqueued`]: https://rspec.info/features/7-
|
222
|
-
[`have_enqueued_job`]: https://rspec.info/features/7-
|
211
|
+
[`be_a_new`]: https://rspec.info/features/7-1/rspec-rails/matchers/new-record-matcher
|
212
|
+
[`render_template`]: https://rspec.info/features/7-1/rspec-rails/matchers/render-template-matcher
|
213
|
+
[`redirect_to`]: https://rspec.info/features/7-1/rspec-rails/matchers/redirect-to-matcher
|
214
|
+
[`route_to`]: https://rspec.info/features/7-1/rspec-rails/routing-specs/route-to-matcher
|
215
|
+
[`be_routable`]: https://rspec.info/features/7-1/rspec-rails/routing-specs/be-routable-matcher
|
216
|
+
[`have_http_status`]: https://rspec.info/features/7-1/rspec-rails/matchers/have-http-status-matcher
|
217
|
+
[`match_array`]: https://rspec.info/features/7-1/rspec-rails/matchers/relation-match-array
|
218
|
+
[`have_been_enqueued`]: https://rspec.info/features/7-1/rspec-rails/matchers/have-been-enqueued-matcher
|
219
|
+
[`have_enqueued_job`]: https://rspec.info/features/7-1/rspec-rails/matchers/have-enqueued-job-matcher
|
223
220
|
|
224
221
|
### What else does RSpec Rails add?
|
225
222
|
|
226
223
|
For a comprehensive look at RSpec Rails’ features,
|
227
224
|
read the [official Cucumber documentation][].
|
228
225
|
|
229
|
-
[official Cucumber documentation]: https://rspec.info/features/7-
|
226
|
+
[official Cucumber documentation]: https://rspec.info/features/7-1/rspec-rails
|
230
227
|
|
231
228
|
## What tests should I write?
|
232
229
|
|
@@ -271,20 +268,20 @@ RSpec.describe User, type: :model do
|
|
271
268
|
...
|
272
269
|
```
|
273
270
|
|
274
|
-
[request]: https://rspec.info/features/7-
|
275
|
-
[feature]: https://rspec.info/features/7-
|
276
|
-
[system]: https://rspec.info/features/7-
|
277
|
-
[model]: https://rspec.info/features/7-
|
278
|
-
[controller]: https://rspec.info/features/7-
|
279
|
-
[mailer]: https://rspec.info/features/7-
|
280
|
-
[job]: https://rspec.info/features/7-
|
281
|
-
[view]: https://rspec.info/features/7-
|
282
|
-
[routing]: https://rspec.info/features/7-
|
283
|
-
[helper]: https://rspec.info/features/7-
|
271
|
+
[request]: https://rspec.info/features/7-1/rspec-rails/request-specs/request-spec
|
272
|
+
[feature]: https://rspec.info/features/7-1/rspec-rails/feature-specs/feature-spec
|
273
|
+
[system]: https://rspec.info/features/7-1/rspec-rails/system-specs/system-specs
|
274
|
+
[model]: https://rspec.info/features/7-1/rspec-rails/model-specs
|
275
|
+
[controller]: https://rspec.info/features/7-1/rspec-rails/controller-specs
|
276
|
+
[mailer]: https://rspec.info/features/7-1/rspec-rails/mailer-specs
|
277
|
+
[job]: https://rspec.info/features/7-1/rspec-rails/job-specs/job-spec
|
278
|
+
[view]: https://rspec.info/features/7-1/rspec-rails/view-specs/view-spec
|
279
|
+
[routing]: https://rspec.info/features/7-1/rspec-rails/routing-specs
|
280
|
+
[helper]: https://rspec.info/features/7-1/rspec-rails/helper-specs/helper-spec
|
284
281
|
[`ActionDispatch::IntegrationTest`]: https://api.rubyonrails.org/classes/ActionDispatch/IntegrationTest.html
|
285
282
|
[`ActionDispatch::SystemTestCase`]: https://api.rubyonrails.org/classes/ActionDispatch/SystemTestCase.html
|
286
283
|
[`ActionController::TestCase`]: https://api.rubyonrails.org/classes/ActionController/TestCase.html
|
287
|
-
[in the appropriate folder]: https://rspec.info/features/7-
|
284
|
+
[in the appropriate folder]: https://rspec.info/features/7-1/rspec-rails/directory-structure
|
288
285
|
|
289
286
|
### System specs, feature specs, request specs–what’s the difference?
|
290
287
|
|
@@ -67,20 +67,22 @@ RSpec.configure do |config|
|
|
67
67
|
# config.use_transactional_fixtures = true
|
68
68
|
|
69
69
|
<% end -%>
|
70
|
-
# RSpec Rails
|
71
|
-
#
|
72
|
-
# `post` in specs under `spec/controllers`.
|
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.:
|
73
72
|
#
|
74
|
-
#
|
75
|
-
# explicitly tag your specs with their type, e.g.:
|
76
|
-
#
|
77
|
-
# RSpec.describe UsersController, type: :controller do
|
73
|
+
# RSpec.describe UsersController, type: :request do
|
78
74
|
# # ...
|
79
75
|
# end
|
80
76
|
#
|
81
77
|
# The different available types are documented in the features, such as in
|
82
|
-
# https://rspec.info/features/7-
|
83
|
-
|
78
|
+
# https://rspec.info/features/7-1/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!
|
84
86
|
|
85
87
|
# Filter lines from Rails gems in backtraces.
|
86
88
|
config.filter_rails_from_backtrace!
|
@@ -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
|
|
@@ -178,6 +178,8 @@ module RSpec
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def detect_args_signature_mismatch(jobs)
|
181
|
+
return if skip_signature_verification?
|
182
|
+
|
181
183
|
jobs.each do |job|
|
182
184
|
args = deserialize_arguments(job)
|
183
185
|
|
@@ -189,6 +191,13 @@ module RSpec
|
|
189
191
|
nil
|
190
192
|
end
|
191
193
|
|
194
|
+
def skip_signature_verification?
|
195
|
+
return true unless defined?(::RSpec::Mocks) && (::RSpec::Mocks.respond_to?(:configuration))
|
196
|
+
|
197
|
+
!RSpec::Mocks.configuration.verify_partial_doubles? ||
|
198
|
+
RSpec::Mocks.configuration.temporarily_suppress_partial_double_verification
|
199
|
+
end
|
200
|
+
|
192
201
|
def check_args_signature_mismatch(job_class, job_method, args)
|
193
202
|
signature = Support::MethodSignature.new(job_class.public_instance_method(job_method))
|
194
203
|
verifier = Support::StrictSignatureVerifier.new(signature, args)
|
@@ -72,7 +72,7 @@ module RSpec
|
|
72
72
|
@mailer_class ? @mailer_class.name : 'ActionMailer::Base'
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
75
|
+
def job_matches?(job)
|
76
76
|
legacy_mail?(job) || parameterized_mail?(job) || unified_mail?(job)
|
77
77
|
end
|
78
78
|
|
@@ -93,6 +93,7 @@ module RSpec
|
|
93
93
|
|
94
94
|
def detect_args_signature_mismatch(jobs)
|
95
95
|
return if @method_name.nil?
|
96
|
+
return if skip_signature_verification?
|
96
97
|
|
97
98
|
mailer_class = mailer_class_name.constantize
|
98
99
|
|
@@ -123,18 +124,18 @@ module RSpec
|
|
123
124
|
|
124
125
|
def unmatching_mail_jobs
|
125
126
|
@unmatching_jobs.select do |job|
|
126
|
-
|
127
|
+
job_matches?(job)
|
127
128
|
end
|
128
129
|
end
|
129
130
|
|
130
131
|
def unmatching_mail_jobs_message
|
131
|
-
|
132
|
+
messages = ["Queued deliveries:"]
|
132
133
|
|
133
134
|
unmatching_mail_jobs.each do |job|
|
134
|
-
|
135
|
+
messages << " #{mail_job_message(job)}"
|
135
136
|
end
|
136
137
|
|
137
|
-
|
138
|
+
messages.join("\n")
|
138
139
|
end
|
139
140
|
|
140
141
|
def mail_job_message(job)
|
data/lib/rspec/rails/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,21 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chelimsky
|
8
8
|
- Andy Lindeman
|
9
|
-
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain:
|
12
11
|
- |
|
13
12
|
-----BEGIN CERTIFICATE-----
|
14
|
-
|
13
|
+
MIIFvjCCA6agAwIBAgIJAPXjfUbCjdXVMA0GCSqGSIb3DQEBCwUAMIGAMQswCQYD
|
15
14
|
VQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEO
|
16
15
|
MAwGA1UECgwFUlNwZWMxEzARBgNVBAMMCnJzcGVjLmluZm8xJTAjBgkqhkiG9w0B
|
17
|
-
|
18
|
-
|
16
|
+
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NtlhNFY6+tTwCeblwZbcuYGyGY8+Rg7GbyVl
|
36
|
+
3Tr4Gi1aS/qG/MDXKdE8HWm39dmaAMdbw6dg1VBd0JrX2VqH7xvE1dM/D3OlKrNp
|
37
|
+
gNFRNJig3Y8qPjocZR0cGkhgZoC9wribWxHSNawZm4CoV3fja2HNx9QyM7BaB+as
|
38
|
+
yuqAiBbA7vBcyc8nKATip3mxbyXYXoDD7nmO8JCPP7O/WsgG+U/B2a0kPdvYFoxE
|
39
|
+
Q0Js3GtFCuMvL+0rifqdxBOLtu0Pw9q4RvToTJIl2IR6eTgCb82B1hw9qKf7PjuL
|
40
|
+
BoEsYjjDhGw6FZvcJG8O6uj7aB+z4aF21YR74UGL7sq/RIPNNez5JI95jTGfqCPy
|
41
|
+
6yo0w3zja3yg28QK3Fj+tbOHeSLv9SDQWi/1jiPprGzbxGvbVvjvX11YZc46vkmY
|
42
|
+
AwP+qZPPf97FXXZGEGIYhhHpnj+Ltx9nCetRPiZ4rvYBcXgCWVQSg6eiEofrMwn/
|
43
|
+
AKMCABhZ1Y2eATsfMgdkmIZk7JIPZiSi6eUxPiCMP9M/pw==
|
46
44
|
-----END CERTIFICATE-----
|
47
|
-
date:
|
45
|
+
date: 2025-02-06 00:00:00.000000000 Z
|
48
46
|
dependencies:
|
49
47
|
- !ruby/object:Gem::Dependency
|
50
48
|
name: actionpack
|
@@ -176,14 +174,14 @@ dependencies:
|
|
176
174
|
name: cucumber
|
177
175
|
requirement: !ruby/object:Gem::Requirement
|
178
176
|
requirements:
|
179
|
-
- - "
|
177
|
+
- - ">"
|
180
178
|
- !ruby/object:Gem::Version
|
181
179
|
version: '7.0'
|
182
180
|
type: :development
|
183
181
|
prerelease: false
|
184
182
|
version_requirements: !ruby/object:Gem::Requirement
|
185
183
|
requirements:
|
186
|
-
- - "
|
184
|
+
- - ">"
|
187
185
|
- !ruby/object:Gem::Version
|
188
186
|
version: '7.0'
|
189
187
|
description: rspec-rails integrates the Rails testing helpers into RSpec.
|
@@ -296,11 +294,10 @@ licenses:
|
|
296
294
|
- MIT
|
297
295
|
metadata:
|
298
296
|
bug_tracker_uri: https://github.com/rspec/rspec-rails/issues
|
299
|
-
changelog_uri: https://github.com/rspec/rspec-rails/blob/v7.
|
297
|
+
changelog_uri: https://github.com/rspec/rspec-rails/blob/v7.1.1/Changelog.md
|
300
298
|
documentation_uri: https://rspec.info/documentation/
|
301
299
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
302
300
|
source_code_uri: https://github.com/rspec/rspec-rails
|
303
|
-
post_install_message:
|
304
301
|
rdoc_options:
|
305
302
|
- "--charset=UTF-8"
|
306
303
|
require_paths:
|
@@ -316,8 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
313
|
- !ruby/object:Gem::Version
|
317
314
|
version: '0'
|
318
315
|
requirements: []
|
319
|
-
rubygems_version: 3.
|
320
|
-
signing_key:
|
316
|
+
rubygems_version: 3.6.2
|
321
317
|
specification_version: 4
|
322
318
|
summary: RSpec for Rails
|
323
319
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|