Sha256: a7415478d3202cce87c7802a6d25c72cde68ef908d867b3acc745098d74d8dee
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
require 'spec_helper' describe HashDiff do it "should be able to decode property path" do decoded = HashDiff.send(:decode_property_path, "a.b[0].c.city[5]") decoded.should == ['a', 'b', 0, 'c', 'city', 5] end it "should be able to decode property path with custom delimiter" do decoded = HashDiff.send(:decode_property_path, "a\tb[0]\tc\tcity[5]", "\t") decoded.should == ['a', 'b', 0, 'c', 'city', 5] end it "should be able to tell similiar hash" do a = {'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5} b = {'a' => 1, 'b' => 2, 'c' => 3, 'e' => 5} HashDiff.similar?(a, b).should be_true HashDiff.similar?(a, b, 1).should be_false end it "should be able to tell numbers and strings" do HashDiff.similar?(1, 2).should be_false HashDiff.similar?("a", "b").should be_false HashDiff.similar?("a", [1, 2, 3]).should be_false HashDiff.similar?(1, {'a' => 1, 'b' => 2, 'c' => 3, 'e' => 5}).should be_false end it "should be able to tell true when similarity == 0.5" do a = {"value" => "New1", "onclick" => "CreateNewDoc()"} b = {"value" => "New", "onclick" => "CreateNewDoc()"} HashDiff.similar?(a, b, 0.5).should be_true end it "should be able to tell false when similarity == 0.5" do a = {"value" => "New1", "onclick" => "open()"} b = {"value" => "New", "onclick" => "CreateNewDoc()"} HashDiff.similar?(a, b, 0.5).should be_false end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hashdiff-0.1.1 | spec/hashdiff/util_spec.rb |
hashdiff-0.1.0 | spec/hashdiff/util_spec.rb |