From b429e94abfc835cb79e6542db2501be158a522c3 Mon Sep 17 00:00:00 2001 From: Sunny Ripert Date: Tue, 29 Oct 2024 07:48:30 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20spec=20for=20Ruby=203.4.0dev=E2=80=99s=20?= =?UTF-8?q?new=20pretty-print=20syntax=20for=20hashes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/service_actor/result_spec.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/spec/service_actor/result_spec.rb b/spec/service_actor/result_spec.rb index 03a3bc5..93f123b 100644 --- a/spec/service_actor/result_spec.rb +++ b/spec/service_actor/result_spec.rb @@ -17,7 +17,8 @@ end describe ".instance_methods" do - it "stays the same across supported Rubies" do # rubocop:disable RSpec/ExampleLength + # rubocop:disable RSpec/ExampleLength + it "stays the same across supported Rubies" do expect(described_class.instance_methods).to contain_exactly( :__binding__, :__id__, @@ -61,6 +62,7 @@ :yield_self, ) end + # rubocop:enable RSpec/ExampleLength end context "when input is String" do @@ -233,8 +235,19 @@ context "with nested attributes" do let(:result) { described_class.new(a: 1, b: "hello") } + # Test for the new hash syntax introduced in Ruby 3.4.0dev + let(:new_pp_ruby_syntax?) { PP.pp({hash: "test"}, +"").include?("hash:") } + + let(:expected_result) do + if new_pp_ruby_syntax? + "#\"hello\"}>\n" + else + "#1, :b=>\"hello\"}>\n" + end + end + it "correctly pretty prints the result" do - expect(PP.pp(result, +"")).to eq("#1, :b=>\"hello\"}>\n") + expect(PP.pp(result, +"")).to eq(expected_result) end end end