spec/array_spec.rb in rico-0.0.1 vs spec/array_spec.rb in rico-0.1.0
- old
+ new
@@ -131,9 +131,32 @@
a.add(1, 2, 3, 4, 5, 6)
a.count.should eql 6
end
end
+ describe ".resolve" do
+ it "properly resolves missing values" do
+ datas = [
+ { "_type" => "array", "_values" => [1,2,3] },
+ { "_type" => "array", "_values" => [1,2,3,4] }
+ ]
+ conflicted = RiakHelpers.build_conflicted_robject "array_resolve_simple", datas
+ result = Rico::Array.resolve(conflicted)
+ result.data["_values"].should eql [1,2,3,4]
+ end
+
+ it "properly deletes deleted values after resolve" do
+ datas = [
+ { "_type" => "array", "_values" => [1,2,3,4] },
+ { "_type" => "array", "_values" => [1,2,3], "_deletes" => [4] }
+ ]
+ conflicted = RiakHelpers.build_conflicted_robject "array_resolve_delete", datas
+ result = Rico::Array.resolve(conflicted)
+ result.data["_values"].should eql [1,2,3]
+ result.data["_deletes"].should eql [4]
+ end
+ end
+
it "is enumerable" do
a = Rico::Array.new RiakHelpers.bucket, "enumerable"
a.add(3, 1, 4, 1, 5, 9)
a.to_a.should eql [3, 1, 4, 1, 5, 9]
a.each { }.length.should eql 6