rubygem-rspec-support/rubygem-rspec-support-pr616-ruby34-syntax.patch
2024-11-06 16:14:11 +09:00

132 lines
4.7 KiB
Diff

From 3b539d062868f3da9095075ad989ff688323923e Mon Sep 17 00:00:00 2001
From: Jon Rowe <hello@jonrowe.co.uk>
Date: Fri, 18 Oct 2024 22:19:24 +0100
Subject: [PATCH 1/2] Handle Ruby 3.4 hash syntax changes
---
spec/rspec/support/object_formatter_spec.rb | 24 +++++++++++++++------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/spec/rspec/support/object_formatter_spec.rb b/spec/rspec/support/object_formatter_spec.rb
index 4ec8ddb4d..c371c77ea 100644
--- a/spec/rspec/support/object_formatter_spec.rb
+++ b/spec/rspec/support/object_formatter_spec.rb
@@ -27,7 +27,7 @@ module Support
# We can't count on the ordering of the hash on 1.8.7...
expect(formatted).to include(%Q{"key"=>#{formatted_time}}, %Q{#{formatted_time}=>"value"}, %Q{"nested"=>{"key"=>#{formatted_time}}})
else
- expect(formatted).to eq(%Q{{"key"=>#{formatted_time}, #{formatted_time}=>"value", "nested"=>{"key"=>#{formatted_time}}}})
+ expect(formatted).to eq_hash_syntax(%Q{{"key"=>#{formatted_time}, #{formatted_time}=>"value", "nested"=>{"key"=>#{formatted_time}}}})
end
end
end
@@ -39,7 +39,7 @@ module Support
it 'sorts keys to ensure objects are always displayed the same way' do
formatted = ObjectFormatter.format(input)
- expect(formatted).to eq expected
+ expect(formatted).to eq_hash_syntax expected
end
end
end
@@ -269,7 +269,7 @@ def self.to_s
let(:formatted_time) { ObjectFormatter.format(time) }
it 'formats the recursive element as {...} and other elements with custom formatting' do
- expect(output).to eq("{{...}=>#{formatted_time}}")
+ expect(output).to eq_hash_syntax("{{...}=>#{formatted_time}}")
end
end
@@ -289,7 +289,7 @@ def self.to_s
let(:formatted_time) { ObjectFormatter.format(time) }
it 'formats the recursive element as {...} and other elements with custom formatting' do
- expect(output).to eq("{#{formatted_time}=>{...}}")
+ expect(output).to eq_hash_syntax("{#{formatted_time}=>{...}}")
end
end
@@ -305,7 +305,7 @@ def self.to_s
end
it 'formats the recursive element as [...]' do
- expect(output).to eq('[{:recursive_array=>[...]}]')
+ expect(output).to eq_hash_syntax('[{:recursive_array=>[...]}]')
end
end
@@ -321,7 +321,7 @@ def self.to_s
end
it 'formats the recursive element as {...}' do
- expect(output).to eq('{:array=>[:next_is_recursive_hash, {...}]}')
+ expect(output).to eq_hash_syntax('{:array=>[:next_is_recursive_hash, {...}]}')
end
end
@@ -336,7 +336,7 @@ def self.to_s
end
it 'does not omit them' do
- expect(output).to eq('[{:key=>"value"}, {:key=>"value"}]')
+ expect(output).to eq_hash_syntax('[{:key=>"value"}, {:key=>"value"}]')
end
end
@@ -370,6 +370,16 @@ def inspect
expect(formatter.format('Test String Of A Longer Length')).to eq('"Test String Of A Longer Length"')
end
end
+
+ if RUBY_VERSION.to_f > 3.3
+ def eq_hash_syntax(string)
+ eq string.gsub('=>', ' => ')
+ end
+ else
+ def eq_hash_syntax(string)
+ eq string
+ end
+ end
end
end
end
From c4364ea195fb924ab55eb6385d9cbd481e0fc878 Mon Sep 17 00:00:00 2001
From: Jon Rowe <hello@jonrowe.co.uk>
Date: Sat, 19 Oct 2024 09:39:35 +0100
Subject: [PATCH 2/2] Adapt to hash formatting in Ruby 3.4 in the differ
---
spec/rspec/support/differ_spec.rb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/spec/rspec/support/differ_spec.rb b/spec/rspec/support/differ_spec.rb
index 83bb1242c..3677cbb45 100644
--- a/spec/rspec/support/differ_spec.rb
+++ b/spec/rspec/support/differ_spec.rb
@@ -306,6 +306,8 @@ def inspect; "<BrokenObject>"; end
|
EOD
+ expected_diff.gsub!('=>',' => ') if RUBY_VERSION.to_f > 3.3
+
diff = differ.diff(expected,actual)
expect(diff).to be_diffed_as(expected_diff)
end
@@ -375,6 +377,7 @@ def inspect; "<BrokenObject>"; end
|+"c" => {"key_1"=>#{formatted_time}},
|
EOD
+ expected_diff.gsub!('"=>','" => ') if RUBY_VERSION.to_f > 3.3
left_side_hash = {'c' => {'key_1' => time}}
right_side_hash = {'b' => {'key_1' => time}}
@@ -408,6 +411,7 @@ def inspect; "<BrokenObject>"; end
|+[{"a"=>#{formatted_time}}, "c"]
|
EOD
+ expected_diff.gsub!('=>',' => ') if RUBY_VERSION.to_f > 3.3
left_side_array = [{'a' => time}, 'c']
right_side_array = [{'b' => time}, 'c']