1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
From: Antonio Terceiro <terceiro@debian.org>
Date: Fri, 22 Jan 2016 12:14:40 -0200
Subject: Port tests to rspec 3
---
spec/hashdiff/util_spec.rb | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/spec/hashdiff/util_spec.rb b/spec/hashdiff/util_spec.rb
index bce861c..9130686 100644
--- a/spec/hashdiff/util_spec.rb
+++ b/spec/hashdiff/util_spec.rb
@@ -14,59 +14,59 @@ describe HashDiff do
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, :similarity => 1).should be_false
+ HashDiff.similar?(a, b).should be true
+ HashDiff.similar?(a, b, :similarity => 1).should be false
end
it "should be able to tell similiar hash with values within tolerance" do
a = {'a' => 1.5, 'b' => 2.25, 'c' => 3, 'd' => 4, 'e' => 5}
b = {'a' => 1.503, 'b' => 2.22, 'c' => 3, 'e' => 5}
- HashDiff.similar?(a, b, :numeric_tolerance => 0.05).should be_true
- HashDiff.similar?(a, b).should be_false
+ HashDiff.similar?(a, b, :numeric_tolerance => 0.05).should be true
+ HashDiff.similar?(a, b).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
+ 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, :similarity => 0.5).should be_true
+ HashDiff.similar?(a, b, :similarity => 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, :similarity => 0.5).should be_false
+ HashDiff.similar?(a, b, :similarity => 0.5).should be false
end
describe '.compare_values' do
it "should compare numeric values exactly when no tolerance" do
- expect(HashDiff.compare_values(10.004, 10.003)).to be_false
+ expect(HashDiff.compare_values(10.004, 10.003)).to be false
end
it "should allow tolerance with numeric values" do
- expect(HashDiff.compare_values(10.004, 10.003, :numeric_tolerance => 0.01)).to be_true
+ expect(HashDiff.compare_values(10.004, 10.003, :numeric_tolerance => 0.01)).to be true
end
it "should compare other objects with or without tolerance" do
- expect(HashDiff.compare_values('hats', 'ninjas')).to be_false
- expect(HashDiff.compare_values('hats', 'ninjas', :numeric_tolerance => 0.01)).to be_false
- expect(HashDiff.compare_values('horse', 'horse')).to be_true
+ expect(HashDiff.compare_values('hats', 'ninjas')).to be false
+ expect(HashDiff.compare_values('hats', 'ninjas', :numeric_tolerance => 0.01)).to be false
+ expect(HashDiff.compare_values('horse', 'horse')).to be true
end
it 'should compare strings exactly by default' do
- expect(HashDiff.compare_values(' horse', 'horse')).to be_false
+ expect(HashDiff.compare_values(' horse', 'horse')).to be false
end
it 'should strip strings before comparing when requested' do
- expect(HashDiff.compare_values(' horse', 'horse', :strip => true)).to be_true
+ expect(HashDiff.compare_values(' horse', 'horse', :strip => true)).to be true
end
end
end
|