Compare commits
5 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf30e4437e | ||
|
|
6ac0794a0c | ||
|
|
87a8d5773d | ||
|
|
c3034a91e2 | ||
|
|
f0a6901ca4 |
6 changed files with 133 additions and 406 deletions
25
rspec-expectations-pr282-ruby4_0-source_location.patch
Normal file
25
rspec-expectations-pr282-ruby4_0-source_location.patch
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
From 1c20fa80772ca7a1ed0512056ce7cd6a94f8e68d Mon Sep 17 00:00:00 2001
|
||||
From: Jon Rowe <hello@jonrowe.co.uk>
|
||||
Date: Fri, 28 Nov 2025 10:59:10 +0000
|
||||
Subject: [PATCH] Cope with the changes to block source_location in Ruby 4
|
||||
|
||||
---
|
||||
rspec-core/lib/rspec/core/hooks.rb | 2 +-
|
||||
rspec-core/lib/rspec/core/metadata.rb | 2 +-
|
||||
rspec-core/lib/rspec/core/shared_example_group.rb | 2 +-
|
||||
.../lib/rspec/expectations/block_snippet_extractor.rb | 2 +-
|
||||
4 files changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb b/rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb
|
||||
index 5c66ac639..24dbaf88e 100644
|
||||
--- a/rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb
|
||||
+++ b/rspec-expectations/lib/rspec/expectations/block_snippet_extractor.rb
|
||||
@@ -62,7 +62,7 @@ def file_path
|
||||
end
|
||||
|
||||
def beginning_line_number
|
||||
- source_location.last
|
||||
+ source_location[1]
|
||||
end
|
||||
|
||||
def source_location
|
||||
|
|
@ -14,10 +14,12 @@ CURRDIR=$(pwd)
|
|||
TMPDIRPATH=$(mktemp -d /var/tmp/rspec-tar-XXXXXX)
|
||||
pushd $TMPDIRPATH
|
||||
|
||||
git clone https://github.com/rspec/$1.git
|
||||
pushd $1
|
||||
git reset --hard v$2
|
||||
popd
|
||||
git clone https://github.com/rspec/rspec.git
|
||||
pushd rspec
|
||||
|
||||
# https://github.com/rspec/rspec/issues/220
|
||||
git reset --hard $1-v$2 || \
|
||||
git reset --hard rspec-expecations-v$2
|
||||
|
||||
ln -sf $1 $1-$2
|
||||
tar czf ${CURRDIR}/rubygem-$1-$2-full.tar.gz $1-$2/./
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
--- rspec-expectations-3.13.4/spec/rspec/matchers/built_in/include_spec.rb 2025-05-15 11:40:49.000000000 +0900
|
||||
+++ rspec-expectations-3.13.3/spec/rspec/matchers/built_in/include_spec.rb 2024-09-08 16:39:38.000000000 +0900
|
||||
@@ -109,7 +104,7 @@ RSpec.describe "#include matcher" do
|
||||
failure_string = if use_string_keys_in_failure_message?
|
||||
dedent(<<-END)
|
||||
|Diff:
|
||||
- |@@ #{one_line_header(3)} @@
|
||||
+ |@@ -1,3 +1,3 @@
|
||||
|-:bar => 3,
|
||||
|-:foo => 1,
|
||||
|+"bar" => 2,
|
||||
@@ -137,7 +132,7 @@ RSpec.describe "#include matcher" do
|
||||
failure_string = if use_string_keys_in_failure_message?
|
||||
dedent(<<-END)
|
||||
|Diff:
|
||||
- |@@ #{one_line_header(3)} @@
|
||||
+ |@@ -1,3 +1,3 @@
|
||||
|-(match /FOO/i) => 1,
|
||||
|-:bar => 3,
|
||||
|+"bar" => 2,
|
||||
@@ -146,7 +141,7 @@ RSpec.describe "#include matcher" do
|
||||
else
|
||||
dedent(<<-END)
|
||||
|Diff:
|
||||
- |@@ #{one_line_header(3)} @@
|
||||
+ |@@ -1,3 +1,3 @@
|
||||
|-(match /FOO/i) => 1,
|
||||
|-:bar => 3,
|
||||
|+:bar => 2,
|
||||
--- rspec-expectations-3.13.4/spec/rspec/matchers/built_in/compound_spec.rb 2025-05-15 11:40:49.000000000 +0900
|
||||
+++ rspec-expectations-3.13.3/spec/rspec/matchers/built_in/compound_spec.rb 2024-09-08 16:39:38.000000000 +0900
|
||||
@@ -596,14 +595,14 @@ module RSpec::Matchers::BuiltIn
|
||||
|
|
||||
| expected "HELLO\\nWORLD" to eq downcase "hola\\nmon"
|
||||
|Diff for (eq downcase "bonjour\\nmonde"):
|
||||
- |@@ #{one_line_header(3)} @@
|
||||
+ |@@ -1,3 +1,3 @@
|
||||
|-bonjour
|
||||
|-monde
|
||||
|+hello
|
||||
|+world
|
||||
|
|
||||
|Diff for (eq downcase "hola\\nmon"):
|
||||
- |@@ #{one_line_header(3)} @@
|
||||
+ |@@ -1,3 +1,3 @@
|
||||
|-hola
|
||||
|-mon
|
||||
|+hello
|
||||
@@ -639,14 +638,14 @@ module RSpec::Matchers::BuiltIn
|
||||
|
|
||||
| expected "hello\\nworld" to eq downcase "hola\\nmon"
|
||||
|Diff for (eq downcase "bonjour\\nmonde"):
|
||||
- |@@ #{one_line_header(3)} @@
|
||||
+ |@@ -1,3 +1,3 @@
|
||||
|-bonjour
|
||||
|-monde
|
||||
|+hello
|
||||
|+world
|
||||
|
|
||||
|Diff for (eq downcase "hola\\nmon"):
|
||||
- |@@ #{one_line_header(3)} @@
|
||||
+ |@@ -1,3 +1,3 @@
|
||||
|-hola
|
||||
|-mon
|
||||
|+hello
|
||||
|
||||
|
|
@ -1,393 +0,0 @@
|
|||
From f1b04eec3b696c9a9134b6ed9ef11ac70356e57f Mon Sep 17 00:00:00 2001
|
||||
From: Jon Rowe <hello@jonrowe.co.uk>
|
||||
Date: Wed, 25 Dec 2024 11:14:19 +0000
|
||||
Subject: [PATCH 2/2] Fixes for rspec-expectations hash syntax
|
||||
|
||||
---
|
||||
.../built_in_matchers/include.feature | 4 +-
|
||||
.../built_in_matchers/predicates.feature | 2 +-
|
||||
.../step_definitions/additional_cli_steps.rb | 26 +++++++
|
||||
.../spec/rspec/matchers/aliases_spec.rb | 6 +-
|
||||
.../rspec/matchers/built_in/captures_spec.rb | 4 +-
|
||||
.../spec/rspec/matchers/built_in/eq_spec.rb | 2 +-
|
||||
.../spec/rspec/matchers/built_in/has_spec.rb | 4 +-
|
||||
.../matchers/built_in/have_attributes_spec.rb | 16 +++-
|
||||
.../rspec/matchers/built_in/include_spec.rb | 74 +++++++++++++------
|
||||
9 files changed, 102 insertions(+), 36 deletions(-)
|
||||
|
||||
diff --git a/rspec-expectations/features/built_in_matchers/include.feature b/rspec-expectations/features/built_in_matchers/include.feature
|
||||
index 295d9b60f..012307135 100644
|
||||
--- a/rspec-expectations/features/built_in_matchers/include.feature
|
||||
+++ b/rspec-expectations/features/built_in_matchers/include.feature
|
||||
@@ -139,7 +139,7 @@ Feature: `include` matcher
|
||||
end
|
||||
"""
|
||||
When I run `rspec hash_include_matcher_spec.rb`
|
||||
- Then the output should contain all of these:
|
||||
+ Then the output should contain all of these, ignoring hash syntax:
|
||||
| 22 examples, 13 failures |
|
||||
| expected {:a => 7, :b => 5} not to include :a |
|
||||
| expected {:a => 7, :b => 5} not to include :b and :a |
|
||||
@@ -176,7 +176,7 @@ Feature: `include` matcher
|
||||
end
|
||||
"""
|
||||
When I run `rspec include_matcher_with_counts_spec.rb`
|
||||
- Then the output should contain all of these:
|
||||
+ Then the output should contain all of these, ignoring hash syntax:
|
||||
| 12 examples, 4 failures |
|
||||
| expected [{:c => 7}, {:a => 1}, {:b => 2}, {:c => 1}, {:a => 3}, {:c => 7}] not to include (have key :b) once |
|
||||
| expected [{:c => 7}, {:a => 1}, {:b => 2}, {:c => 1}, {:a => 3}, {:c => 7}] not to include (have key :a) twice |
|
||||
diff --git a/rspec-expectations/features/built_in_matchers/predicates.feature b/rspec-expectations/features/built_in_matchers/predicates.feature
|
||||
index 0c3b33c5e..282c7a853 100644
|
||||
--- a/rspec-expectations/features/built_in_matchers/predicates.feature
|
||||
+++ b/rspec-expectations/features/built_in_matchers/predicates.feature
|
||||
@@ -88,7 +88,7 @@ Feature: Predicate matchers
|
||||
"""
|
||||
When I run `rspec should_have_key_spec.rb`
|
||||
Then the output should contain "2 examples, 1 failure"
|
||||
- And the output should contain "expected `{:foo=>7}.has_key?(:bar)` to be truthy, got false"
|
||||
+ And the output should contain, ignoring hash syntax, "expected `{:foo=>7}.has_key?(:bar)` to be truthy, got false"
|
||||
|
||||
Scenario: Expecting `subject` to have all decimals (based on custom `has_decimals?` method)
|
||||
Given a file named "should_not_have_all_string_keys_spec.rb" with:
|
||||
diff --git a/rspec-expectations/features/step_definitions/additional_cli_steps.rb b/rspec-expectations/features/step_definitions/additional_cli_steps.rb
|
||||
index 2ab176f60..c016e0ea8 100644
|
||||
--- a/rspec-expectations/features/step_definitions/additional_cli_steps.rb
|
||||
+++ b/rspec-expectations/features/step_definitions/additional_cli_steps.rb
|
||||
@@ -28,3 +28,29 @@
|
||||
step 'the output should contain "1 failure"'
|
||||
step 'the exit status should not be 0'
|
||||
end
|
||||
+
|
||||
+Then(/^the output should contain, ignoring hash syntax, "(.*)"$/) do |output|
|
||||
+ if RUBY_VERSION.to_f > 3.3
|
||||
+ expect(all_output).to include(output.gsub(/:(\w+)=>/, '\1: '))
|
||||
+ else
|
||||
+ expect(all_output).to include(output)
|
||||
+ end
|
||||
+end
|
||||
+
|
||||
+RSpec::Matchers.define :match_table do |lines|
|
||||
+ match do |all_output|
|
||||
+ lines.all? { |line| all_output.include?(line) }
|
||||
+ end
|
||||
+
|
||||
+ diffable
|
||||
+end
|
||||
+
|
||||
+Then "the output should contain all of these, ignoring hash syntax:" do |table|
|
||||
+ lines = table.raw.flatten.reject(&:empty?)
|
||||
+
|
||||
+ if RUBY_VERSION.to_f > 3.3
|
||||
+ lines = lines.map { |line| line.gsub(/:(\w+)\s+=>\s+/, '\1: ') }
|
||||
+ end
|
||||
+
|
||||
+ expect(all_output).to match_table(lines)
|
||||
+end
|
||||
diff --git a/rspec-expectations/spec/rspec/matchers/aliases_spec.rb b/rspec-expectations/spec/rspec/matchers/aliases_spec.rb
|
||||
index 1b7b0d2ac..aeaca6a63 100644
|
||||
--- a/rspec-expectations/spec/rspec/matchers/aliases_spec.rb
|
||||
+++ b/rspec-expectations/spec/rspec/matchers/aliases_spec.rb
|
||||
@@ -219,7 +219,7 @@ module RSpec
|
||||
an_object_having_attributes(:age => 32)
|
||||
).to be_aliased_to(
|
||||
have_attributes(:age => 32)
|
||||
- ).with_description("an object having attributes {:age => 32}")
|
||||
+ ).with_description("an object having attributes #{hash_inspect({ :age => 32 })}")
|
||||
end
|
||||
|
||||
specify do
|
||||
@@ -227,7 +227,7 @@ module RSpec
|
||||
having_attributes(:age => 32)
|
||||
).to be_aliased_to(
|
||||
have_attributes(:age => 32)
|
||||
- ).with_description("having attributes {:age => 32}")
|
||||
+ ).with_description("having attributes #{hash_inspect({ :age => 32 })}")
|
||||
end
|
||||
|
||||
specify do
|
||||
@@ -251,7 +251,7 @@ module RSpec
|
||||
a_hash_including(:a => 5)
|
||||
).to be_aliased_to(
|
||||
include(:a => 5)
|
||||
- ).with_description('a hash including {:a => 5}')
|
||||
+ ).with_description("a hash including #{hash_inspect({ :a => 5 })}")
|
||||
end
|
||||
|
||||
specify do
|
||||
diff --git a/rspec-expectations/spec/rspec/matchers/built_in/captures_spec.rb b/rspec-expectations/spec/rspec/matchers/built_in/captures_spec.rb
|
||||
index b8656f1cc..609326e48 100644
|
||||
--- a/rspec-expectations/spec/rspec/matchers/built_in/captures_spec.rb
|
||||
+++ b/rspec-expectations/spec/rspec/matchers/built_in/captures_spec.rb
|
||||
@@ -36,7 +36,7 @@
|
||||
it "has a sensible failure description with a hash including matcher" do
|
||||
expect {
|
||||
expect("a123a").not_to match(Regexp.new("(?<num>123)(asdf)?")).with_captures(a_hash_including(:num => "123"))
|
||||
- }.to fail_with(/num => "123"/)
|
||||
+ }.to fail_with(/#{hash_inspect({ :num => "123" })}/)
|
||||
end
|
||||
|
||||
it "matches named captures when not passing a hash" do
|
||||
@@ -80,7 +80,7 @@
|
||||
it "has a sensible failure description with a hash including matcher" do
|
||||
expect {
|
||||
expect(Regexp.new("(?<num>123)(asdf)?")).not_to match("a123a").with_captures(a_hash_including(:num => "123"))
|
||||
- }.to fail_with(/num => "123"/)
|
||||
+ }.to fail_with(/#{hash_inspect({ :num => "123" })}/)
|
||||
end
|
||||
|
||||
it "matches named captures when not passing a hash" do
|
||||
diff --git a/rspec-expectations/spec/rspec/matchers/built_in/eq_spec.rb b/rspec-expectations/spec/rspec/matchers/built_in/eq_spec.rb
|
||||
index ad03c1f1d..b1ab6aa5c 100644
|
||||
--- a/rspec-expectations/spec/rspec/matchers/built_in/eq_spec.rb
|
||||
+++ b/rspec-expectations/spec/rspec/matchers/built_in/eq_spec.rb
|
||||
@@ -120,7 +120,7 @@ module Matchers
|
||||
['foo', 'eq "foo"'],
|
||||
[/regex/, 'eq /regex/'],
|
||||
[['foo'], 'eq ["foo"]'],
|
||||
- [{ :foo => :bar }, 'eq {:foo=>:bar}'],
|
||||
+ [{ :foo => :bar }, "eq #{{ :foo=>:bar }.inspect}"],
|
||||
[Class, 'eq Class'],
|
||||
[RSpec, 'eq RSpec'],
|
||||
[Time.utc(2014, 1, 1), "eq 2014-01-01 00:00:00.#{expected_seconds} +0000"],
|
||||
diff --git a/rspec-expectations/spec/rspec/matchers/built_in/has_spec.rb b/rspec-expectations/spec/rspec/matchers/built_in/has_spec.rb
|
||||
index 190817828..bf6054dbf 100644
|
||||
--- a/rspec-expectations/spec/rspec/matchers/built_in/has_spec.rb
|
||||
+++ b/rspec-expectations/spec/rspec/matchers/built_in/has_spec.rb
|
||||
@@ -31,7 +31,7 @@
|
||||
it "fails if #has_sym?(*args) returns false" do
|
||||
expect {
|
||||
expect({ :b => "B" }).to have_key(:a)
|
||||
- }.to fail_with('expected `{:b=>"B"}.has_key?(:a)` to return true, got false')
|
||||
+ }.to fail_with("expected `#{{ :b=>"B" }.inspect}.has_key?(:a)` to return true, got false")
|
||||
end
|
||||
|
||||
obj_with_block_method = Object.new
|
||||
@@ -180,7 +180,7 @@ def o.has_sym?(sym); sym == :foo; end
|
||||
it "fails if #has_sym?(*args) returns true" do
|
||||
expect {
|
||||
expect({ :a => "A" }).not_to have_key(:a)
|
||||
- }.to fail_with('expected `{:a=>"A"}.has_key?(:a)` to return false, got true')
|
||||
+ }.to fail_with("expected `#{{ :a=>"A" }.inspect}.has_key?(:a)` to return false, got true")
|
||||
end
|
||||
|
||||
it "fails if target does not respond to #has_sym?" do
|
||||
diff --git a/rspec-expectations/spec/rspec/matchers/built_in/have_attributes_spec.rb b/rspec-expectations/spec/rspec/matchers/built_in/have_attributes_spec.rb
|
||||
index 92e803b63..aad08effe 100644
|
||||
--- a/rspec-expectations/spec/rspec/matchers/built_in/have_attributes_spec.rb
|
||||
+++ b/rspec-expectations/spec/rspec/matchers/built_in/have_attributes_spec.rb
|
||||
@@ -108,13 +108,25 @@ def count
|
||||
|
||||
it 'provides a description' do
|
||||
description = have_attributes(:age => (a_value > 30)).description
|
||||
- expect(description).to eq("have attributes {:age => (a value > 30)}")
|
||||
+ expect(description).to eq(
|
||||
+ if RUBY_VERSION.to_f > 3.3
|
||||
+ "have attributes {age: (a value > 30)}"
|
||||
+ else
|
||||
+ "have attributes {:age => (a value > 30)}"
|
||||
+ end
|
||||
+ )
|
||||
end
|
||||
|
||||
it "fails with a clear message when the matcher does not match" do
|
||||
expect {
|
||||
expect(person).to have_attributes(:age => (a_value < 10))
|
||||
- }.to fail_including("expected #{object_inspect person} to have attributes {:age => (a value < 10)}")
|
||||
+ }.to fail_including(
|
||||
+ if RUBY_VERSION.to_f > 3.3
|
||||
+ "expected #{object_inspect person} to have attributes {age: (a value < 10)}"
|
||||
+ else
|
||||
+ "expected #{object_inspect person} to have attributes {:age => (a value < 10)}"
|
||||
+ end
|
||||
+ )
|
||||
end
|
||||
end
|
||||
end
|
||||
diff --git a/rspec-expectations/spec/rspec/matchers/built_in/include_spec.rb b/rspec-expectations/spec/rspec/matchers/built_in/include_spec.rb
|
||||
index e760a3a46..19aba9673 100644
|
||||
--- a/rspec-expectations/spec/rspec/matchers/built_in/include_spec.rb
|
||||
+++ b/rspec-expectations/spec/rspec/matchers/built_in/include_spec.rb
|
||||
@@ -69,8 +69,12 @@ def use_string_keys_in_failure_message?
|
||||
false
|
||||
end
|
||||
|
||||
- def convert_key(key)
|
||||
- use_string_keys_in_failure_message? ? "\"#{key}\"" : ":#{key}"
|
||||
+ def converted_key_hash_inspect(key, value)
|
||||
+ if use_string_keys_in_failure_message?
|
||||
+ hash_inspect({ key.to_s => value })
|
||||
+ else
|
||||
+ hash_inspect({ key => value })
|
||||
+ end
|
||||
end
|
||||
|
||||
it 'passes if target has the expected as a key' do
|
||||
@@ -82,7 +86,8 @@ def convert_key(key)
|
||||
end
|
||||
|
||||
it "fails if target does not include expected" do
|
||||
- failure_string = %(expected {#{convert_key(:key)} => "value"} to include :other)
|
||||
+ failure_string = %(expected #{converted_key_hash_inspect(:key, "value")} to include :other)
|
||||
+
|
||||
expect {
|
||||
expect(build_target(:key => 'value')).to include(:other)
|
||||
}.to fail_matching(failure_string)
|
||||
@@ -91,7 +96,7 @@ def convert_key(key)
|
||||
it "fails if target doesn't have a key and we expect nil" do
|
||||
expect {
|
||||
expect(build_target({})).to include(:something => nil)
|
||||
- }.to fail_matching("expected {} to include {:something => nil}")
|
||||
+ }.to fail_matching("expected {} to include #{hash_inspect({ :something => nil })}")
|
||||
end
|
||||
|
||||
it 'works even when an entry in the hash overrides #send' do
|
||||
@@ -480,12 +485,23 @@ class PseudoHash < SimpleDelegator
|
||||
{ :number => 0 },
|
||||
{ :number => 3 }
|
||||
)
|
||||
- }.to fail_including(dedent(<<-END))
|
||||
- |Diff:
|
||||
- |@@ #{one_line_header} @@
|
||||
- |-[{:number=>1}, {:number=>0}, {:number=>3}]
|
||||
- |+[{:number=>1}, {:number=>2}, {:number=>3}]
|
||||
- END
|
||||
+ }.to fail_including(
|
||||
+ if RUBY_VERSION.to_f > 3.3
|
||||
+ dedent(<<-END)
|
||||
+ |Diff:
|
||||
+ |@@ #{one_line_header} @@
|
||||
+ |-[{number: 1}, {number: 0}, {number: 3}]
|
||||
+ |+[{number: 1}, {number: 2}, {number: 3}]
|
||||
+ END
|
||||
+ else
|
||||
+ dedent(<<-END)
|
||||
+ |Diff:
|
||||
+ |@@ #{one_line_header} @@
|
||||
+ |-[{:number=>1}, {:number=>0}, {:number=>3}]
|
||||
+ |+[{:number=>1}, {:number=>2}, {:number=>3}]
|
||||
+ END
|
||||
+ end
|
||||
+ )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -632,7 +648,7 @@ class PseudoHash < SimpleDelegator
|
||||
it "fails if target includes expected key" do
|
||||
expect {
|
||||
expect({ :key => 'value' }).not_to include(:key)
|
||||
- }.to fail_matching('expected {:key => "value"} not to include :key')
|
||||
+ }.to fail_matching("expected #{hash_inspect({ :key => "value" })} not to include :key")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -751,13 +767,13 @@ class PseudoHash < SimpleDelegator
|
||||
it "fails if target has a different value for key" do
|
||||
expect {
|
||||
expect({ :key => 'different' }).to include(:key => 'value')
|
||||
- }.to fail_matching('expected {:key => "different"} to include {:key => "value"}')
|
||||
+ }.to fail_matching("expected #{hash_inspect({ :key => "different" })} to include #{hash_inspect({ :key => "value" })}")
|
||||
end
|
||||
|
||||
it "fails if target has a different key" do
|
||||
expect {
|
||||
expect({ :other => 'value' }).to include(:key => 'value')
|
||||
- }.to fail_matching('expected {:other => "value"} to include {:key => "value"}')
|
||||
+ }.to fail_matching("expected #{hash_inspect({ :other => "value" })} to include #{hash_inspect({ :key => "value" })}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -765,7 +781,7 @@ class PseudoHash < SimpleDelegator
|
||||
it "fails if the target does not contain the given hash" do
|
||||
expect {
|
||||
expect(['a', 'b']).to include(:key => 'value')
|
||||
- }.to fail_matching('expected ["a", "b"] to include {:key => "value"}')
|
||||
+ }.to fail_matching("expected [\"a\", \"b\"] to include #{hash_inspect({ :key => "value" })}")
|
||||
end
|
||||
|
||||
it "passes if the target contains the given hash" do
|
||||
@@ -779,13 +795,13 @@ class PseudoHash < SimpleDelegator
|
||||
it "fails if target includes the key/value pair" do
|
||||
expect {
|
||||
expect({ :key => 'value' }).not_to include(:key => 'value')
|
||||
- }.to fail_matching('expected {:key => "value"} not to include {:key => "value"}')
|
||||
+ }.to fail_matching("expected #{hash_inspect({ :key => "value" })} not to include #{hash_inspect({ :key => "value" })}")
|
||||
end
|
||||
|
||||
it "fails if target includes the key/value pair among others" do
|
||||
expect {
|
||||
expect({ :key => 'value', :other => 'different' }).not_to include(:key => 'value')
|
||||
- }.to fail_with(%r|expected #{hash_inspect :key => "value", :other => "different"} not to include \{:key => "value"\}|)
|
||||
+ }.to fail_with(%r|expected #{hash_inspect(:key => "value", :other => "different")} not to include #{hash_inspect({ :key => "value" })}|)
|
||||
end
|
||||
|
||||
it "passes if target has a different value for key" do
|
||||
@@ -805,7 +821,7 @@ class PseudoHash < SimpleDelegator
|
||||
it "fails if the target contains the given hash" do
|
||||
expect {
|
||||
expect(['a', { :key => 'value' }]).not_to include(:key => 'value')
|
||||
- }.to fail_matching('expected ["a", {:key => "value"}] not to include {:key => "value"}')
|
||||
+ }.to fail_matching("expected [\"a\", #{hash_inspect({ :key => "value" })}] not to include #{hash_inspect({ :key => "value" })}")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -982,13 +998,25 @@ def matches?(_)
|
||||
|
||||
it 'provides a description' do
|
||||
description = include(:a => a_value_within(3).of(10)).description
|
||||
- expect(description).to eq("include {:a => (a value within 3 of 10)}")
|
||||
+ expect(description).to eq(
|
||||
+ if RUBY_VERSION.to_f > 3.3
|
||||
+ "include {a: (a value within 3 of 10)}"
|
||||
+ else
|
||||
+ "include {:a => (a value within 3 of 10)}"
|
||||
+ end
|
||||
+ )
|
||||
end
|
||||
|
||||
it "fails with a clear message when the matcher does not match" do
|
||||
expect {
|
||||
expect(:a => 15).to include(:a => a_value_within(3).of(10))
|
||||
- }.to fail_matching("expected {:a => 15} to include {:a => (a value within 3 of 10)}")
|
||||
+ }.to fail_matching(
|
||||
+ if RUBY_VERSION.to_f > 3.3
|
||||
+ "expected {a: 15} to include {a: (a value within 3 of 10)}"
|
||||
+ else
|
||||
+ "expected {:a => 15} to include {:a => (a value within 3 of 10)}"
|
||||
+ end
|
||||
+ )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1005,7 +1033,7 @@ def matches?(_)
|
||||
it 'fails with a clear message when the matcher does not match', :if => (RUBY_VERSION.to_f > 1.8) do
|
||||
expect {
|
||||
expect(:drink => "water", :food => "bread").to include(match(/bar/))
|
||||
- }.to fail_matching('expected {:drink => "water", :food => "bread"} to include (match /bar/)')
|
||||
+ }.to fail_matching("expected #{hash_inspect({ :drink => "water", :food => "bread" })} to include (match /bar/)")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1034,19 +1062,19 @@ def matches?(_)
|
||||
it 'fails with a clear message when the value does not match', :if => (RUBY_VERSION.to_f > 1.8) do
|
||||
expect {
|
||||
expect(:drink => "water", :food => "bread").to include(match(/foo/) => "meat")
|
||||
- }.to fail_matching('expected {:drink => "water", :food => "bread"} to include {(match /foo/) => "meat"}')
|
||||
+ }.to fail_matching("expected #{hash_inspect({ :drink => "water", :food => "bread" })} to include {(match /foo/) => \"meat\"}")
|
||||
end
|
||||
|
||||
it 'fails with a clear message when the matcher does not match', :if => (RUBY_VERSION.to_f > 1.8) do
|
||||
expect {
|
||||
expect(:drink => "water", :food => "bread").to include(match(/bar/) => "bread")
|
||||
- }.to fail_matching('expected {:drink => "water", :food => "bread"} to include {(match /bar/) => "bread"}')
|
||||
+ }.to fail_matching("expected #{hash_inspect({ :drink => "water", :food => "bread" })} to include {(match /bar/) => \"bread\"}")
|
||||
end
|
||||
|
||||
it 'fails with a clear message when several matchers do not match', :if => (RUBY_VERSION.to_f > 1.8) do
|
||||
expect {
|
||||
expect(:drink => "water", :food => "bread").to include(match(/bar/) => "bread", match(/baz/) => "water")
|
||||
- }.to fail_matching('expected {:drink => "water", :food => "bread"} to include {(match /bar/) => "bread", (match /baz/) => "water"}')
|
||||
+ }.to fail_matching("expected #{hash_inspect({ :drink => "water", :food => "bread" })} to include {(match /bar/) => \"bread\", (match /baz/) => \"water\"}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
%global majorver 3.13.3
|
||||
%global majorver 3.13.5
|
||||
#%%global preminorver .rc6
|
||||
%global rpmminorver .%(echo %preminorver | sed -e 's|^\\.\\.*||')
|
||||
%global fullver %{majorver}%{?preminorver}
|
||||
|
||||
%global baserelease 3
|
||||
%global baserelease 4
|
||||
|
||||
%global gem_name rspec-expectations
|
||||
|
||||
|
|
@ -18,14 +18,17 @@ Release: %{?preminorver:0.}%{baserelease}%{?preminorver:%{rpmminorver}}%{?dist}
|
|||
|
||||
# SPDX confirmed
|
||||
License: MIT
|
||||
URL: http://github.com/rspec/rspec-expectations
|
||||
URL: https://rspec.info
|
||||
Source0: https://rubygems.org/gems/%{gem_name}-%{fullver}.gem
|
||||
# %%{SOURCE2} %%{name} %%{version}
|
||||
Source1: rubygem-%{gem_name}-%{version}-full.tar.gz
|
||||
Source2: rspec-related-create-full-tarball.sh
|
||||
# https://github.com/rspec/rspec/pull/164
|
||||
# Support ruby34 Hash#inspect syntax
|
||||
Patch0: rubygem-rspec-expectations-pr164-ruby34-hash-syntax.patch
|
||||
# Workaround tests wrt diff/lcs diff format
|
||||
# Partially revert 3.13.3 -> 3.13.4 change
|
||||
Patch0: rubygem-rspec-expectations-3.13.4-diff_spec-format-revert.patch
|
||||
# https://github.com/rspec/rspec/pull/282/commits/1c20fa80772ca7a1ed0512056ce7cd6a94f8e68d
|
||||
# Support ruby4_0 source_location behavior change
|
||||
Patch1: rspec-expectations-pr282-ruby4_0-source_location.patch
|
||||
|
||||
#BuildRequires: ruby(release)
|
||||
BuildRequires: rubygems-devel
|
||||
|
|
@ -57,7 +60,9 @@ This package contains documentation for %{name}.
|
|||
|
||||
%prep
|
||||
%setup -q -T -n %{gem_name}-%{version} -b 1
|
||||
%patch -P0 -p2
|
||||
|
||||
%patch -P0 -p1
|
||||
%patch -P1 -p2
|
||||
|
||||
gem specification %{SOURCE0} -l --ruby > %{gem_name}.gemspec
|
||||
|
||||
|
|
@ -88,6 +93,13 @@ rspec spec/
|
|||
exit 0
|
||||
%endif
|
||||
|
||||
# Fix minitest 6 compatibility
|
||||
# Behavior changed on: https://github.com/minitest/minitest/commit/2572c78420af73dbe9b202d535a1474405a32173
|
||||
if ( ruby -e 'require "minitest" ; exit Minitest::VERSION >= "6"' ) ; then
|
||||
sed -i features/test_frameworks/minitest.feature \
|
||||
-e 's|9 runs, 10 assertions, 5 failures, 0 errors|9 runs, 11 assertions, 5 failures, 0 errors|'
|
||||
fi
|
||||
|
||||
# Skip one failing scenario, needs investigating...
|
||||
sed -i features/built_in_matchers/include.feature -e '\@skip-on-fedora@d'
|
||||
sed -i features/built_in_matchers/include.feature -e 's|^\([ \t]*\)\(Scenario: counts usage.*\)|\1@skip-on-fedora\n\1\2|'
|
||||
|
|
@ -113,6 +125,21 @@ cucumber \
|
|||
%{gem_docdir}
|
||||
|
||||
%changelog
|
||||
* Thu Jan 01 2026 Mamoru TASAKA <mtasaka@fedoraproject.org> - 3.13.5-4
|
||||
- Fix compatibility for minitest 6
|
||||
|
||||
* Tue Dec 02 2025 Mamoru TASAKA <mtasaka@fedoraproject.org> - 3.13.5-3
|
||||
- Backport upstream patch to support ruby4_0 source_location behavior change
|
||||
|
||||
* Fri Jul 25 2025 Fedora Release Engineering <releng@fedoraproject.org> - 3.13.5-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
|
||||
|
||||
* Thu May 29 2025 Mamoru TASAKA <mtasaka@fedoraproject.org> - 3.13.5-1
|
||||
- 3.13.5
|
||||
|
||||
* Thu May 15 2025 Mamoru TASAKA <mtasaka@fedoraproject.org> - 3.13.4-1
|
||||
- 3.13.4
|
||||
|
||||
* Sat Jan 18 2025 Fedora Release Engineering <releng@fedoraproject.org> - 3.13.3-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
|
||||
|
||||
|
|
|
|||
4
sources
4
sources
|
|
@ -1,2 +1,2 @@
|
|||
SHA512 (rspec-expectations-3.13.3.gem) = 887d378bccf08f8f42dd3b580dc67dac0d91b7e08a23ab924bd8d618fae2f37132048b473a288a9f1c40096271e4312c28fc91383a074eda53d62939bb8c58fe
|
||||
SHA512 (rubygem-rspec-expectations-3.13.3-full.tar.gz) = 0bd40f246fe44c76e489a7af44d5ccdad0ad346c6e8b1ec0c623d61f02e15fa70a3c014360a517b71be2b1a3adf261c079ebe0d198c5692a3c34fc8269495d9d
|
||||
SHA512 (rspec-expectations-3.13.5.gem) = 4fde5ddae1c723bb3f25c65db61ec959146b1b92a08ddf09d4caf1164d25fd67e4d6d7a73b576fdb48477a3ee54763a8a2d3b93ea573ba6962d65ae80379cd03
|
||||
SHA512 (rubygem-rspec-expectations-3.13.5-full.tar.gz) = 057bf2ff409248ab4a37bc615806e786cdcf4324bd47bb606459a6ceece07799dc488838d008511bb7d798db6b8dddf2339cb6509c2d78911aa9aa06f50607ea
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue