Skip to content

Commit 5dd3a1c

Browse files
committed
Name 'fuzzy' objects more after what RSpec calls them
1 parent 861886c commit 5dd3a1c

21 files changed

+116
-100
lines changed

lib/super_diff/rspec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@ def self.configuration
2525
@_configuration ||= Configuration.new
2626
end
2727

28-
def self.partial_hash?(value)
29-
partial_placeholder?(value) &&
28+
def self.a_hash_including_something?(value)
29+
fuzzy_object?(value) &&
3030
value.respond_to?(:expecteds) &&
3131
value.expecteds.one? &&
3232
value.expecteds.first.is_a?(::Hash)
3333
end
3434

35-
def self.partial_array?(value)
36-
partial_placeholder?(value) &&
35+
def self.a_collection_including_something?(value)
36+
fuzzy_object?(value) &&
3737
value.respond_to?(:expecteds) &&
3838
!(value.expecteds.one? && value.expecteds.first.is_a?(::Hash))
3939
end
4040

41-
def self.partial_object?(value)
42-
partial_placeholder?(value) &&
41+
def self.an_object_having_some_attributes?(value)
42+
fuzzy_object?(value) &&
4343
value.base_matcher.is_a?(::RSpec::Matchers::BuiltIn::HaveAttributes)
4444
end
4545

46-
def self.collection_containing_exactly?(value)
47-
partial_placeholder?(value) &&
46+
def self.a_collection_containing_exactly_something?(value)
47+
fuzzy_object?(value) &&
4848
value.base_matcher.is_a?(::RSpec::Matchers::BuiltIn::ContainExactly)
4949
end
5050

51-
def self.partial_placeholder?(value)
51+
def self.fuzzy_object?(value)
5252
value.is_a?(::RSpec::Matchers::AliasedMatcher)
5353
end
5454
end

lib/super_diff/rspec/differ.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ def diff
1414
extra_classes: [
1515
*RSpec.configuration.extra_differ_classes,
1616
Differs::CollectionContainingExactly,
17-
Differs::PartialArray,
18-
Differs::PartialHash,
19-
Differs::PartialObject,
17+
Differs::CollectionIncluding,
18+
Differs::HashIncluding,
19+
Differs::ObjectHavingAttributes,
2020
],
2121
extra_operational_sequencer_classes: [
2222
*RSpec.configuration.extra_operational_sequencer_classes,
2323
OperationalSequencers::CollectionContainingExactly,
24-
OperationalSequencers::PartialArray,
25-
OperationalSequencers::PartialHash,
26-
OperationalSequencers::PartialObject,
24+
OperationalSequencers::CollectionIncluding,
25+
OperationalSequencers::HashIncluding,
26+
OperationalSequencers::ObjectHavingAttributes,
2727
],
2828
extra_diff_formatter_classes: RSpec.configuration.extra_diff_formatter_classes,
2929
)

lib/super_diff/rspec/differs.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ module Differs
55
:CollectionContainingExactly,
66
"super_diff/rspec/differs/collection_containing_exactly",
77
)
8-
autoload :PartialArray, "super_diff/rspec/differs/partial_array"
9-
autoload :PartialHash, "super_diff/rspec/differs/partial_hash"
10-
autoload :PartialObject, "super_diff/rspec/differs/partial_object"
8+
autoload(
9+
:CollectionIncluding,
10+
"super_diff/rspec/differs/collection_including",
11+
)
12+
autoload :HashIncluding, "super_diff/rspec/differs/hash_including"
13+
autoload(
14+
:ObjectHavingAttributes,
15+
"super_diff/rspec/differs/object_having_attributes",
16+
)
1117
end
1218
end
1319
end

lib/super_diff/rspec/differs/collection_containing_exactly.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module RSpec
33
module Differs
44
class CollectionContainingExactly < SuperDiff::Differs::Array
55
def self.applies_to?(expected, actual)
6-
SuperDiff::RSpec.collection_containing_exactly?(expected) &&
6+
SuperDiff::RSpec.a_collection_containing_exactly_something?(expected) &&
77
actual.is_a?(::Array)
88
end
99

lib/super_diff/rspec/differs/partial_hash.rb renamed to lib/super_diff/rspec/differs/collection_including.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
module SuperDiff
22
module RSpec
33
module Differs
4-
class PartialHash < SuperDiff::Differs::Hash
4+
class CollectionIncluding < SuperDiff::Differs::Array
55
def self.applies_to?(expected, actual)
6-
SuperDiff::RSpec.partial_hash?(expected) && actual.is_a?(::Hash)
6+
SuperDiff::RSpec.a_collection_including_something?(expected) &&
7+
actual.is_a?(::Array)
78
end
89

910
private
1011

1112
def operations
12-
OperationalSequencers::PartialHash.call(
13+
OperationalSequencers::CollectionIncluding.call(
1314
expected: expected,
1415
actual: actual,
1516
extra_operational_sequencer_classes: extra_operational_sequencer_classes,

lib/super_diff/rspec/differs/partial_array.rb renamed to lib/super_diff/rspec/differs/hash_including.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
module SuperDiff
22
module RSpec
33
module Differs
4-
class PartialArray < SuperDiff::Differs::Array
4+
class HashIncluding < SuperDiff::Differs::Hash
55
def self.applies_to?(expected, actual)
6-
SuperDiff::RSpec.partial_array?(expected) && actual.is_a?(::Array)
6+
SuperDiff::RSpec.a_hash_including_something?(expected) &&
7+
actual.is_a?(::Hash)
78
end
89

910
private
1011

1112
def operations
12-
OperationalSequencers::PartialArray.call(
13+
OperationalSequencers::HashIncluding.call(
1314
expected: expected,
1415
actual: actual,
1516
extra_operational_sequencer_classes: extra_operational_sequencer_classes,

lib/super_diff/rspec/differs/partial_object.rb renamed to lib/super_diff/rspec/differs/object_having_attributes.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module SuperDiff
22
module RSpec
33
module Differs
4-
class PartialObject < SuperDiff::Differs::DefaultObject
4+
class ObjectHavingAttributes < SuperDiff::Differs::DefaultObject
55
def self.applies_to?(expected, _actual)
6-
SuperDiff::RSpec.partial_object?(expected)
6+
SuperDiff::RSpec.an_object_having_some_attributes?(expected)
77
end
88

99
private
1010

1111
def operations
12-
OperationalSequencers::PartialObject.call(
12+
OperationalSequencers::ObjectHavingAttributes.call(
1313
expected: expected,
1414
actual: actual,
1515
extra_operational_sequencer_classes: extra_operational_sequencer_classes,

lib/super_diff/rspec/monkey_patches.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,11 @@ class RespondTo
695695
prepend SuperDiff::RSpec::AugmentedMatcher
696696

697697
prepend(Module.new do
698+
def initialize(*)
699+
super
700+
@failing_method_names = nil
701+
end
702+
698703
def matcher_text_builder_class
699704
SuperDiff::RSpec::MatcherTextBuilders::RespondTo
700705
end

lib/super_diff/rspec/object_inspection/inspectors.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ module Inspectors
77
"super_diff/rspec/object_inspection/inspectors/collection_containing_exactly",
88
)
99
autoload(
10-
:PartialArray,
11-
"super_diff/rspec/object_inspection/inspectors/partial_array",
10+
:CollectionIncluding,
11+
"super_diff/rspec/object_inspection/inspectors/collection_including",
1212
)
1313
autoload(
14-
:PartialHash,
15-
"super_diff/rspec/object_inspection/inspectors/partial_hash",
14+
:HashIncluding,
15+
"super_diff/rspec/object_inspection/inspectors/hash_including",
1616
)
1717
autoload(
18-
:PartialObject,
19-
"super_diff/rspec/object_inspection/inspectors/partial_object",
18+
:ObjectHavingAttributes,
19+
"super_diff/rspec/object_inspection/inspectors/object_having_attributes",
2020
)
2121
end
2222
end

lib/super_diff/rspec/object_inspection/inspectors/partial_array.rb renamed to lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module SuperDiff
22
module RSpec
33
module ObjectInspection
44
module Inspectors
5-
PartialArray = SuperDiff::ObjectInspection::InspectionTree.new do
5+
CollectionIncluding = SuperDiff::ObjectInspection::InspectionTree.new do
66
def self.applies_to?(object)
7-
SuperDiff::RSpec.partial_array?(object)
7+
SuperDiff::RSpec.a_collection_including?(object)
88
end
99

1010
add_text "#<a collection including ("

0 commit comments

Comments
 (0)