Skip to content

Commit

Permalink
Fix spec for Ruby 3.4.0dev’s new pretty-print syntax for hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny committed Oct 29, 2024
1 parent c4f22f6 commit b429e94
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions spec/service_actor/result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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__,
Expand Down Expand Up @@ -61,6 +62,7 @@
:yield_self,
)
end
# rubocop:enable RSpec/ExampleLength
end

context "when input is String" do
Expand Down Expand Up @@ -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?
"#<ServiceActor::Result {a: 1, :b=>\"hello\"}>\n"
else
"#<ServiceActor::Result {:a=>1, :b=>\"hello\"}>\n"
end
end

it "correctly pretty prints the result" do
expect(PP.pp(result, +"")).to eq("#<ServiceActor::Result {:a=>1, :b=>\"hello\"}>\n")
expect(PP.pp(result, +"")).to eq(expected_result)
end
end
end
Expand Down

0 comments on commit b429e94

Please sign in to comment.