rspec-rails 6.0.3 → 6.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ea5e598eb640cb98f6c236d15d50ebf4eb2b2a9b3933f9d54e26c641a02a883
4
- data.tar.gz: 1cc9b5c8781149e0e1d0c4ef11d4b39289aef77e01fdd0fe88db1936060134e1
3
+ metadata.gz: ecae469592630a6ecaaa39d6f2be0e2616cb2079c044bc390e548956b823d6bc
4
+ data.tar.gz: f24952e5edf9bf57f6e8c94fced8c7b2d38938b4a1b250fa83043bf316c8de9c
5
5
  SHA512:
6
- metadata.gz: 738369d092e738e50c111b93a1fdc2e02ecacce35cd1595a5e1c00453dad3901ed6a69f162b01d20e5265edda7dbcdb34a2c772f198d1b2a8c1d46d1e9c0ca0f
7
- data.tar.gz: dcd63e6c5faf232419774b29406ffc3492bfb28367a629fd792245227899b07afe12adc13249b29ee9ef3077ec261f6210f6c53b2413f291e57b0d63182a4436
6
+ metadata.gz: e50c692c774cd0a874bedd667e7c0e3997236d43a74750efb6cc215a3019ce9a4babc5437a79825c43c885b70f1c3da9c90599ce1b0bf123ba1538e77cc7884e
7
+ data.tar.gz: a148f034a8667af85e68c478849bd9ea33443567dec01335d0a83ad9fd44d63d7dd0780694ebaee55f2278add2fefa61032674e38dec865cf01ee1205e13d1e9
checksums.yaml.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,5 +1,17 @@
1
- ### Development
2
- [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.3...6-0-maintenance)
1
+ ### 6.0.4 / 2023-11-21
2
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.3...v6.0.4)
3
+
4
+ Bug Fixes:
5
+
6
+ * Fuzzy match `have_broadcasted_to` so that argument matchers can be used.
7
+ (Timothy Peraza, #2684)
8
+ * Fix fixture warning during `:context` hooks on Rails `main`. (Jon Rowe, #2685)
9
+ * Fix `stub_template` on Rails `main`. (Jon Rowe, #2685)
10
+ * Fix variable name in scaffolded view specs when namespaced. (Taketo Takashima, #2694)
11
+ * Prevent `take_failed_screenshot` producing an additional error through `metadata`
12
+ access. (Jon Rowe, #2704)
13
+ * Use `ActiveSupport::ExecutionContext::TestHelper` on Rails 7+. (Jon Rowe, #2711)
14
+ * Fix leak of templates stubbed with `stub_template` on Rails 7.1. (Jon Rowe, #2714)
3
15
 
4
16
  ### 6.0.3 / 2023-05-31
5
17
  [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.2...v6.0.3)
@@ -2,7 +2,7 @@ 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
- let(:<%= ns_file_name %>) {
5
+ let(:<%= singular_table_name %>) {
6
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 ? '' : ','%>
@@ -11,13 +11,13 @@ RSpec.describe "<%= ns_table_name %>/edit", <%= type_metatag(:view) %> do
11
11
  }
12
12
 
13
13
  before(:each) do
14
- assign(:<%= ns_file_name %>, <%= ns_file_name %>)
14
+ assign(:<%= singular_table_name %>, <%= singular_table_name %>)
15
15
  end
16
16
 
17
17
  it "renders the edit <%= ns_file_name %> form" do
18
18
  render
19
19
 
20
- assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(<%= ns_file_name %>), "post" do
20
+ assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(<%= singular_table_name %>), "post" do
21
21
  <% for attribute in output_attributes -%>
22
22
  <%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %>
23
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 %>/new", <%= type_metatag(:view) %> do
5
5
  before(:each) do
6
- assign(:<%= ns_file_name %>, <%= class_name %>.new(<%= '))' if output_attributes.empty? %>
6
+ assign(:<%= singular_table_name %>, <%= class_name %>.new(<%= '))' 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 -%>
@@ -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
- assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
6
+ assign(:<%= singular_table_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 -%>
@@ -2,6 +2,10 @@
2
2
  # suite and ammeter.
3
3
  require 'rspec/rails/matchers'
4
4
 
5
+ if ::Rails::VERSION::MAJOR >= 7
6
+ require 'active_support/execution_context/test_helper'
7
+ end
8
+
5
9
  module RSpec
6
10
  module Rails
7
11
  # @api public
@@ -12,7 +16,10 @@ module RSpec
12
16
  include RSpec::Rails::MinitestLifecycleAdapter
13
17
  include RSpec::Rails::MinitestAssertionAdapter
14
18
  include RSpec::Rails::FixtureSupport
15
- include RSpec::Rails::TaggedLoggingAdapter if ::Rails::VERSION::MAJOR >= 7
19
+ if ::Rails::VERSION::MAJOR >= 7
20
+ include RSpec::Rails::TaggedLoggingAdapter
21
+ include ActiveSupport::ExecutionContext::TestHelper
22
+ end
16
23
  end
17
24
  end
18
25
  end
@@ -44,6 +44,52 @@ module RSpec
44
44
  ].join("_").tr(CHARS_TO_TRANSLATE.join, "_").byteslice(0...200).scrub("") + "_#{rand(1000)}"
45
45
  end
46
46
 
47
+ if ::Rails::VERSION::STRING.to_f >= 7.1
48
+ # @private
49
+ # Allows failure screenshot to work whilst not exposing metadata
50
+ class SuppressRailsScreenshotMetadata
51
+ def initialize
52
+ @example_data = {}
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
62
+
63
+ def []=(key, value)
64
+ if key == :failure_screenshot_path
65
+ @example_data[key] = value
66
+ else
67
+ raise_wrong_scope_error
68
+ end
69
+ end
70
+
71
+ def method_missing(_name, *_args, &_block)
72
+ raise_wrong_scope_error
73
+ end
74
+
75
+ private
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
85
+ end
86
+
87
+ # @private
88
+ def metadata
89
+ @metadata ||= SuppressRailsScreenshotMetadata.new
90
+ end
91
+ end
92
+
47
93
  # Delegates to `Rails.application`.
48
94
  def app
49
95
  ::Rails.application
@@ -89,7 +89,7 @@ module RSpec
89
89
  #
90
90
  # stub_template("widgets/_widget.html.erb" => "This content.")
91
91
  def stub_template(hash)
92
- view.view_paths.unshift(StubResolverCache.resolver_for(hash))
92
+ controller.prepend_view_path(StubResolverCache.resolver_for(hash))
93
93
  end
94
94
 
95
95
  # Provides access to the params hash that will be available within the
@@ -37,28 +37,50 @@ module RSpec
37
37
  module Fixtures
38
38
  extend ActiveSupport::Concern
39
39
 
40
+ # rubocop:disable Metrics/BlockLength
40
41
  class_methods do
41
- def fixtures(*args)
42
- orig_methods = private_instance_methods
43
- super.tap do
44
- new_methods = private_instance_methods - orig_methods
45
- new_methods.each do |method_name|
46
- proxy_method_warning_if_called_in_before_context_scope(method_name)
42
+ if ::Rails.version.to_f >= 7.1
43
+ def fixtures(*args)
44
+ super.tap do
45
+ fixture_sets.each_key do |fixture_name|
46
+ proxy_method_warning_if_called_in_before_context_scope(fixture_name)
47
+ end
48
+ end
49
+ end
50
+
51
+ def proxy_method_warning_if_called_in_before_context_scope(fixture_name)
52
+ define_method(fixture_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
47
68
  end
48
69
  end
49
- end
50
70
 
51
- def proxy_method_warning_if_called_in_before_context_scope(method_name)
52
- orig_implementation = instance_method(method_name)
53
- define_method(method_name) do |*args, &blk|
54
- if RSpec.current_scope == :before_context_hook
55
- RSpec.warn_with("Calling fixture method in before :context ")
56
- else
57
- orig_implementation.bind(self).call(*args, &blk)
71
+ def proxy_method_warning_if_called_in_before_context_scope(method_name)
72
+ orig_implementation = instance_method(method_name)
73
+ define_method(method_name) do |*args, &blk|
74
+ if RSpec.current_scope == :before_context_hook
75
+ RSpec.warn_with("Calling fixture method in before :context ")
76
+ else
77
+ orig_implementation.bind(self).call(*args, &blk)
78
+ end
58
79
  end
59
80
  end
60
81
  end
61
82
  end
83
+ # rubocop:enable Metrics/BlockLength
62
84
  end
63
85
  end
64
86
  end
@@ -112,7 +112,7 @@ module RSpec
112
112
  decoded = ActiveSupport::JSON.decode(msg)
113
113
  decoded = decoded.with_indifferent_access if decoded.is_a?(Hash)
114
114
 
115
- if @data.nil? || @data === decoded
115
+ if @data.nil? || values_match?(@data, decoded)
116
116
  @block.call(decoded)
117
117
  true
118
118
  else
@@ -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 = '6.0.3'
6
+ STRING = '6.0.4'
7
7
  end
8
8
  end
9
9
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.3
4
+ version: 6.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
8
8
  - Andy Lindeman
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain:
12
12
  - |
@@ -44,7 +44,7 @@ cert_chain:
44
44
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
45
45
  F3MdtaDehhjC
46
46
  -----END CERTIFICATE-----
47
- date: 2023-05-31 00:00:00.000000000 Z
47
+ date: 2023-11-21 00:00:00.000000000 Z
48
48
  dependencies:
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: actionpack
@@ -296,11 +296,11 @@ licenses:
296
296
  - MIT
297
297
  metadata:
298
298
  bug_tracker_uri: https://github.com/rspec/rspec-rails/issues
299
- changelog_uri: https://github.com/rspec/rspec-rails/blob/v6.0.3/Changelog.md
299
+ changelog_uri: https://github.com/rspec/rspec-rails/blob/v6.0.4/Changelog.md
300
300
  documentation_uri: https://rspec.info/documentation/
301
301
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
302
302
  source_code_uri: https://github.com/rspec/rspec-rails
303
- post_install_message:
303
+ post_install_message:
304
304
  rdoc_options:
305
305
  - "--charset=UTF-8"
306
306
  require_paths:
@@ -316,8 +316,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
316
  - !ruby/object:Gem::Version
317
317
  version: '0'
318
318
  requirements: []
319
- rubygems_version: 3.1.6
320
- signing_key:
319
+ rubygems_version: 3.4.10
320
+ signing_key:
321
321
  specification_version: 4
322
322
  summary: RSpec for Rails
323
323
  test_files: []
metadata.gz.sig CHANGED
Binary file