object_comparator 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d307d150e4a8ed3e8998cd34bc593b07c3472f67
4
- data.tar.gz: a25b42a56c697a3a9d6a1370b8c4dc579f9e540d
3
+ metadata.gz: 069674508c26382b74ab79d0435d1c554d43de7d
4
+ data.tar.gz: b04c1a6267fd0d20744672791f5f7eb048fdd08b
5
5
  SHA512:
6
- metadata.gz: 3fd96339f0031c41a0162b4f67eec2667afaad9f6b1f51c0a91b2842ee462e7711e9752413db5bdc63a1bfaf417f63e9262149308cf9fa777310f9891bd28af8
7
- data.tar.gz: f9d2adab76bb595274decf7959dfe30baaa09e556d82f4a860c681ce738b800033f477c05d0378b2ae6d8f25bceeb340bca4f2d9002218502968ced1069b8f73
6
+ metadata.gz: fdba30df9b8cec8db2e68c80591aeebe264c98af057a7397c1394c75ddc0b6e9340d429d5c3482e321d9f8652c3abed40ec34402fe306f47d921e0491b70b4ae
7
+ data.tar.gz: 482d16258f0976f1528ed33cc6c7246998a82c2ef4219487adc4630d3f6dc5140f06593103d3035984ade8e4279e3b1baf5049b140ace02eca817ce62e56645f
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
+ - 2.3.5
4
5
  - 2.4.1
5
6
  before_install: gem install bundler -v 1.14.6
6
7
  script:
@@ -2,18 +2,22 @@ require 'object_comparator'
2
2
 
3
3
  class ObjectComparator
4
4
  module Minitest
5
- def assert_equal_objects(obj1, obj2, message = nil)
6
- obj1 = InspectionString.new(obj1.inspect)
7
- obj2 = InspectionString.new(obj2.inspect)
5
+ def assert_equal_objects(expected, actual, message = nil)
6
+ expected = InspectionString.new(expected.inspect)
7
+ actual = InspectionString.new(actual.inspect)
8
8
 
9
- assert_equal(obj1, obj2, message)
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(obj1, obj2, message = nil)
13
- obj1 = InspectionString.new(obj1.inspect)
14
- obj2 = InspectionString.new(obj2.inspect)
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(obj1, obj2, message)
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
@@ -1,3 +1,3 @@
1
1
  class ObjectComparator
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'object_comparator/version'
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.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-06-04 00:00:00.000000000 Z
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.6.11
112
+ rubygems_version: 2.5.1
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Comparison of objects for tests