Skip to content

Commit

Permalink
Add more specs for #merge!
Browse files Browse the repository at this point in the history
  • Loading branch information
spuun committed Sep 27, 2023
1 parent 03a2531 commit 7c885eb
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions spec/table_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,31 @@ describe AMQ::Protocol::Table do
t1.to_h.should eq({"b" => "foo"})
end

it "supports reject!" do
it "supports #reject!" do
t1 = AMQ::Protocol::Table.new({a: 1, b: "foo"})
t1.reject! { |k, v| k.in?("a") }
t1.to_h.should eq({"b" => "foo"})
end

it "supports merge!" do
t1 = AMQ::Protocol::Table.new({a: 1, b: "foo"})
t1.merge!({c: nil})
t1.to_h.should eq({"a" => 1, "b" => "foo", "c" => nil})
describe "#merge!" do
it "supports Table" do
t1 = AMQ::Protocol::Table.new({a: 1, b: "foo"})
t2 = AMQ::Protocol::Table.new({c: nil})
t1.merge!(t2)
t1.to_h.should eq({"a" => 1, "b" => "foo", "c" => nil})
end

it "supports NamedTuple" do
t1 = AMQ::Protocol::Table.new({a: 1, b: "foo"})
t1.merge!({c: nil})
t1.to_h.should eq({"a" => 1, "b" => "foo", "c" => nil})
end

it "supports Hash(String, Field)" do
t1 = AMQ::Protocol::Table.new({a: 1, b: "foo"})
t1.merge!({"c" => nil} of String => AMQ::Protocol::Field)
t1.to_h.should eq({"a" => 1, "b" => "foo", "c" => nil})
end
end

it "can add fields" do
Expand Down

0 comments on commit 7c885eb

Please sign in to comment.