object_comparator 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/lib/object_comparator/minitest.rb +12 -8
- data/lib/object_comparator/rspec.rb +8 -0
- data/lib/object_comparator/version.rb +1 -1
- data/lib/object_comparator.rb +17 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 069674508c26382b74ab79d0435d1c554d43de7d
|
4
|
+
data.tar.gz: b04c1a6267fd0d20744672791f5f7eb048fdd08b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdba30df9b8cec8db2e68c80591aeebe264c98af057a7397c1394c75ddc0b6e9340d429d5c3482e321d9f8652c3abed40ec34402fe306f47d921e0491b70b4ae
|
7
|
+
data.tar.gz: 482d16258f0976f1528ed33cc6c7246998a82c2ef4219487adc4630d3f6dc5140f06593103d3035984ade8e4279e3b1baf5049b140ace02eca817ce62e56645f
|
data/.travis.yml
CHANGED
@@ -2,18 +2,22 @@ require 'object_comparator'
|
|
2
2
|
|
3
3
|
class ObjectComparator
|
4
4
|
module Minitest
|
5
|
-
def assert_equal_objects(
|
6
|
-
|
7
|
-
|
5
|
+
def assert_equal_objects(expected, actual, message = nil)
|
6
|
+
expected = InspectionString.new(expected.inspect)
|
7
|
+
actual = InspectionString.new(actual.inspect)
|
8
8
|
|
9
|
-
|
9
|
+
message ||= ObjectComparator.new.failing_message_for_should(expected, actual)
|
10
|
+
|
11
|
+
assert_equal(expected, actual, message)
|
10
12
|
end
|
11
13
|
|
12
|
-
def refute_equal_objects(
|
13
|
-
|
14
|
-
|
14
|
+
def refute_equal_objects(expected, actual, message = nil)
|
15
|
+
expected = InspectionString.new(expected.inspect)
|
16
|
+
actual = InspectionString.new(actual.inspect)
|
17
|
+
|
18
|
+
message ||= ObjectComparator.new.failing_message_for_should_not(expected, actual)
|
15
19
|
|
16
|
-
refute_equal(
|
20
|
+
refute_equal(expected, actual, message)
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -4,4 +4,12 @@ RSpec::Matchers.define :be_equal_to do |expected|
|
|
4
4
|
match do |actual|
|
5
5
|
ObjectComparator.new.equal?(actual, expected)
|
6
6
|
end
|
7
|
+
|
8
|
+
failure_message_for_should do |actual|
|
9
|
+
ObjectComparator.new.failing_message_for_should(expected, actual)
|
10
|
+
end
|
11
|
+
|
12
|
+
failure_message_for_should_not do |actual|
|
13
|
+
ObjectComparator.new.failing_message_for_should_not(expected, actual)
|
14
|
+
end
|
7
15
|
end
|
data/lib/object_comparator.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "object_comparator/version"
|
2
2
|
|
3
3
|
class ObjectComparator
|
4
4
|
def equal?(one, other)
|
@@ -7,6 +7,20 @@ class ObjectComparator
|
|
7
7
|
one == other
|
8
8
|
end
|
9
9
|
|
10
|
+
def failing_message_for_should(one, other)
|
11
|
+
one = InspectionString.new(one.inspect)
|
12
|
+
other = InspectionString.new(other.inspect)
|
13
|
+
|
14
|
+
"expected #{other} to be equal to #{one}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def failing_message_for_should_not(one, other)
|
18
|
+
one = InspectionString.new(one.inspect)
|
19
|
+
other = InspectionString.new(other.inspect)
|
20
|
+
|
21
|
+
"expected #{other} not to be equal to #{one}"
|
22
|
+
end
|
23
|
+
|
10
24
|
class InspectionString
|
11
25
|
def initialize(string)
|
12
26
|
@string = string
|
@@ -17,8 +31,8 @@ class ObjectComparator
|
|
17
31
|
end
|
18
32
|
|
19
33
|
def to_s
|
20
|
-
@string.gsub(/:0x[a-z0-9]{14} /, ' ')
|
21
|
-
.gsub(/:0x[a-z0-9]{14}>/, '>')
|
34
|
+
@string.gsub(/:0x[a-z0-9]{14,16} /, ' ')
|
35
|
+
.gsub(/:0x[a-z0-9]{14,16}>/, '>')
|
22
36
|
end
|
23
37
|
end
|
24
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: object_comparator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Jacobus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.5.1
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Comparison of objects for tests
|