rspec-rails 6.0.0.rc1 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Changelog.md +24 -5
- data/lib/generators/rspec/channel/channel_generator.rb +1 -1
- data/lib/generators/rspec/controller/controller_generator.rb +4 -4
- data/lib/generators/rspec/feature/feature_generator.rb +1 -1
- data/lib/generators/rspec/generator/generator_generator.rb +1 -1
- data/lib/generators/rspec/helper/helper_generator.rb +1 -1
- data/lib/generators/rspec/install/install_generator.rb +19 -2
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +1 -1
- data/lib/generators/rspec/integration/integration_generator.rb +10 -3
- data/lib/generators/rspec/job/job_generator.rb +1 -1
- data/lib/generators/rspec/mailbox/mailbox_generator.rb +1 -1
- data/lib/generators/rspec/mailer/mailer_generator.rb +3 -3
- data/lib/generators/rspec/model/model_generator.rb +3 -3
- data/lib/generators/rspec/request/request_generator.rb +10 -3
- data/lib/generators/rspec/{integration → request}/templates/request_spec.rb +0 -0
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +4 -4
- data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +8 -4
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +1 -1
- data/lib/generators/rspec/system/system_generator.rb +1 -1
- data/lib/generators/rspec/view/view_generator.rb +2 -2
- data/lib/generators/rspec.rb +18 -1
- data/lib/rspec/rails/adapters.rb +10 -0
- data/lib/rspec/rails/configuration.rb +12 -11
- data/lib/rspec/rails/example/rails_example_group.rb +1 -0
- data/lib/rspec/rails/example/system_example_group.rb +12 -11
- data/lib/rspec/rails/example/view_example_group.rb +1 -1
- data/lib/rspec/rails/feature_check.rb +1 -1
- data/lib/rspec/rails/fixture_file_upload_support.rb +13 -30
- data/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +1 -1
- data/lib/rspec/rails/matchers/active_job.rb +1 -1
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +1 -1
- data/lib/rspec/rails/matchers/have_http_status.rb +1 -1
- data/lib/rspec/rails/matchers/routing_matchers.rb +2 -2
- data/lib/rspec/rails/vendor/capybara.rb +1 -3
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_assigns.rb +0 -18
- data/lib/rspec/rails/view_rendering.rb +2 -8
- data/lib/rspec-rails.rb +1 -5
- data.tar.gz.sig +0 -0
- metadata +10 -22
- 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: f578abb8223c3c509323ce5d3204987a37ab32f238ed7f5c49eee24e283cd89d
|
4
|
+
data.tar.gz: 18afc82a8cb2ed0549a2c351980edfcf43b4fc3b1e49430e8b0c22deefb682a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b64e3d8ab94e864aa53cd14420763c47b2b841365c9c11a554b143082648dfe474ac2dc251c18a6c0bbe920c76bd6a4382d4ff124bb636ba4c6fd6ddf364523
|
7
|
+
data.tar.gz: 2d47dbae246f110999db1e27c551cd079838363727b1127cdf87ea36aae07651677b119765425e649abc897b6524ab9da170b95f0acf93309526f2fd7bd32c42
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,16 +1,35 @@
|
|
1
1
|
### Development
|
2
|
-
[Full Changelog](https://github.com/rspec/rspec-rails/compare/
|
2
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.0...6-0-maintenance)
|
3
3
|
|
4
|
-
### 6.0.0
|
4
|
+
### 6.0.0
|
5
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.1.2...6.0.0)
|
5
6
|
|
6
7
|
Enhancements:
|
7
8
|
|
8
9
|
* Support Rails 7
|
10
|
+
* Template tweaks to remove instance variables from generated specs. (Takuma Ishikawa, #2599)
|
11
|
+
* Generators now respects default path configuration option. (@vivekmiyani, #2508)
|
9
12
|
|
10
13
|
Breaking Changes:
|
11
14
|
|
12
15
|
* Drop support for Rails below 6.1
|
13
16
|
* Drop support for Ruby below 2.5 (following supported versions of Rails 6.1)
|
17
|
+
* Change the order of `after_teardown` from `after` to `around` in system
|
18
|
+
specs to improve compatibility with extensions and Capybara. (Tim Diggins, #2596)
|
19
|
+
|
20
|
+
Deprecations:
|
21
|
+
|
22
|
+
* Deprecates integration spec generator (`rspec:integration`)
|
23
|
+
which was an alias of request spec generator (`rspec:request`)
|
24
|
+
(Luka Lüdicke, #2374)
|
25
|
+
|
26
|
+
### 5.1.2 / 2022-04-24
|
27
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.1.1...v5.1.2)
|
28
|
+
|
29
|
+
Bug Fixes:
|
30
|
+
|
31
|
+
* Fix controller scaffold templates parameter name. (Taketo Takashima, #2591)
|
32
|
+
* Include generator specs in the inferred list of specs. (Jason Karns, #2597)
|
14
33
|
|
15
34
|
### 5.1.1 / 2022-03-07
|
16
35
|
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.1.0...v5.1.1)
|
@@ -85,7 +104,7 @@ Bug Fixes:
|
|
85
104
|
|
86
105
|
Enhancements:
|
87
106
|
|
88
|
-
* Issue a warning when using job matchers with `#at`
|
107
|
+
* Issue a warning when using job matchers with `#at` mismatch on `usec` precision.
|
89
108
|
(Jon Rowe, #2350)
|
90
109
|
* Generated request specs now have a bare `_spec` suffix instead of `request_spec`.
|
91
110
|
(Eloy Espinaco, Luka Lüdicke, #2355, #2356, #2378)
|
@@ -212,7 +231,7 @@ Bug Fixes:
|
|
212
231
|
|
213
232
|
Bug Fixes:
|
214
233
|
|
215
|
-
* Namespaced fixtures now generate a `/`
|
234
|
+
* Namespaced fixtures now generate a `/` separated path rather than an `_`.
|
216
235
|
(@nxlith, #2077)
|
217
236
|
* Check the arity of `errors` before attempting to use it to generate the `be_valid`
|
218
237
|
error message. (Kevin Kuchta, #2096)
|
@@ -372,7 +391,7 @@ Enhancements:
|
|
372
391
|
|
373
392
|
Bug fixes:
|
374
393
|
|
375
|
-
* Prevent asset helpers from taking
|
394
|
+
* Prevent asset helpers from taking precedence over route helpers. (Prem Sichanugrist, #1496)
|
376
395
|
* Prevent `NoMethodError` during failed `have_rendered` assertions on weird templates.
|
377
396
|
(Jon Rowe, #1623).
|
378
397
|
|
@@ -5,7 +5,7 @@ module Rspec
|
|
5
5
|
# @private
|
6
6
|
class ChannelGenerator < Base
|
7
7
|
def create_channel_spec
|
8
|
-
template 'channel_spec.rb.erb',
|
8
|
+
template 'channel_spec.rb.erb', target_path('channels', class_path, "#{file_name}_channel_spec.rb")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -16,14 +16,14 @@ module Rspec
|
|
16
16
|
return unless options[:request_specs]
|
17
17
|
|
18
18
|
template 'request_spec.rb',
|
19
|
-
|
19
|
+
target_path('requests', class_path, "#{file_name}_spec.rb")
|
20
20
|
end
|
21
21
|
|
22
22
|
def generate_controller_spec
|
23
23
|
return unless options[:controller_specs]
|
24
24
|
|
25
25
|
template 'controller_spec.rb',
|
26
|
-
|
26
|
+
target_path('controllers', class_path, "#{file_name}_controller_spec.rb")
|
27
27
|
end
|
28
28
|
|
29
29
|
def generate_view_specs
|
@@ -35,7 +35,7 @@ module Rspec
|
|
35
35
|
actions.each do |action|
|
36
36
|
@action = action
|
37
37
|
template 'view_spec.rb',
|
38
|
-
|
38
|
+
target_path('views', file_path, "#{@action}.html.#{options[:template_engine]}_spec.rb")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -44,7 +44,7 @@ module Rspec
|
|
44
44
|
return unless options[:routing_specs]
|
45
45
|
|
46
46
|
template 'routing_spec.rb',
|
47
|
-
|
47
|
+
target_path('routing', class_path, "#{file_name}_routing_spec.rb")
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -10,7 +10,7 @@ module Rspec
|
|
10
10
|
def generate_feature_spec
|
11
11
|
return unless options[:feature_specs]
|
12
12
|
|
13
|
-
template template_name,
|
13
|
+
template template_name, target_path('features', class_path, filename)
|
14
14
|
end
|
15
15
|
|
16
16
|
def template_name
|
@@ -9,7 +9,7 @@ module Rspec
|
|
9
9
|
def generate_generator_spec
|
10
10
|
return unless options[:generator_specs]
|
11
11
|
|
12
|
-
template template_name,
|
12
|
+
template template_name, target_path('generator', class_path, filename)
|
13
13
|
end
|
14
14
|
|
15
15
|
def template_name
|
@@ -9,7 +9,7 @@ module Rspec
|
|
9
9
|
def generate_helper_spec
|
10
10
|
return unless options[:helper_specs]
|
11
11
|
|
12
|
-
template 'helper_spec.rb',
|
12
|
+
template 'helper_spec.rb', target_path('helpers', class_path, "#{file_name}_helper_spec.rb")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -12,6 +12,8 @@ Description:
|
|
12
12
|
Copy rspec files to your application.
|
13
13
|
DESC
|
14
14
|
|
15
|
+
class_option :default_path, type: :string, default: 'spec'
|
16
|
+
|
15
17
|
def self.source_root
|
16
18
|
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
17
19
|
end
|
@@ -20,12 +22,12 @@ DESC
|
|
20
22
|
Dir.mktmpdir do |dir|
|
21
23
|
generate_rspec_init dir
|
22
24
|
template File.join(dir, '.rspec'), '.rspec'
|
23
|
-
directory File.join(dir, 'spec'),
|
25
|
+
directory File.join(dir, 'spec'), default_path
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
def copy_rails_files
|
28
|
-
template 'spec/rails_helper.rb'
|
30
|
+
template 'spec/rails_helper.rb', "#{default_path}/rails_helper.rb"
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
@@ -41,6 +43,12 @@ DESC
|
|
41
43
|
|
42
44
|
replace_generator_command(spec_helper_path)
|
43
45
|
remove_warnings_configuration(spec_helper_path)
|
46
|
+
|
47
|
+
unless default_path == "spec"
|
48
|
+
dot_rspec_path = File.join(tmpdir, '.rspec')
|
49
|
+
|
50
|
+
append_default_path(dot_rspec_path)
|
51
|
+
end
|
44
52
|
end
|
45
53
|
|
46
54
|
def replace_generator_command(spec_helper_path)
|
@@ -58,6 +66,15 @@ DESC
|
|
58
66
|
'',
|
59
67
|
verbose: false
|
60
68
|
end
|
69
|
+
|
70
|
+
def append_default_path(dot_rspec_path)
|
71
|
+
append_to_file dot_rspec_path,
|
72
|
+
"--default-path #{default_path}"
|
73
|
+
end
|
74
|
+
|
75
|
+
def default_path
|
76
|
+
options[:default_path]
|
77
|
+
end
|
61
78
|
end
|
62
79
|
end
|
63
80
|
end
|
@@ -48,7 +48,7 @@ RSpec.configure do |config|
|
|
48
48
|
# Remove this line to enable support for ActiveRecord
|
49
49
|
config.use_active_record = false
|
50
50
|
|
51
|
-
# If you enable ActiveRecord support you should
|
51
|
+
# If you enable ActiveRecord support you should uncomment these lines,
|
52
52
|
# note if you'd prefer not to run each example within a transaction, you
|
53
53
|
# should set use_transactional_fixtures to false.
|
54
54
|
#
|
@@ -1,21 +1,28 @@
|
|
1
1
|
require 'generators/rspec'
|
2
|
+
require 'rspec/core/warnings'
|
2
3
|
|
3
4
|
module Rspec
|
4
5
|
module Generators
|
5
6
|
# @private
|
6
7
|
class IntegrationGenerator < Base
|
7
|
-
# Add a deprecation for this class, before rspec-rails 4, to use the
|
8
|
-
# `RequestGenerator` instead
|
9
8
|
class_option :request_specs,
|
10
9
|
type: :boolean,
|
11
10
|
default: true,
|
12
11
|
desc: "Generate request specs"
|
13
12
|
|
13
|
+
source_paths << File.expand_path('../request/templates', __dir__)
|
14
|
+
|
14
15
|
def generate_request_spec
|
15
16
|
return unless options[:request_specs]
|
16
17
|
|
18
|
+
RSpec.warn_deprecation <<-WARNING.gsub(/\s*\|/, ' ')
|
19
|
+
|The integration generator is deprecated
|
20
|
+
|and will be deleted in RSpec-Rails 7.
|
21
|
+
|Please use the request generator instead.
|
22
|
+
WARNING
|
23
|
+
|
17
24
|
template 'request_spec.rb',
|
18
|
-
|
25
|
+
target_path('requests', "#{name.underscore.pluralize}_spec.rb")
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
@@ -6,7 +6,7 @@ module Rspec
|
|
6
6
|
class JobGenerator < Base
|
7
7
|
def create_job_spec
|
8
8
|
file_suffix = file_name.end_with?('job') ? 'spec.rb' : 'job_spec.rb'
|
9
|
-
template 'job_spec.rb.erb',
|
9
|
+
template 'job_spec.rb.erb', target_path('jobs', class_path, [file_name, file_suffix].join('_'))
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -6,7 +6,7 @@ module Rspec
|
|
6
6
|
class MailboxGenerator < Base
|
7
7
|
def create_mailbox_spec
|
8
8
|
template('mailbox_spec.rb.erb',
|
9
|
-
|
9
|
+
target_path('mailboxes', class_path, "#{file_name}_mailbox_spec.rb")
|
10
10
|
)
|
11
11
|
end
|
12
12
|
end
|
@@ -8,20 +8,20 @@ module Rspec
|
|
8
8
|
argument :actions, type: :array, default: [], banner: "method method"
|
9
9
|
|
10
10
|
def generate_mailer_spec
|
11
|
-
template "mailer_spec.rb",
|
11
|
+
template "mailer_spec.rb", target_path('mailers', class_path, "#{file_name}_spec.rb")
|
12
12
|
end
|
13
13
|
|
14
14
|
def generate_fixtures_files
|
15
15
|
actions.each do |action|
|
16
16
|
@action, @path = action, File.join(file_path, action)
|
17
|
-
template "fixture",
|
17
|
+
template "fixture", target_path("fixtures", @path)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
def generate_preview_files
|
22
22
|
return unless RSpec::Rails::FeatureCheck.has_action_mailer_preview?
|
23
23
|
|
24
|
-
template "preview.rb",
|
24
|
+
template "preview.rb", target_path("mailers/previews", class_path, "#{file_name}_preview.rb")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -11,8 +11,8 @@ module Rspec
|
|
11
11
|
class_option :fixture, type: :boolean
|
12
12
|
|
13
13
|
def create_model_spec
|
14
|
-
template_file =
|
15
|
-
'
|
14
|
+
template_file = target_path(
|
15
|
+
'models',
|
16
16
|
class_path,
|
17
17
|
"#{file_name}_spec.rb"
|
18
18
|
)
|
@@ -24,7 +24,7 @@ module Rspec
|
|
24
24
|
def create_fixture_file
|
25
25
|
return unless missing_fixture_replacement?
|
26
26
|
|
27
|
-
template 'fixtures.yml',
|
27
|
+
template 'fixtures.yml', target_path('fixtures', class_path, "#{(pluralize_table_names? ? plural_file_name : file_name)}.yml")
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
@@ -1,10 +1,17 @@
|
|
1
|
-
require 'generators/rspec
|
1
|
+
require 'generators/rspec'
|
2
2
|
|
3
3
|
module Rspec
|
4
4
|
module Generators
|
5
5
|
# @private
|
6
|
-
class RequestGenerator <
|
7
|
-
|
6
|
+
class RequestGenerator < Base
|
7
|
+
class_option :request_specs, type: :boolean, default: true, desc: 'Generate request specs'
|
8
|
+
|
9
|
+
def generate_request_spec
|
10
|
+
return unless options[:request_specs]
|
11
|
+
|
12
|
+
template 'request_spec.rb',
|
13
|
+
target_path('requests', "#{name.underscore.pluralize}_spec.rb")
|
14
|
+
end
|
8
15
|
end
|
9
16
|
end
|
10
17
|
end
|
File without changes
|
@@ -58,8 +58,8 @@ module Rspec
|
|
58
58
|
def generate_routing_spec
|
59
59
|
return unless options[:routing_specs]
|
60
60
|
|
61
|
-
template_file =
|
62
|
-
'
|
61
|
+
template_file = target_path(
|
62
|
+
'routing',
|
63
63
|
controller_class_path,
|
64
64
|
"#{controller_file_name}_routing_spec.rb"
|
65
65
|
)
|
@@ -72,7 +72,7 @@ module Rspec
|
|
72
72
|
|
73
73
|
def copy_view(view)
|
74
74
|
template "#{view}_spec.rb",
|
75
|
-
|
75
|
+
target_path("views", controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
|
76
76
|
end
|
77
77
|
|
78
78
|
# support for namespaced-resources
|
@@ -121,7 +121,7 @@ module Rspec
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def template_file(folder:, suffix: '')
|
124
|
-
|
124
|
+
target_path(folder, controller_class_path, "#{controller_file_name}#{suffix}_spec.rb")
|
125
125
|
end
|
126
126
|
|
127
127
|
def banner
|
@@ -100,7 +100,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
100
100
|
|
101
101
|
it "renders a JSON response with the <%= singular_table_name %>" do
|
102
102
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
103
|
-
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>:
|
103
|
+
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: new_attributes}, session: valid_session
|
104
104
|
expect(response).to have_http_status(:ok)
|
105
105
|
expect(response.content_type).to eq('application/json')
|
106
106
|
end
|
@@ -119,7 +119,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
119
119
|
|
120
120
|
it "redirects to the <%= singular_table_name %>" do
|
121
121
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
122
|
-
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>:
|
122
|
+
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: new_attributes}, session: valid_session
|
123
123
|
expect(response).to redirect_to(<%= file_name %>)
|
124
124
|
end
|
125
125
|
end
|
@@ -2,18 +2,22 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
|
4
4
|
RSpec.describe "<%= ns_table_name %>/edit", <%= type_metatag(:view) %> do
|
5
|
-
|
6
|
-
|
5
|
+
let(:<%= ns_file_name %>) {
|
6
|
+
<%= class_name %>.create!(<%= ')' if output_attributes.empty? %>
|
7
7
|
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
8
8
|
<%= attribute.name %>: <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
9
9
|
<% end -%>
|
10
|
-
<%=
|
10
|
+
<%= " )\n" unless output_attributes.empty? -%>
|
11
|
+
}
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
assign(:<%= ns_file_name %>, <%= ns_file_name %>)
|
11
15
|
end
|
12
16
|
|
13
17
|
it "renders the edit <%= ns_file_name %> form" do
|
14
18
|
render
|
15
19
|
|
16
|
-
assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(
|
20
|
+
assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(<%= ns_file_name %>), "post" do
|
17
21
|
<% for attribute in output_attributes -%>
|
18
22
|
<%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %>
|
19
23
|
assert_select "<%= attribute.input_type -%>[name=?]", "<%= ns_file_name %>[<%= name %>]"
|
@@ -3,7 +3,7 @@ require 'rails_helper'
|
|
3
3
|
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
|
4
4
|
RSpec.describe "<%= ns_table_name %>/show", <%= type_metatag(:view) %> do
|
5
5
|
before(:each) do
|
6
|
-
|
6
|
+
assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
|
7
7
|
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
8
8
|
<%= attribute.name %>: <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
9
9
|
<% end -%>
|
@@ -9,12 +9,12 @@ module Rspec
|
|
9
9
|
class_option :template_engine, desc: "Template engine to generate view files"
|
10
10
|
|
11
11
|
def create_view_specs
|
12
|
-
empty_directory
|
12
|
+
empty_directory target_path("views", file_path)
|
13
13
|
|
14
14
|
actions.each do |action|
|
15
15
|
@action = action
|
16
16
|
template 'view_spec.rb',
|
17
|
-
|
17
|
+
target_path("views", file_path, "#{@action}.html.#{options[:template_engine]}_spec.rb")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/generators/rspec.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'rails/generators/named_base'
|
2
|
+
require 'rspec/core'
|
2
3
|
require 'rspec/rails/feature_check'
|
3
4
|
|
4
5
|
# @private
|
5
|
-
# Weirdly named generators namespace (should be `RSpec`) for
|
6
|
+
# Weirdly named generators namespace (should be `RSpec`) for compatibility with
|
6
7
|
# rails loading.
|
7
8
|
module Rspec
|
8
9
|
# @private
|
@@ -18,6 +19,22 @@ module Rspec
|
|
18
19
|
@_rspec_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'rspec', generator_name, 'templates'))
|
19
20
|
end
|
20
21
|
end
|
22
|
+
|
23
|
+
# @private
|
24
|
+
# Load configuration from RSpec to ensure `--default-path` is set
|
25
|
+
def self.configuration
|
26
|
+
@configuration ||=
|
27
|
+
begin
|
28
|
+
configuration = RSpec.configuration
|
29
|
+
options = RSpec::Core::ConfigurationOptions.new({})
|
30
|
+
options.configure(configuration)
|
31
|
+
configuration
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def target_path(*paths)
|
36
|
+
File.join(self.class.configuration.default_path, *paths)
|
37
|
+
end
|
21
38
|
end
|
22
39
|
end
|
23
40
|
end
|
data/lib/rspec/rails/adapters.rb
CHANGED
@@ -181,5 +181,15 @@ module RSpec
|
|
181
181
|
#
|
182
182
|
# @private
|
183
183
|
TestUnitAssertionAdapter = MinitestAssertionAdapter
|
184
|
+
|
185
|
+
# @private
|
186
|
+
module TaggedLoggingAdapter
|
187
|
+
require 'active_support/testing/tagged_logging'
|
188
|
+
include ActiveSupport::Testing::TaggedLogging
|
189
|
+
|
190
|
+
# Just a stub as TaggedLogging is calling `name`
|
191
|
+
def name
|
192
|
+
end
|
193
|
+
end
|
184
194
|
end
|
185
195
|
end
|
@@ -26,18 +26,19 @@ module RSpec
|
|
26
26
|
#
|
27
27
|
# @api private
|
28
28
|
DIRECTORY_MAPPINGS = {
|
29
|
-
channel:
|
29
|
+
channel: %w[spec channels],
|
30
30
|
controller: %w[spec controllers],
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
31
|
+
generator: %w[spec generator],
|
32
|
+
helper: %w[spec helpers],
|
33
|
+
job: %w[spec jobs],
|
34
|
+
mailer: %w[spec mailers],
|
35
|
+
model: %w[spec models],
|
36
|
+
request: %w[spec (requests|integration|api)],
|
37
|
+
routing: %w[spec routing],
|
38
|
+
view: %w[spec views],
|
39
|
+
feature: %w[spec features],
|
40
|
+
system: %w[spec system],
|
41
|
+
mailbox: %w[spec mailboxes]
|
41
42
|
}
|
42
43
|
|
43
44
|
# Sets up the different example group modules for the different spec types
|
@@ -54,23 +54,22 @@ module RSpec
|
|
54
54
|
ActionDispatch::SystemTesting::Server.silence_puma = true
|
55
55
|
end
|
56
56
|
|
57
|
+
require 'action_dispatch/system_test_case'
|
58
|
+
|
57
59
|
begin
|
58
60
|
require 'capybara'
|
59
|
-
require 'action_dispatch/system_test_case'
|
60
61
|
rescue LoadError => e
|
61
62
|
abort """
|
62
63
|
LoadError: #{e.message}
|
63
|
-
System test integration
|
64
|
+
System test integration has a hard
|
64
65
|
dependency on a webserver and `capybara`, please add capybara to
|
65
66
|
your Gemfile and configure a webserver (e.g. `Capybara.server =
|
66
|
-
:
|
67
|
+
:puma`) before attempting to use system specs.
|
67
68
|
""".gsub(/\s+/, ' ').strip
|
68
69
|
end
|
69
70
|
|
70
|
-
|
71
|
-
|
72
|
-
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown)
|
73
|
-
end
|
71
|
+
original_before_teardown =
|
72
|
+
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown)
|
74
73
|
|
75
74
|
original_after_teardown =
|
76
75
|
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)
|
@@ -108,10 +107,7 @@ module RSpec
|
|
108
107
|
orig_stdout = $stdout
|
109
108
|
$stdout = StringIO.new
|
110
109
|
begin
|
111
|
-
|
112
|
-
original_before_teardown.bind(self).call
|
113
|
-
end
|
114
|
-
original_after_teardown.bind(self).call
|
110
|
+
original_before_teardown.bind(self).call
|
115
111
|
ensure
|
116
112
|
myio = $stdout
|
117
113
|
myio.rewind
|
@@ -119,6 +115,11 @@ module RSpec
|
|
119
115
|
$stdout = orig_stdout
|
120
116
|
end
|
121
117
|
end
|
118
|
+
|
119
|
+
around do |example|
|
120
|
+
example.run
|
121
|
+
original_after_teardown.bind(self).call
|
122
|
+
end
|
122
123
|
end
|
123
124
|
end
|
124
125
|
end
|
@@ -149,7 +149,7 @@ module RSpec
|
|
149
149
|
# the original string.
|
150
150
|
match = path_regex.match(_default_file_to_render)
|
151
151
|
|
152
|
-
render_options = {template: match[:template]}
|
152
|
+
render_options = { template: match[:template] }
|
153
153
|
render_options[:handlers] = [match[:handler].to_sym] if match[:handler]
|
154
154
|
render_options[:formats] = [match[:format].to_sym] if match[:format]
|
155
155
|
render_options[:locales] = [match[:locale].to_sym] if match[:locale]
|
@@ -6,41 +6,24 @@ module RSpec
|
|
6
6
|
|
7
7
|
private
|
8
8
|
|
9
|
-
# In Rails
|
10
|
-
# was brought in with a deprecation warning on 6.1. In Rails
|
9
|
+
# In Rails 7.0 fixture file path needs to be relative to `file_fixture_path` instead, this change
|
10
|
+
# was brought in with a deprecation warning on 6.1. In Rails 7.0 expect to rework this to remove
|
11
11
|
# the old accessor.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
RailsFixtureFileWrapper.instance
|
23
|
-
end
|
24
|
-
else
|
25
|
-
def rails_fixture_file_wrapper
|
26
|
-
RailsFixtureFileWrapper.fixture_path = nil
|
27
|
-
resolved_fixture_path =
|
28
|
-
if respond_to?(:fixture_path) && !fixture_path.nil?
|
29
|
-
fixture_path.to_s
|
30
|
-
else
|
31
|
-
(RSpec.configuration.fixture_path || '').to_s
|
32
|
-
end
|
33
|
-
RailsFixtureFileWrapper.fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
|
34
|
-
RailsFixtureFileWrapper.instance
|
35
|
-
end
|
12
|
+
def rails_fixture_file_wrapper
|
13
|
+
RailsFixtureFileWrapper.file_fixture_path = nil
|
14
|
+
resolved_fixture_path =
|
15
|
+
if respond_to?(:file_fixture_path) && !file_fixture_path.nil?
|
16
|
+
file_fixture_path.to_s
|
17
|
+
else
|
18
|
+
(RSpec.configuration.fixture_path || '').to_s
|
19
|
+
end
|
20
|
+
RailsFixtureFileWrapper.file_fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
|
21
|
+
RailsFixtureFileWrapper.instance
|
36
22
|
end
|
37
23
|
|
38
24
|
class RailsFixtureFileWrapper
|
39
25
|
include ActionDispatch::TestProcess if defined?(ActionDispatch::TestProcess)
|
40
|
-
|
41
|
-
if ::Rails.version.to_f >= 6.1
|
42
|
-
include ActiveSupport::Testing::FileFixtures
|
43
|
-
end
|
26
|
+
include ActiveSupport::Testing::FileFixtures
|
44
27
|
|
45
28
|
class << self
|
46
29
|
attr_accessor :fixture_path
|
@@ -159,7 +159,7 @@ module RSpec
|
|
159
159
|
def check_channel_presence
|
160
160
|
return if @channel.present? && @channel.respond_to?(:channel_name)
|
161
161
|
|
162
|
-
error_msg = "Broadcasting channel can't be
|
162
|
+
error_msg = "Broadcasting channel can't be inferred. Please, specify it with `from_channel`"
|
163
163
|
raise ArgumentError, error_msg
|
164
164
|
end
|
165
165
|
end
|
@@ -181,7 +181,7 @@ module RSpec
|
|
181
181
|
|`Time.current.change(usec: 0)`
|
182
182
|
|
|
183
183
|
|Note: RSpec cannot do this for you because jobs can be scheduled with usec
|
184
|
-
|precision and we do not know
|
184
|
+
|precision and we do not know whether it is on purpose or not.
|
185
185
|
|
|
186
186
|
|
|
187
187
|
WARNING
|
@@ -134,7 +134,7 @@ module RSpec
|
|
134
134
|
end
|
135
135
|
|
136
136
|
# Ruby 3.1 changed how params were serialized on Rails 6.1
|
137
|
-
# so we override the active job implementation and
|
137
|
+
# so we override the active job implementation and customize it here.
|
138
138
|
def deserialize_arguments(job)
|
139
139
|
args = super
|
140
140
|
|
@@ -305,7 +305,7 @@ module RSpec
|
|
305
305
|
|
306
306
|
private
|
307
307
|
|
308
|
-
# @return [String]
|
308
|
+
# @return [String] formatting the expected status and associated code(s)
|
309
309
|
def type_message
|
310
310
|
@type_message ||= (expected == :error ? "an error" : "a #{expected}") +
|
311
311
|
" status code (#{type_codes})"
|
@@ -26,7 +26,7 @@ module RSpec
|
|
26
26
|
path, query = *verb_to_path_map.values.first.split('?')
|
27
27
|
@scope.assert_recognizes(
|
28
28
|
@expected,
|
29
|
-
{method: verb_to_path_map.keys.first, path: path},
|
29
|
+
{ method: verb_to_path_map.keys.first, path: path },
|
30
30
|
Rack::Utils.parse_nested_query(query)
|
31
31
|
)
|
32
32
|
end
|
@@ -115,7 +115,7 @@ module RSpec
|
|
115
115
|
# Shorthand method for matching this type of route.
|
116
116
|
%w[get post put patch delete options head].each do |method|
|
117
117
|
define_method method do |path|
|
118
|
-
{method.to_sym => path}
|
118
|
+
{ method.to_sym => path }
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -12,9 +12,7 @@ if defined?(Capybara)
|
|
12
12
|
RSpec.configure do |c|
|
13
13
|
if defined?(Capybara::DSL)
|
14
14
|
c.include Capybara::DSL, type: :feature
|
15
|
-
|
16
|
-
c.include Capybara::DSL, type: :system
|
17
|
-
end
|
15
|
+
c.include Capybara::DSL, type: :system
|
18
16
|
end
|
19
17
|
|
20
18
|
if defined?(Capybara::RSpecMatchers)
|
data/lib/rspec/rails/version.rb
CHANGED
@@ -13,26 +13,8 @@ module RSpec
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# Compat-shim for AbstractController::Rendering#view_assigns
|
16
|
-
#
|
17
|
-
# _assigns was deprecated in favor of view_assigns after
|
18
|
-
# Rails-3.0.0 was released. Since we are not able to predict when
|
19
|
-
# the _assigns/view_assigns patch will be released (I thought it
|
20
|
-
# would have been in 3.0.1, but 3.0.1 bypassed this change for a
|
21
|
-
# security fix), this bit ensures that we do the right thing without
|
22
|
-
# knowing anything about the Rails version we are dealing with.
|
23
|
-
#
|
24
|
-
# Once that change _is_ released, this can be changed to something
|
25
|
-
# that checks for the Rails version when the module is being
|
26
|
-
# interpreted, as it was before commit dd0095.
|
27
16
|
def view_assigns
|
28
17
|
super.merge(_encapsulated_assigns)
|
29
|
-
rescue
|
30
|
-
_assigns
|
31
|
-
end
|
32
|
-
|
33
|
-
# @private
|
34
|
-
def _assigns
|
35
|
-
super.merge(_encapsulated_assigns)
|
36
18
|
end
|
37
19
|
|
38
20
|
private
|
@@ -62,14 +62,8 @@ module RSpec
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
template.format
|
68
|
-
end
|
69
|
-
else
|
70
|
-
def self.template_format(template)
|
71
|
-
template.formats
|
72
|
-
end
|
65
|
+
def self.template_format(template)
|
66
|
+
template.format
|
73
67
|
end
|
74
68
|
|
75
69
|
# Delegates all methods to the submitted resolver and for all methods
|
data/lib/rspec-rails.rb
CHANGED
@@ -8,11 +8,7 @@ module RSpec
|
|
8
8
|
class Railtie < ::Rails::Railtie
|
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
|
-
|
12
|
-
::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec")
|
13
|
-
else
|
14
|
-
SourceAnnotationExtractor::Annotation.register_directories("spec")
|
15
|
-
end
|
11
|
+
::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec")
|
16
12
|
generators = config.app_generators
|
17
13
|
generators.integration_tool :rspec
|
18
14
|
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: 6.0.0
|
4
|
+
version: 6.0.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: 2022-
|
47
|
+
date: 2022-10-10 00:00:00.000000000 Z
|
48
48
|
dependencies:
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: actionpack
|
@@ -176,28 +176,16 @@ dependencies:
|
|
176
176
|
name: cucumber
|
177
177
|
requirement: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
|
-
- - "
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version: '3.2'
|
182
|
-
- - "!="
|
183
|
-
- !ruby/object:Gem::Version
|
184
|
-
version: 4.0.0
|
185
|
-
- - "<"
|
179
|
+
- - "~>"
|
186
180
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
181
|
+
version: '7.0'
|
188
182
|
type: :development
|
189
183
|
prerelease: false
|
190
184
|
version_requirements: !ruby/object:Gem::Requirement
|
191
185
|
requirements:
|
192
|
-
- - "
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '3.2'
|
195
|
-
- - "!="
|
196
|
-
- !ruby/object:Gem::Version
|
197
|
-
version: 4.0.0
|
198
|
-
- - "<"
|
186
|
+
- - "~>"
|
199
187
|
- !ruby/object:Gem::Version
|
200
|
-
version:
|
188
|
+
version: '7.0'
|
201
189
|
description: rspec-rails is a testing framework for Rails 5+.
|
202
190
|
email: rspec@googlegroups.com
|
203
191
|
executables: []
|
@@ -228,7 +216,6 @@ files:
|
|
228
216
|
- lib/generators/rspec/install/install_generator.rb
|
229
217
|
- lib/generators/rspec/install/templates/spec/rails_helper.rb
|
230
218
|
- lib/generators/rspec/integration/integration_generator.rb
|
231
|
-
- lib/generators/rspec/integration/templates/request_spec.rb
|
232
219
|
- lib/generators/rspec/job/job_generator.rb
|
233
220
|
- lib/generators/rspec/job/templates/job_spec.rb.erb
|
234
221
|
- lib/generators/rspec/mailbox/mailbox_generator.rb
|
@@ -241,6 +228,7 @@ files:
|
|
241
228
|
- lib/generators/rspec/model/templates/fixtures.yml
|
242
229
|
- lib/generators/rspec/model/templates/model_spec.rb
|
243
230
|
- lib/generators/rspec/request/request_generator.rb
|
231
|
+
- lib/generators/rspec/request/templates/request_spec.rb
|
244
232
|
- lib/generators/rspec/scaffold/scaffold_generator.rb
|
245
233
|
- lib/generators/rspec/scaffold/templates/api_controller_spec.rb
|
246
234
|
- lib/generators/rspec/scaffold/templates/api_request_spec.rb
|
@@ -308,7 +296,7 @@ licenses:
|
|
308
296
|
- MIT
|
309
297
|
metadata:
|
310
298
|
bug_tracker_uri: https://github.com/rspec/rspec-rails/issues
|
311
|
-
changelog_uri: https://github.com/rspec/rspec-rails/blob/v6.0.0
|
299
|
+
changelog_uri: https://github.com/rspec/rspec-rails/blob/v6.0.0/Changelog.md
|
312
300
|
documentation_uri: https://rspec.info/documentation/
|
313
301
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
314
302
|
source_code_uri: https://github.com/rspec/rspec-rails
|
@@ -324,9 +312,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
324
312
|
version: 2.5.0
|
325
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
326
314
|
requirements:
|
327
|
-
- - "
|
315
|
+
- - ">="
|
328
316
|
- !ruby/object:Gem::Version
|
329
|
-
version:
|
317
|
+
version: '0'
|
330
318
|
requirements: []
|
331
319
|
rubygems_version: 3.1.6
|
332
320
|
signing_key:
|
metadata.gz.sig
CHANGED
Binary file
|