rspec-rails 7.1.0 → 8.0.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 +235 -214
- data/README.md +29 -33
- 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 +7 -7
- data/lib/rspec/rails/configuration.rb +3 -67
- data/lib/rspec/rails/example/system_example_group.rb +38 -41
- 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 +2 -0
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +3 -3
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec-rails.rb +3 -11
- data.tar.gz.sig +0 -0
- metadata +32 -33
- metadata.gz.sig +0 -0
data/README.md
CHANGED
@@ -9,6 +9,7 @@ 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` 8.x][]** for Rails 8.0 or 7.2.
|
12
13
|
* **[`rspec-rails` 7.x][]** for Rails 7.x.
|
13
14
|
* **[`rspec-rails` 6.x][]** for Rails 6.1, 7.0 or 7.1.
|
14
15
|
* **[`rspec-rails` 5.x][]** for Rails 5.2 or 6.x.
|
@@ -27,14 +28,15 @@ According to [RSpec Rails new versioning strategy][] use:
|
|
27
28
|
[`rspec-rails` 4.x]: https://github.com/rspec/rspec-rails/tree/4-1-maintenance
|
28
29
|
[`rspec-rails` 5.x]: https://github.com/rspec/rspec-rails/tree/5-1-maintenance
|
29
30
|
[`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-
|
31
|
+
[`rspec-rails` 7.x]: https://github.com/rspec/rspec-rails/tree/7-1-maintenance
|
32
|
+
[`rspec-rails` 8.x]: https://github.com/rspec/rspec-rails/tree/8-0-maintenance
|
31
33
|
[RSpec Rails new versioning strategy]: https://github.com/rspec/rspec-rails/blob/main/rfcs/versioning-strategy.md
|
32
34
|
|
33
35
|
## Installation
|
34
36
|
|
35
|
-
**IMPORTANT** This README / branch refers to the
|
37
|
+
**IMPORTANT** This README / branch refers to the 8.0.x stable release series, only bugfixes from this series will
|
36
38
|
be added here. See the [`main` branch on Github](https://github.com/rspec/rspec-rails/tree/main) if you want or
|
37
|
-
require the latest unstable features.
|
39
|
+
require the latest unstable features.https://github.com/rspec/rspec-rails/tree/8-0-maintenance) if you want or require the latest stable release.
|
38
40
|
|
39
41
|
1. Add `rspec-rails` to **both** the `:development` and `:test` groups
|
40
42
|
of your app’s `Gemfile`:
|
@@ -42,15 +44,12 @@ require the latest unstable features.
|
|
42
44
|
```ruby
|
43
45
|
# Run against this stable release
|
44
46
|
group :development, :test do
|
45
|
-
gem 'rspec-rails', '~>
|
47
|
+
gem 'rspec-rails', '~> 8.0.0'
|
46
48
|
end
|
47
49
|
|
48
50
|
# Or, run against the main branch
|
49
|
-
# (requires main-branch versions of all related RSpec libraries)
|
50
51
|
group :development, :test do
|
51
|
-
|
52
|
-
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'main'
|
53
|
-
end
|
52
|
+
gem 'rspec-rails', git: 'https://github.com/rspec/rspec-rails'
|
54
53
|
end
|
55
54
|
```
|
56
55
|
|
@@ -89,7 +88,7 @@ read the [`rspec-rails` upgrade notes][] to find out what to watch out for.
|
|
89
88
|
|
90
89
|
Be sure to check the general [RSpec upgrade notes][] as well.
|
91
90
|
|
92
|
-
[`rspec-rails` upgrade notes]: https://rspec.info/features/
|
91
|
+
[`rspec-rails` upgrade notes]: https://rspec.info/features/8-0/rspec-rails/upgrade
|
93
92
|
[RSpec upgrade notes]: https://rspec.info/upgrading-from-rspec-2/
|
94
93
|
|
95
94
|
## Usage
|
@@ -211,22 +210,22 @@ to test the various parts of a Rails system:
|
|
211
210
|
Follow the links above for examples of how each matcher is used.
|
212
211
|
|
213
212
|
[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/
|
215
|
-
[`render_template`]: https://rspec.info/features/
|
216
|
-
[`redirect_to`]: https://rspec.info/features/
|
217
|
-
[`route_to`]: https://rspec.info/features/
|
218
|
-
[`be_routable`]: https://rspec.info/features/
|
219
|
-
[`have_http_status`]: https://rspec.info/features/
|
220
|
-
[`match_array`]: https://rspec.info/features/
|
221
|
-
[`have_been_enqueued`]: https://rspec.info/features/
|
222
|
-
[`have_enqueued_job`]: https://rspec.info/features/
|
213
|
+
[`be_a_new`]: https://rspec.info/features/8-0/rspec-rails/matchers/new-record-matcher
|
214
|
+
[`render_template`]: https://rspec.info/features/8-0/rspec-rails/matchers/render-template-matcher
|
215
|
+
[`redirect_to`]: https://rspec.info/features/8-0/rspec-rails/matchers/redirect-to-matcher
|
216
|
+
[`route_to`]: https://rspec.info/features/8-0/rspec-rails/routing-specs/route-to-matcher
|
217
|
+
[`be_routable`]: https://rspec.info/features/8-0/rspec-rails/routing-specs/be-routable-matcher
|
218
|
+
[`have_http_status`]: https://rspec.info/features/8-0/rspec-rails/matchers/have-http-status-matcher
|
219
|
+
[`match_array`]: https://rspec.info/features/8-0/rspec-rails/matchers/relation-match-array
|
220
|
+
[`have_been_enqueued`]: https://rspec.info/features/8-0/rspec-rails/matchers/have-been-enqueued-matcher
|
221
|
+
[`have_enqueued_job`]: https://rspec.info/features/8-0/rspec-rails/matchers/have-enqueued-job-matcher
|
223
222
|
|
224
223
|
### What else does RSpec Rails add?
|
225
224
|
|
226
225
|
For a comprehensive look at RSpec Rails’ features,
|
227
226
|
read the [official Cucumber documentation][].
|
228
227
|
|
229
|
-
[official Cucumber documentation]: https://rspec.info/features/
|
228
|
+
[official Cucumber documentation]: https://rspec.info/features/8-0/rspec-rails
|
230
229
|
|
231
230
|
## What tests should I write?
|
232
231
|
|
@@ -271,20 +270,20 @@ RSpec.describe User, type: :model do
|
|
271
270
|
...
|
272
271
|
```
|
273
272
|
|
274
|
-
[request]: https://rspec.info/features/
|
275
|
-
[feature]: https://rspec.info/features/
|
276
|
-
[system]: https://rspec.info/features/
|
277
|
-
[model]: https://rspec.info/features/
|
278
|
-
[controller]: https://rspec.info/features/
|
279
|
-
[mailer]: https://rspec.info/features/
|
280
|
-
[job]: https://rspec.info/features/
|
281
|
-
[view]: https://rspec.info/features/
|
282
|
-
[routing]: https://rspec.info/features/
|
283
|
-
[helper]: https://rspec.info/features/
|
273
|
+
[request]: https://rspec.info/features/8-0/rspec-rails/request-specs/request-spec
|
274
|
+
[feature]: https://rspec.info/features/8-0/rspec-rails/feature-specs/feature-spec
|
275
|
+
[system]: https://rspec.info/features/8-0/rspec-rails/system-specs/system-specs
|
276
|
+
[model]: https://rspec.info/features/8-0/rspec-rails/model-specs
|
277
|
+
[controller]: https://rspec.info/features/8-0/rspec-rails/controller-specs
|
278
|
+
[mailer]: https://rspec.info/features/8-0/rspec-rails/mailer-specs
|
279
|
+
[job]: https://rspec.info/features/8-0/rspec-rails/job-specs/job-spec
|
280
|
+
[view]: https://rspec.info/features/8-0/rspec-rails/view-specs/view-spec
|
281
|
+
[routing]: https://rspec.info/features/8-0/rspec-rails/routing-specs
|
282
|
+
[helper]: https://rspec.info/features/8-0/rspec-rails/helper-specs/helper-spec
|
284
283
|
[`ActionDispatch::IntegrationTest`]: https://api.rubyonrails.org/classes/ActionDispatch/IntegrationTest.html
|
285
284
|
[`ActionDispatch::SystemTestCase`]: https://api.rubyonrails.org/classes/ActionDispatch/SystemTestCase.html
|
286
285
|
[`ActionController::TestCase`]: https://api.rubyonrails.org/classes/ActionController/TestCase.html
|
287
|
-
[in the appropriate folder]: https://rspec.info/features/
|
286
|
+
[in the appropriate folder]: https://rspec.info/features/8-0/rspec-rails/directory-structure
|
288
287
|
|
289
288
|
### System specs, feature specs, request specs–what’s the difference?
|
290
289
|
|
@@ -368,9 +367,6 @@ you can run the specs and Cucumber features, or submit a pull request.
|
|
368
367
|
### RSpec base libraries
|
369
368
|
|
370
369
|
* https://github.com/rspec/rspec
|
371
|
-
* https://github.com/rspec/rspec-core
|
372
|
-
* https://github.com/rspec/rspec-expectations
|
373
|
-
* https://github.com/rspec/rspec-mocks
|
374
370
|
|
375
371
|
### Recommended third-party extensions
|
376
372
|
|
@@ -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,7 +75,7 @@ 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
80
|
# You can also this infer these behaviours automatically by location, e.g.
|
81
81
|
# /spec/models would pull in the same behaviour as `type: :model` but this
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -192,6 +192,8 @@ module RSpec
|
|
192
192
|
end
|
193
193
|
|
194
194
|
def skip_signature_verification?
|
195
|
+
return true unless defined?(::RSpec::Mocks) && (::RSpec::Mocks.respond_to?(:configuration))
|
196
|
+
|
195
197
|
!RSpec::Mocks.configuration.verify_partial_doubles? ||
|
196
198
|
RSpec::Mocks.configuration.temporarily_suppress_partial_double_verification
|
197
199
|
end
|
@@ -129,13 +129,13 @@ module RSpec
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def unmatching_mail_jobs_message
|
132
|
-
|
132
|
+
messages = ["Queued deliveries:"]
|
133
133
|
|
134
134
|
unmatching_mail_jobs.each do |job|
|
135
|
-
|
135
|
+
messages << " #{mail_job_message(job)}"
|
136
136
|
end
|
137
137
|
|
138
|
-
|
138
|
+
messages.join("\n")
|
139
139
|
end
|
140
140
|
|
141
141
|
def mail_job_message(job)
|
data/lib/rspec/rails/version.rb
CHANGED
data/lib/rspec-rails.rb
CHANGED
@@ -64,18 +64,10 @@ module RSpec
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
return unless options.preview_paths.empty?
|
67
|
+
def config_default_preview_path(options)
|
68
|
+
return unless options.preview_paths.empty?
|
70
69
|
|
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
|
70
|
+
options.preview_paths << "#{::Rails.root}/spec/mailers/previews"
|
79
71
|
end
|
80
72
|
|
81
73
|
def supports_action_mailer_previews?(config)
|
data.tar.gz.sig
CHANGED
Binary file
|