contrast 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/contrast/version.rb +1 -1
- data/lib/contrast_with.rb +1 -1
- data/spec/contrast_spec.rb +60 -0
- metadata +3 -1
data/lib/contrast/version.rb
CHANGED
data/lib/contrast_with.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "examples" do
|
4
|
+
it "should return no results when the objects match" do
|
5
|
+
fields = [:first_name, :last_name, :city, :state, :zip]
|
6
|
+
example_objects = fields.to_objects {[
|
7
|
+
['a', 'b', 'c', 'd', 'e'],
|
8
|
+
['a', 'b', 'c', 'd', 'e']
|
9
|
+
]}
|
10
|
+
|
11
|
+
first = example_objects[0]
|
12
|
+
second = example_objects[1]
|
13
|
+
|
14
|
+
first.contrast_with(second, fields).count.must_equal 0
|
15
|
+
second.contrast_with(first, fields).count.must_equal 0
|
16
|
+
first.contrast_with!(second, fields)
|
17
|
+
second.contrast_with!(first, fields)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return the fields that do not match" do
|
21
|
+
fields = [:first_name, :last_name, :city, :state, :zip]
|
22
|
+
example_objects = fields.to_objects {[
|
23
|
+
['a', 'b', 'c', 'd', 'e'],
|
24
|
+
['z', 'b', 'c', 'd', 'e']
|
25
|
+
]}
|
26
|
+
|
27
|
+
first = example_objects[0]
|
28
|
+
second = example_objects[1]
|
29
|
+
|
30
|
+
first.contrast_with(second, fields).count.must_equal 1
|
31
|
+
second.contrast_with(first, fields).count.must_equal 1
|
32
|
+
|
33
|
+
#this statement will force an exception
|
34
|
+
begin
|
35
|
+
first.contrast_with!(second, fields)
|
36
|
+
rescue
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return all fields if they all are different" do
|
41
|
+
fields = [:first_name, :last_name, :city, :state, :zip]
|
42
|
+
example_objects = fields.to_objects {[
|
43
|
+
['a', 'b', 'c', 'd', 'e'],
|
44
|
+
['z', 'y', 'x', 'w', 'v']
|
45
|
+
]}
|
46
|
+
|
47
|
+
first = example_objects[0]
|
48
|
+
second = example_objects[1]
|
49
|
+
|
50
|
+
first.contrast_with(second, fields).count.must_equal 5
|
51
|
+
second.contrast_with(first, fields).count.must_equal 5
|
52
|
+
|
53
|
+
#this statement will force an exception
|
54
|
+
begin
|
55
|
+
first.contrast_with!(second, fields)
|
56
|
+
rescue
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contrast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/contrast_with.rb
|
98
98
|
- spec/contrast/detective_spec.rb
|
99
99
|
- spec/contrast/matching_exception_spec.rb
|
100
|
+
- spec/contrast_spec.rb
|
100
101
|
- spec/contrast_with_spec.rb
|
101
102
|
- spec/spec_helper.rb
|
102
103
|
homepage: ''
|
@@ -126,5 +127,6 @@ summary: Contrast two objects by a defined set of values
|
|
126
127
|
test_files:
|
127
128
|
- spec/contrast/detective_spec.rb
|
128
129
|
- spec/contrast/matching_exception_spec.rb
|
130
|
+
- spec/contrast_spec.rb
|
129
131
|
- spec/contrast_with_spec.rb
|
130
132
|
- spec/spec_helper.rb
|