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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/Changelog.md +60 -6
  4. data/README.md +35 -35
  5. data/lib/generators/rspec/channel/channel_generator.rb +1 -1
  6. data/lib/generators/rspec/controller/controller_generator.rb +4 -4
  7. data/lib/generators/rspec/feature/feature_generator.rb +1 -1
  8. data/lib/generators/rspec/generator/generator_generator.rb +1 -1
  9. data/lib/generators/rspec/helper/helper_generator.rb +1 -1
  10. data/lib/generators/rspec/install/install_generator.rb +19 -2
  11. data/lib/generators/rspec/install/templates/spec/rails_helper.rb +3 -4
  12. data/lib/generators/rspec/integration/integration_generator.rb +10 -3
  13. data/lib/generators/rspec/job/job_generator.rb +1 -1
  14. data/lib/generators/rspec/mailbox/mailbox_generator.rb +1 -1
  15. data/lib/generators/rspec/mailer/mailer_generator.rb +3 -3
  16. data/lib/generators/rspec/model/model_generator.rb +3 -3
  17. data/lib/generators/rspec/request/request_generator.rb +10 -3
  18. data/lib/generators/rspec/scaffold/scaffold_generator.rb +4 -4
  19. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +15 -0
  20. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +8 -4
  21. data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -1
  22. data/lib/generators/rspec/scaffold/templates/request_spec.rb +15 -0
  23. data/lib/generators/rspec/scaffold/templates/show_spec.rb +1 -1
  24. data/lib/generators/rspec/system/system_generator.rb +1 -1
  25. data/lib/generators/rspec/view/view_generator.rb +2 -2
  26. data/lib/generators/rspec.rb +18 -1
  27. data/lib/rspec/rails/adapters.rb +11 -0
  28. data/lib/rspec/rails/configuration.rb +12 -12
  29. data/lib/rspec/rails/example/rails_example_group.rb +1 -0
  30. data/lib/rspec/rails/example/system_example_group.rb +12 -11
  31. data/lib/rspec/rails/example/view_example_group.rb +4 -4
  32. data/lib/rspec/rails/feature_check.rb +6 -2
  33. data/lib/rspec/rails/file_fixture_support.rb +3 -0
  34. data/lib/rspec/rails/fixture_file_upload_support.rb +13 -30
  35. data/lib/rspec/rails/fixture_support.rb +7 -2
  36. data/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +5 -2
  37. data/lib/rspec/rails/matchers/active_job.rb +4 -4
  38. data/lib/rspec/rails/matchers/have_enqueued_mail.rb +3 -2
  39. data/lib/rspec/rails/matchers/have_http_status.rb +1 -1
  40. data/lib/rspec/rails/matchers/routing_matchers.rb +2 -2
  41. data/lib/rspec/rails/vendor/capybara.rb +1 -3
  42. data/lib/rspec/rails/version.rb +1 -1
  43. data/lib/rspec/rails/view_assigns.rb +0 -18
  44. data/lib/rspec/rails/view_rendering.rb +13 -11
  45. data/lib/rspec-rails.rb +1 -5
  46. data.tar.gz.sig +0 -0
  47. metadata +23 -35
  48. metadata.gz.sig +0 -0
  49. /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
- @<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
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,7 +9,7 @@ module Rspec
9
9
  def generate_system_spec
10
10
  return unless options[:system_specs]
11
11
 
12
- template template_name, File.join('spec/system', class_path, filename)
12
+ template template_name, target_path('system', class_path, filename)
13
13
  end
14
14
 
15
15
  def template_name
@@ -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 File.join("spec", "views", file_path)
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
- File.join("spec", "views", file_path, "#{@action}.html.#{options[:template_engine]}_spec.rb")
17
+ target_path("views", file_path, "#{@action}.html.#{options[:template_engine]}_spec.rb")
18
18
  end
19
19
  end
20
20
  end
@@ -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 compatability with
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
@@ -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: %w[spec channels],
29
+ channel: %w[spec channels],
30
30
  controller: %w[spec controllers],
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]
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
@@ -12,6 +12,7 @@ module RSpec
12
12
  include RSpec::Rails::MinitestLifecycleAdapter
13
13
  include RSpec::Rails::MinitestAssertionAdapter
14
14
  include RSpec::Rails::FixtureSupport
15
+ include RSpec::Rails::TaggedLoggingAdapter if ::Rails::VERSION::MAJOR >= 7
15
16
  end
16
17
  end
17
18
  end
@@ -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 requires Rails >= 5.1 and has a hard
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
- :webrick`) before attempting to use system specs.
67
+ :puma`) before attempting to use system specs.
67
68
  """.gsub(/\s+/, ' ').strip
68
69
  end
69
70
 
70
- if ::Rails::VERSION::STRING >= '6.0'
71
- original_before_teardown =
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
- if ::Rails::VERSION::STRING >= '6.0'
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) && ActionCable::VERSION::MAJOR >= 6
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
@@ -9,6 +9,9 @@ module RSpec
9
9
 
10
10
  included do
11
11
  self.file_fixture_path = RSpec.configuration.file_fixture_path
12
+ if defined?(ActiveStorage::FixtureSet)
13
+ ActiveStorage::FixtureSet.file_fixture_path = RSpec.configuration.file_fixture_path
14
+ end
12
15
  end
13
16
  end
14
17
  end
@@ -6,41 +6,24 @@ module RSpec
6
6
 
7
7
  private
8
8
 
9
- # In Rails 6.2 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 6.2 expect to rework this to remove
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
- if ::Rails.version.to_f >= 6.1
13
- def rails_fixture_file_wrapper
14
- RailsFixtureFileWrapper.file_fixture_path = nil
15
- resolved_fixture_path =
16
- if respond_to?(:file_fixture_path) && !file_fixture_path.nil?
17
- file_fixture_path.to_s
18
- else
19
- (RSpec.configuration.fixture_path || '').to_s
20
- end
21
- RailsFixtureFileWrapper.file_fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
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
- self.fixture_path = RSpec.configuration.fixture_path
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 inspect.include?("before(:context)")
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 ||= if @target.is_a?(String)
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 infered. Please, specify it with `from_channel`"
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 wether it is on purpose or not.
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
- original_enqueued_jobs_count = queue_adapter.enqueued_jobs.count
233
+ original_enqueued_jobs = Set.new(queue_adapter.enqueued_jobs)
234
234
  proc.call
235
- in_block_jobs = queue_adapter.enqueued_jobs.drop(original_enqueued_jobs_count)
235
+ enqueued_jobs = Set.new(queue_adapter.enqueued_jobs)
236
236
 
237
- check(in_block_jobs)
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 customise it here.
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] formating the expected status and associated code(s)
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
- if defined?(ActionPack) && ActionPack::VERSION::STRING >= "5.1"
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)
@@ -3,7 +3,7 @@ module RSpec
3
3
  # Version information for RSpec Rails.
4
4
  module Version
5
5
  # Current version of RSpec Rails, in semantic versioning format.
6
- STRING = '5.1.2'
6
+ STRING = '6.0.3'
7
7
  end
8
8
  end
9
9
  end
@@ -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
- if ::Rails::VERSION::STRING >= '6'
66
- def self.template_format(template)
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
- lookup_context.view_paths.unshift(*_path_decorator(*new_path))
130
+ super(_path_decorator(*new_path))
129
131
  end
130
132
 
131
133
  def append_view_path(new_path)
132
- lookup_context.view_paths.push(*_path_decorator(*new_path))
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
- if ::Rails::VERSION::STRING >= '6.0'
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