Skip to content

Commit

Permalink
add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Jan 23, 2025
1 parent 3f16f06 commit 7616814
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/hash_inspect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ class Memo < Struct.new(:id); end
assert_equal Trailblazer::Core::Utils.inspect("A string {with: true, and: 1} a hash"), %(A string {:with=>true, :and=>1} a hash)
end

# it "can convert multi-line strings" do
# multi_line = %(Actual contract errors: \e[33m{:title=>[\"must be filled\"], :content=>[\"must be filled\", \"size cannot be less than 8\"]}\e[0m.
# --- expected
# +++ actual
# @@ -1 +1 @@
# -{:title=>[\"is XXX\"]}
# +{:title=>[\"must be filled\"], :content=>[\"must be filled\", \"size cannot be less than 8\"]}
# )

# assert_equal Trailblazer::Core::Utils.inspect("A string {with: true, and: 1} a hash"), %(A string {:with=>true, :and=>1} a hash)
# end

it "doesn't convert non-hashes in multi-line strings" do
multi_line = %({Trailblazer::Test::Testing::Memo::Operation::Create} didn't fail, it passed.
Expected: false
Actual: true)

assert_equal Trailblazer::Core::Utils.inspect(multi_line), %({Trailblazer::Test::Testing::Memo::Operation::Create} didn't fail, it passed.
Expected: false
Actual: true)
end

it "uses native {#inspect} for other classes" do
assert_equal Trailblazer::Core::Utils.inspect(Struct.new(:id).new(1)), %(#<struct id=1>)
end
Expand Down

0 comments on commit 7616814

Please sign in to comment.