spec/map_spec.rb in rico-0.3.0 vs spec/map_spec.rb in rico-0.4.0
- old
+ new
@@ -11,24 +11,25 @@
a.add({"a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5})
b = Rico::Map.new RiakHelpers.bucket, "map_add_single_hash"
b.members.should eql({"a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5})
end
- it "writes multiple hashes to the map" do
- a = Rico::Map.new RiakHelpers.bucket, "map_add_multiple_hashes"
- a.add({"a" => 1, "b" => 2, "c" => 3}, {"d" => 4, "e" => 5})
- b = Rico::Map.new RiakHelpers.bucket, "map_add_multiple_hashes"
- b.members.should eql({"a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5})
- end
-
it "supports multiple multiple writes to the map" do
a = Rico::Map.new RiakHelpers.bucket, "map_add_multiple_writes"
a.add({"a" => 1, "b" => 2, "c" => 3})
a.add({"d" => 4, "e" => 5})
b = Rico::Map.new RiakHelpers.bucket, "map_add_multiple_writes"
b.members.should eql({"a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5})
end
+
+ it "merges in the right order with implicit deduping" do
+ a = Rico::Map.new RiakHelpers.bucket, "map_add_order_dedupe"
+ a.add({"a" => 1, "b" => 2, "c" => 3})
+ a.add({"b" => "B", "c" => "C"})
+ b = Rico::Map.new RiakHelpers.bucket, "map_add_order_dedupe"
+ b.members.should eql({"a" => 1, "b" => "B", "c" => "C"})
+ end
end
describe "#remove" do
it "removes a single key by string" do
a = Rico::Map.new RiakHelpers.bucket, "map_remove_single_key_string"
@@ -41,39 +42,47 @@
it "removes multiple keys by string" do
a = Rico::Map.new RiakHelpers.bucket, "map_remove_multiple_keys_string"
a.add({"a" => 1, "b" => 2, "c" => 3})
b = Rico::Map.new RiakHelpers.bucket, "map_remove_multiple_keys_string"
- b.remove("a", "c")
+ b.remove(["a", "c"])
c = Rico::Map.new RiakHelpers.bucket, "map_remove_multiple_keys_string"
c.members.should eql({"b" => 2})
end
it "removes multiple keys by symbol" do
a = Rico::Map.new RiakHelpers.bucket, "map_remove_multiple_keys_symbol"
a.add({"a" => 1, "b" => 2, "c" => 3})
b = Rico::Map.new RiakHelpers.bucket, "map_remove_multiple_keys_symbol"
- b.remove(:a, :c)
+ b.remove([:a, :c])
c = Rico::Map.new RiakHelpers.bucket, "map_remove_multiple_keys_symbol"
c.members.should eql({"b" => 2})
end
it "removes multiple keys by integer" do
a = Rico::Map.new RiakHelpers.bucket, "map_remove_multiple_keys_integer"
a.add({1 => 1, 2 => 2, 3 => 3})
b = Rico::Map.new RiakHelpers.bucket, "map_remove_multiple_keys_integer"
- b.remove(1, 3)
+ b.remove([1, 3])
c = Rico::Map.new RiakHelpers.bucket, "map_remove_multiple_keys_integer"
c.members.should eql({"2" => 2})
end
it "removes multiple keys by map tuples" do
a = Rico::Map.new RiakHelpers.bucket, "map_remove_single_key_tuple"
a.add({"a" => 1, "b" => 2, "c" => 3})
b = Rico::Map.new RiakHelpers.bucket, "map_remove_single_key_tuple"
- b.remove({"a" => 1})
+ b.remove({"a" => 1, "b" => 2})
c = Rico::Map.new RiakHelpers.bucket, "map_remove_single_key_tuple"
- c.members.should eql({"b" => 2, "c" => 3})
+ c.members.should eql({"c" => 3})
+ end
+
+ it "merges in the right order with implicit deduping" do
+ a = Rico::Map.new RiakHelpers.bucket, "map_remove_order_dedupe"
+ a.add({"a" => 1, "b" => 2, "c" => 3, "d" => 4})
+ a.remove({"b" => 2, "c" => 3, "c" => 3, "c" => 3})
+ b = Rico::Map.new RiakHelpers.bucket, "map_remove_order_dedupe"
+ b.members.should eql({"a" => 1, "d" => 4})
end
end
describe "#length" do
it "returns zero for an empty list" do