diff --git a/spec/rspec/expectations/block_snippet_extractor_spec.rb b/spec/rspec/expectations/block_snippet_extractor_spec.rb index 9f7cfd90a..420a7929f 100644 --- a/spec/rspec/expectations/block_snippet_extractor_spec.rb +++ b/spec/rspec/expectations/block_snippet_extractor_spec.rb @@ -14,7 +14,7 @@ def target_method(*, &block) @proc_object = block end - def another_method(*) + def another_method(*, &_block) end before do diff --git a/spec/rspec/expectations/failure_aggregator_spec.rb b/spec/rspec/expectations/failure_aggregator_spec.rb index 955694944..64fbdaaf0 100644 --- a/spec/rspec/expectations/failure_aggregator_spec.rb +++ b/spec/rspec/expectations/failure_aggregator_spec.rb @@ -457,7 +457,11 @@ def fail_including # Each Ruby version return a different exception complement. # This method gets the current version and return the # right complement. - if RSpec::Support::Ruby.mri? && RUBY_VERSION > "1.8.7" + if RSpec::Support::Ruby.mri? && RUBY_VERSION.to_f > 3.3 + def exception_complement(block_levels) + ":in 'block (#{block_levels} levels) in '" + end + elsif RSpec::Support::Ruby.mri? && RUBY_VERSION > "1.8.7" def exception_complement(block_levels) ":in `block (#{block_levels} levels) in '" end diff --git a/spec/rspec/matchers/built_in/eq_spec.rb b/spec/rspec/matchers/built_in/eq_spec.rb index 1f02dcacd..82e9fae4a 100644 --- a/spec/rspec/matchers/built_in/eq_spec.rb +++ b/spec/rspec/matchers/built_in/eq_spec.rb @@ -62,7 +62,7 @@ module Matchers it "provides message, expected and actual with encoding details on #failure_message when string encoding is different" do matcher = eq('abc'.encode('UTF-16LE')) - matcher.matches?('abc'.force_encoding('ASCII-8BIT')) + matcher.matches?('abc'.dup.force_encoding('ASCII-8BIT')) expect(matcher.failure_message).to eq "\nexpected: # \"abc\"\n got: # \"abc\"\n\n(compared using ==)\n" end diff --git a/spec/rspec/matchers/built_in/eql_spec.rb b/spec/rspec/matchers/built_in/eql_spec.rb index e2333ac94..3a4cc4fb5 100644 --- a/spec/rspec/matchers/built_in/eql_spec.rb +++ b/spec/rspec/matchers/built_in/eql_spec.rb @@ -50,7 +50,7 @@ module Matchers it "provides message, expected and actual with encoding details on #failure_message when string encoding is different" do matcher = eql('abc'.encode('UTF-16LE')) - matcher.matches?('abc'.force_encoding('ASCII-8BIT')) + matcher.matches?('abc'.dup.force_encoding('ASCII-8BIT')) expect(matcher.failure_message).to eq "\nexpected: # \"abc\"\n got: # \"abc\"\n\n(compared using eql?)\n" end diff --git a/spec/rspec/matchers/built_in/yield_spec.rb b/spec/rspec/matchers/built_in/yield_spec.rb index b45d59166..1a25f449d 100644 --- a/spec/rspec/matchers/built_in/yield_spec.rb +++ b/spec/rspec/matchers/built_in/yield_spec.rb @@ -1,14 +1,14 @@ module YieldHelpers # these helpers are prefixed with an underscore to prevent # collisions with the matchers (some of which have the same names) - def _dont_yield + def _dont_yield(&_block) end def _yield_with_no_args yield end - def _yield_with_args(*args) + def _yield_with_args(*args, &_block) yield(*args) end end @@ -789,7 +789,7 @@ def invalid_block(&block) %w[ food barn ].each do |eventual| initial = '' _yield_with_args(initial, &b) - initial << eventual + initial += eventual end }.not_to yield_successive_args(a_string_matching(/foo/), a_string_matching(/bar/)) end