rspec-rails 5.1.2 → 6.0.3
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 +60 -6
- data/README.md +35 -35
- 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 +3 -4
- 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/scaffold/scaffold_generator.rb +4 -4
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +15 -0
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +8 -4
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -1
- data/lib/generators/rspec/scaffold/templates/request_spec.rb +15 -0
- 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 +11 -0
- data/lib/rspec/rails/configuration.rb +12 -12
- 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 +4 -4
- data/lib/rspec/rails/feature_check.rb +6 -2
- data/lib/rspec/rails/file_fixture_support.rb +3 -0
- data/lib/rspec/rails/fixture_file_upload_support.rb +13 -30
- data/lib/rspec/rails/fixture_support.rb +7 -2
- data/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +5 -2
- data/lib/rspec/rails/matchers/active_job.rb +4 -4
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +3 -2
- 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 +13 -11
- data/lib/rspec-rails.rb +1 -5
- data.tar.gz.sig +0 -0
- metadata +23 -35
- metadata.gz.sig +0 -0
- /data/lib/generators/rspec/{integration → request}/templates/request_spec.rb +0 -0
@@ -83,10 +83,17 @@ 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 %>
|
86
87
|
it "renders a successful response (i.e. to display the 'new' template)" do
|
87
88
|
post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
|
88
89
|
expect(response).to be_successful
|
89
90
|
end
|
91
|
+
<% else %>
|
92
|
+
it "renders a response with 422 status (i.e. to display the 'new' template)" do
|
93
|
+
post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
|
94
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
95
|
+
end
|
96
|
+
<% end %>
|
90
97
|
end
|
91
98
|
end
|
92
99
|
|
@@ -112,11 +119,19 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
|
|
112
119
|
end
|
113
120
|
|
114
121
|
context "with invalid parameters" do
|
122
|
+
<% if Rails.version.to_f < 7.0 %>
|
115
123
|
it "renders a successful response (i.e. to display the 'edit' template)" do
|
116
124
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
117
125
|
patch <%= show_helper %>, params: { <%= singular_table_name %>: invalid_attributes }
|
118
126
|
expect(response).to be_successful
|
119
127
|
end
|
128
|
+
<% else %>
|
129
|
+
it "renders a response with 422 status (i.e. to display the 'edit' template)" do
|
130
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
131
|
+
patch <%= show_helper %>, params: { <%= singular_table_name %>: invalid_attributes }
|
132
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
133
|
+
end
|
134
|
+
<% end %>
|
120
135
|
end
|
121
136
|
end
|
122
137
|
|
@@ -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,16 @@ module RSpec
|
|
181
181
|
#
|
182
182
|
# @private
|
183
183
|
TestUnitAssertionAdapter = MinitestAssertionAdapter
|
184
|
+
|
185
|
+
# @private
|
186
|
+
module TaggedLoggingAdapter
|
187
|
+
private
|
188
|
+
# Vendored from activesupport/lib/active_support/testing/tagged_logging.rb
|
189
|
+
# This implements the tagged_logger method where it is expected, but
|
190
|
+
# doesn't call `name` or set it up like Rails does.
|
191
|
+
def tagged_logger
|
192
|
+
@tagged_logger ||= (defined?(Rails.logger) && Rails.logger)
|
193
|
+
end
|
194
|
+
end
|
184
195
|
end
|
185
196
|
end
|
@@ -26,19 +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
|
-
generator:
|
32
|
-
helper:
|
33
|
-
job:
|
34
|
-
mailer:
|
35
|
-
model:
|
36
|
-
request:
|
37
|
-
routing:
|
38
|
-
view:
|
39
|
-
feature:
|
40
|
-
system:
|
41
|
-
mailbox:
|
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]
|
42
42
|
}
|
43
43
|
|
44
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,11 +149,11 @@ 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]}
|
153
|
-
render_options[:handlers] = [match[:handler]] if match[:handler]
|
152
|
+
render_options = { template: match[:template] }
|
153
|
+
render_options[:handlers] = [match[:handler].to_sym] if match[:handler]
|
154
154
|
render_options[:formats] = [match[:format].to_sym] if match[:format]
|
155
|
-
render_options[:locales] = [match[:locale]] if match[:locale]
|
156
|
-
render_options[:variants] = [match[:variant]] if match[:variant]
|
155
|
+
render_options[:locales] = [match[:locale].to_sym] if match[:locale]
|
156
|
+
render_options[:variants] = [match[:variant].to_sym] if match[:variant]
|
157
157
|
|
158
158
|
render_options
|
159
159
|
end
|
@@ -24,17 +24,21 @@ module RSpec
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def has_action_cable_testing?
|
27
|
-
defined?(::ActionCable)
|
27
|
+
defined?(::ActionCable)
|
28
28
|
end
|
29
29
|
|
30
30
|
def has_action_mailer_parameterized?
|
31
|
-
has_action_mailer? && defined?(::ActionMailer::Parameterized)
|
31
|
+
has_action_mailer? && defined?(::ActionMailer::Parameterized::DeliveryJob)
|
32
32
|
end
|
33
33
|
|
34
34
|
def has_action_mailer_unified_delivery?
|
35
35
|
has_action_mailer? && defined?(::ActionMailer::MailDeliveryJob)
|
36
36
|
end
|
37
37
|
|
38
|
+
def has_action_mailer_legacy_delivery_job?
|
39
|
+
defined?(ActionMailer::DeliveryJob)
|
40
|
+
end
|
41
|
+
|
38
42
|
def has_action_mailbox?
|
39
43
|
defined?(::ActionMailbox)
|
40
44
|
end
|
@@ -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
|
@@ -21,7 +21,12 @@ module RSpec
|
|
21
21
|
if RSpec.configuration.use_active_record?
|
22
22
|
include Fixtures
|
23
23
|
|
24
|
-
|
24
|
+
# TestFixtures#fixture_path is deprecated and will be removed in Rails 7.2
|
25
|
+
if respond_to?(:fixture_paths=)
|
26
|
+
fixture_paths << RSpec.configuration.fixture_path
|
27
|
+
else
|
28
|
+
self.fixture_path = RSpec.configuration.fixture_path
|
29
|
+
end
|
25
30
|
self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
|
26
31
|
self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures
|
27
32
|
|
@@ -46,7 +51,7 @@ module RSpec
|
|
46
51
|
def proxy_method_warning_if_called_in_before_context_scope(method_name)
|
47
52
|
orig_implementation = instance_method(method_name)
|
48
53
|
define_method(method_name) do |*args, &blk|
|
49
|
-
if
|
54
|
+
if RSpec.current_scope == :before_context_hook
|
50
55
|
RSpec.warn_with("Calling fixture method in before :context ")
|
51
56
|
else
|
52
57
|
orig_implementation.bind(self).call(*args, &blk)
|
@@ -96,8 +96,11 @@ module RSpec
|
|
96
96
|
private
|
97
97
|
|
98
98
|
def stream
|
99
|
-
@stream ||=
|
99
|
+
@stream ||= case @target
|
100
|
+
when String
|
100
101
|
@target
|
102
|
+
when Symbol
|
103
|
+
@target.to_s
|
101
104
|
else
|
102
105
|
check_channel_presence
|
103
106
|
@channel.broadcasting_for(@target)
|
@@ -159,7 +162,7 @@ module RSpec
|
|
159
162
|
def check_channel_presence
|
160
163
|
return if @channel.present? && @channel.respond_to?(:channel_name)
|
161
164
|
|
162
|
-
error_msg = "Broadcasting channel can't be
|
165
|
+
error_msg = "Broadcasting channel can't be inferred. Please, specify it with `from_channel`"
|
163
166
|
raise ArgumentError, error_msg
|
164
167
|
end
|
165
168
|
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
|
@@ -230,11 +230,11 @@ module RSpec
|
|
230
230
|
def matches?(proc)
|
231
231
|
raise ArgumentError, "have_enqueued_job and enqueue_job only support block expectations" unless Proc === proc
|
232
232
|
|
233
|
-
|
233
|
+
original_enqueued_jobs = Set.new(queue_adapter.enqueued_jobs)
|
234
234
|
proc.call
|
235
|
-
|
235
|
+
enqueued_jobs = Set.new(queue_adapter.enqueued_jobs)
|
236
236
|
|
237
|
-
check(
|
237
|
+
check(enqueued_jobs - original_enqueued_jobs)
|
238
238
|
end
|
239
239
|
|
240
240
|
def does_not_match?(proc)
|
@@ -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
|
|
@@ -158,7 +158,7 @@ module RSpec
|
|
158
158
|
end
|
159
159
|
|
160
160
|
def legacy_mail?(job)
|
161
|
-
job[:job] <= ActionMailer::DeliveryJob
|
161
|
+
RSpec::Rails::FeatureCheck.has_action_mailer_legacy_delivery_job? && job[:job] <= ActionMailer::DeliveryJob
|
162
162
|
end
|
163
163
|
|
164
164
|
def parameterized_mail?(job)
|
@@ -169,6 +169,7 @@ module RSpec
|
|
169
169
|
RSpec::Rails::FeatureCheck.has_action_mailer_unified_delivery? && job[:job] <= ActionMailer::MailDeliveryJob
|
170
170
|
end
|
171
171
|
end
|
172
|
+
|
172
173
|
# @api public
|
173
174
|
# Passes if an email has been enqueued inside block.
|
174
175
|
# May chain with to specify expected arguments.
|
@@ -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
|
@@ -77,7 +71,15 @@ module RSpec
|
|
77
71
|
# templates with modified source
|
78
72
|
#
|
79
73
|
# @private
|
80
|
-
class ResolverDecorator
|
74
|
+
class ResolverDecorator < ::ActionView::Resolver
|
75
|
+
(::ActionView::Resolver.instance_methods - Object.instance_methods).each do |method|
|
76
|
+
undef_method method
|
77
|
+
end
|
78
|
+
|
79
|
+
(::ActionView::Resolver.methods - Object.methods).each do |method|
|
80
|
+
singleton_class.undef_method method
|
81
|
+
end
|
82
|
+
|
81
83
|
def initialize(resolver)
|
82
84
|
@resolver = resolver
|
83
85
|
end
|
@@ -125,11 +127,11 @@ module RSpec
|
|
125
127
|
# @private
|
126
128
|
module EmptyTemplates
|
127
129
|
def prepend_view_path(new_path)
|
128
|
-
|
130
|
+
super(_path_decorator(*new_path))
|
129
131
|
end
|
130
132
|
|
131
133
|
def append_view_path(new_path)
|
132
|
-
|
134
|
+
super(_path_decorator(*new_path))
|
133
135
|
end
|
134
136
|
|
135
137
|
private
|
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
|