super_diff 0.4.1 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -10
- data/lib/super_diff.rb +20 -11
- data/lib/super_diff/active_record.rb +20 -24
- data/lib/super_diff/active_record/diff_formatters/active_record_relation.rb +3 -3
- data/lib/super_diff/active_record/differs/active_record_relation.rb +3 -5
- data/lib/super_diff/active_record/object_inspection/inspectors/active_record_model.rb +32 -22
- data/lib/super_diff/active_record/object_inspection/inspectors/active_record_relation.rb +17 -7
- data/lib/super_diff/active_record/operation_tree_builders.rb +14 -0
- data/lib/super_diff/active_record/{operational_sequencers → operation_tree_builders}/active_record_model.rb +2 -2
- data/lib/super_diff/active_record/{operational_sequencers → operation_tree_builders}/active_record_relation.rb +4 -4
- data/lib/super_diff/active_record/{operation_sequences.rb → operation_trees.rb} +2 -2
- data/lib/super_diff/active_record/{operation_sequences → operation_trees}/active_record_relation.rb +2 -2
- data/lib/super_diff/active_support.rb +16 -19
- data/lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb +3 -3
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +3 -5
- data/lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb +17 -7
- data/lib/super_diff/active_support/operation_tree_builders.rb +10 -0
- data/lib/super_diff/active_support/{operational_sequencers → operation_tree_builders}/hash_with_indifferent_access.rb +2 -2
- data/lib/super_diff/active_support/{operation_sequences.rb → operation_trees.rb} +2 -2
- data/lib/super_diff/active_support/{operation_sequences → operation_trees}/hash_with_indifferent_access.rb +2 -2
- data/lib/super_diff/configuration.rb +60 -0
- data/lib/super_diff/diff_formatters.rb +3 -3
- data/lib/super_diff/diff_formatters/array.rb +3 -3
- data/lib/super_diff/diff_formatters/base.rb +3 -2
- data/lib/super_diff/diff_formatters/collection.rb +2 -2
- data/lib/super_diff/diff_formatters/custom_object.rb +3 -3
- data/lib/super_diff/diff_formatters/default_object.rb +6 -8
- data/lib/super_diff/diff_formatters/defaults.rb +10 -0
- data/lib/super_diff/diff_formatters/hash.rb +3 -3
- data/lib/super_diff/diff_formatters/main.rb +41 -0
- data/lib/super_diff/diff_formatters/multiline_string.rb +3 -3
- data/lib/super_diff/differs.rb +4 -11
- data/lib/super_diff/differs/array.rb +2 -11
- data/lib/super_diff/differs/base.rb +20 -3
- data/lib/super_diff/differs/custom_object.rb +2 -11
- data/lib/super_diff/differs/default_object.rb +2 -8
- data/lib/super_diff/differs/defaults.rb +12 -0
- data/lib/super_diff/differs/hash.rb +2 -11
- data/lib/super_diff/differs/main.rb +48 -0
- data/lib/super_diff/differs/multiline_string.rb +2 -14
- data/lib/super_diff/differs/time_like.rb +15 -0
- data/lib/super_diff/equality_matchers.rb +3 -9
- data/lib/super_diff/equality_matchers/array.rb +1 -7
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +1 -7
- data/lib/super_diff/equality_matchers/defaults.rb +12 -0
- data/lib/super_diff/equality_matchers/hash.rb +1 -7
- data/lib/super_diff/equality_matchers/main.rb +21 -0
- data/lib/super_diff/equality_matchers/multiline_string.rb +1 -7
- data/lib/super_diff/errors.rb +16 -0
- data/lib/super_diff/errors/no_diff_formatter_available_error.rb +21 -0
- data/lib/super_diff/errors/no_differ_available_error.rb +24 -0
- data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +22 -0
- data/lib/super_diff/implementation_checks.rb +19 -0
- data/lib/super_diff/object_inspection.rb +1 -10
- data/lib/super_diff/object_inspection/inspection_tree.rb +6 -2
- data/lib/super_diff/object_inspection/inspectors.rb +5 -1
- data/lib/super_diff/object_inspection/inspectors/array.rb +20 -10
- data/lib/super_diff/object_inspection/inspectors/base.rb +36 -0
- data/lib/super_diff/object_inspection/inspectors/custom_object.rb +24 -14
- data/lib/super_diff/object_inspection/inspectors/default_object.rb +44 -30
- data/lib/super_diff/object_inspection/inspectors/defaults.rb +15 -0
- data/lib/super_diff/object_inspection/inspectors/hash.rb +20 -10
- data/lib/super_diff/object_inspection/inspectors/main.rb +35 -0
- data/lib/super_diff/object_inspection/inspectors/primitive.rb +20 -5
- data/lib/super_diff/object_inspection/inspectors/string.rb +15 -5
- data/lib/super_diff/object_inspection/inspectors/time_like.rb +23 -0
- data/lib/super_diff/object_inspection/nodes/inspection.rb +9 -2
- data/lib/super_diff/operation_tree_builders.rb +18 -0
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/array.rb +38 -59
- data/lib/super_diff/operation_tree_builders/base.rb +98 -0
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/custom_object.rb +3 -3
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/default_object.rb +8 -3
- data/lib/super_diff/operation_tree_builders/defaults.rb +5 -0
- data/lib/super_diff/operation_tree_builders/hash.rb +226 -0
- data/lib/super_diff/operation_tree_builders/main.rb +42 -0
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/multiline_string.rb +3 -3
- data/lib/super_diff/operation_tree_builders/time_like.rb +34 -0
- data/lib/super_diff/operation_trees.rb +13 -0
- data/lib/super_diff/{operation_sequences → operation_trees}/array.rb +5 -1
- data/lib/super_diff/{operation_sequences → operation_trees}/base.rb +9 -1
- data/lib/super_diff/{operation_sequences → operation_trees}/custom_object.rb +5 -1
- data/lib/super_diff/{operation_sequences → operation_trees}/default_object.rb +10 -8
- data/lib/super_diff/operation_trees/defaults.rb +5 -0
- data/lib/super_diff/{operation_sequences → operation_trees}/hash.rb +5 -1
- data/lib/super_diff/operation_trees/main.rb +35 -0
- data/lib/super_diff/operation_trees/multiline_string.rb +18 -0
- data/lib/super_diff/operations/unary_operation.rb +3 -0
- data/lib/super_diff/recursion_guard.rb +2 -0
- data/lib/super_diff/rspec.rb +45 -13
- data/lib/super_diff/rspec/augmented_matcher.rb +1 -1
- data/lib/super_diff/rspec/differ.rb +2 -17
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +2 -7
- data/lib/super_diff/rspec/differs/collection_including.rb +2 -7
- data/lib/super_diff/rspec/differs/hash_including.rb +2 -7
- data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -7
- data/lib/super_diff/rspec/matcher_text_builders/match.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_template.rb +1 -1
- data/lib/super_diff/rspec/monkey_patches.rb +4 -2
- data/lib/super_diff/rspec/object_inspection.rb +0 -1
- data/lib/super_diff/rspec/object_inspection/inspectors.rb +16 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/collection_containing_exactly.rb +17 -8
- data/lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb +15 -9
- data/lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb +20 -10
- data/lib/super_diff/rspec/object_inspection/inspectors/instance_of.rb +23 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/kind_of.rb +23 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/object_having_attributes.rb +20 -11
- data/lib/super_diff/rspec/object_inspection/inspectors/primitive.rb +13 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/value_within.rb +29 -0
- data/lib/super_diff/rspec/operation_tree_builders.rb +22 -0
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_containing_exactly.rb +5 -5
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_including.rb +2 -2
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/hash_including.rb +3 -11
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/object_having_attributes.rb +4 -8
- data/lib/super_diff/version.rb +1 -1
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +354 -227
- data/spec/integration/rspec/include_matcher_spec.rb +2 -2
- data/spec/integration/rspec/match_array_matcher_spec.rb +42 -0
- data/spec/integration/rspec/unhandled_errors_spec.rb +68 -12
- data/spec/support/command_runner.rb +3 -0
- data/spec/support/integration/helpers.rb +12 -96
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +14 -29
- data/spec/support/integration/test_programs/base.rb +120 -0
- data/spec/support/integration/test_programs/plain.rb +13 -0
- data/spec/support/integration/test_programs/rspec_active_record.rb +17 -0
- data/spec/support/integration/test_programs/rspec_rails.rb +17 -0
- data/spec/support/models/active_record/person.rb +4 -11
- data/spec/support/models/active_record/shipping_address.rb +10 -14
- data/spec/support/object_id.rb +6 -5
- data/spec/unit/{equality_matcher_spec.rb → equality_matchers/main_spec.rb} +157 -1
- data/spec/unit/object_inspection_spec.rb +77 -1
- data/spec/unit/rspec/matchers/raise_error_spec.rb +16 -0
- data/super_diff.gemspec +2 -1
- metadata +74 -53
- data/lib/super_diff/active_record/object_inspection/map_extension.rb +0 -18
- data/lib/super_diff/active_record/operational_sequencers.rb +0 -14
- data/lib/super_diff/active_support/object_inspection/map_extension.rb +0 -15
- data/lib/super_diff/active_support/operational_sequencers.rb +0 -10
- data/lib/super_diff/diff_formatter.rb +0 -32
- data/lib/super_diff/differ.rb +0 -51
- data/lib/super_diff/differs/time.rb +0 -24
- data/lib/super_diff/equality_matcher.rb +0 -32
- data/lib/super_diff/no_differ_available_error.rb +0 -22
- data/lib/super_diff/no_operational_sequencer_available_error.rb +0 -20
- data/lib/super_diff/object_inspection/inspector.rb +0 -27
- data/lib/super_diff/object_inspection/inspectors/time.rb +0 -13
- data/lib/super_diff/object_inspection/map.rb +0 -30
- data/lib/super_diff/operation_sequences.rb +0 -9
- data/lib/super_diff/operational_sequencer.rb +0 -48
- data/lib/super_diff/operational_sequencers.rb +0 -17
- data/lib/super_diff/operational_sequencers/base.rb +0 -89
- data/lib/super_diff/operational_sequencers/hash.rb +0 -85
- data/lib/super_diff/operational_sequencers/time_like.rb +0 -30
- data/lib/super_diff/rspec/configuration.rb +0 -31
- data/lib/super_diff/rspec/object_inspection/map_extension.rb +0 -23
- data/lib/super_diff/rspec/operational_sequencers.rb +0 -22
@@ -9,13 +9,8 @@ module SuperDiff
|
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
expected: expected,
|
15
|
-
actual: actual,
|
16
|
-
extra_operational_sequencer_classes: extra_operational_sequencer_classes,
|
17
|
-
extra_diff_formatter_classes: extra_diff_formatter_classes,
|
18
|
-
)
|
12
|
+
def operation_tree_builder_class
|
13
|
+
OperationTreeBuilders::HashIncluding
|
19
14
|
end
|
20
15
|
end
|
21
16
|
end
|
@@ -8,13 +8,8 @@ module SuperDiff
|
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
expected: expected,
|
14
|
-
actual: actual,
|
15
|
-
extra_operational_sequencer_classes: extra_operational_sequencer_classes,
|
16
|
-
extra_diff_formatter_classes: extra_diff_formatter_classes,
|
17
|
-
)
|
11
|
+
def operation_tree_builder_class
|
12
|
+
OperationTreeBuilders::ObjectHavingAttributes
|
18
13
|
end
|
19
14
|
end
|
20
15
|
end
|
@@ -661,7 +661,9 @@ module RSpec
|
|
661
661
|
|
662
662
|
def expected_for_matcher_text
|
663
663
|
if @expected_message
|
664
|
-
"#<#{@expected_error.name} #{@expected_message
|
664
|
+
"#<#{@expected_error.name} #{description_of(@expected_message)}>"
|
665
|
+
elsif @expected_error.is_a? Regexp
|
666
|
+
"#<Exception #{description_of(@expected_error)}>"
|
665
667
|
else
|
666
668
|
"#<#{@expected_error.name}>"
|
667
669
|
end
|
@@ -727,7 +729,7 @@ module RSpec
|
|
727
729
|
end
|
728
730
|
|
729
731
|
def match_array(items)
|
730
|
-
BuiltIn::MatchArray.new(items)
|
732
|
+
BuiltIn::MatchArray.new(items.is_a?(String) ? [items] : items)
|
731
733
|
end
|
732
734
|
alias_matcher :an_array_matching, :match_array
|
733
735
|
end
|
@@ -14,10 +14,26 @@ module SuperDiff
|
|
14
14
|
:HashIncluding,
|
15
15
|
"super_diff/rspec/object_inspection/inspectors/hash_including",
|
16
16
|
)
|
17
|
+
autoload(
|
18
|
+
:InstanceOf,
|
19
|
+
"super_diff/rspec/object_inspection/inspectors/instance_of",
|
20
|
+
)
|
21
|
+
autoload(
|
22
|
+
:KindOf,
|
23
|
+
"super_diff/rspec/object_inspection/inspectors/kind_of",
|
24
|
+
)
|
17
25
|
autoload(
|
18
26
|
:ObjectHavingAttributes,
|
19
27
|
"super_diff/rspec/object_inspection/inspectors/object_having_attributes",
|
20
28
|
)
|
29
|
+
autoload(
|
30
|
+
:Primitive,
|
31
|
+
"super_diff/rspec/object_inspection/inspectors/primitive",
|
32
|
+
)
|
33
|
+
autoload(
|
34
|
+
:ValueWithin,
|
35
|
+
"super_diff/rspec/object_inspection/inspectors/value_within",
|
36
|
+
)
|
21
37
|
end
|
22
38
|
end
|
23
39
|
end
|
@@ -2,17 +2,26 @@ module SuperDiff
|
|
2
2
|
module RSpec
|
3
3
|
module ObjectInspection
|
4
4
|
module Inspectors
|
5
|
-
CollectionContainingExactly
|
6
|
-
|
7
|
-
|
5
|
+
class CollectionContainingExactly < SuperDiff::ObjectInspection::Inspectors::Base
|
6
|
+
def self.applies_to?(value)
|
7
|
+
SuperDiff::RSpec.a_collection_containing_exactly_something?(value)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
protected
|
11
|
+
|
12
|
+
def inspection_tree
|
13
|
+
SuperDiff::ObjectInspection::InspectionTree.new do
|
14
|
+
add_text "#<a collection containing exactly ("
|
12
15
|
|
13
|
-
|
14
|
-
|
16
|
+
nested do |aliased_matcher|
|
17
|
+
insert_array_inspection_of(aliased_matcher.expected)
|
18
|
+
end
|
19
|
+
|
20
|
+
add_break
|
21
|
+
add_text ")>"
|
22
|
+
end
|
15
23
|
end
|
24
|
+
end
|
16
25
|
end
|
17
26
|
end
|
18
27
|
end
|
@@ -2,19 +2,25 @@ module SuperDiff
|
|
2
2
|
module RSpec
|
3
3
|
module ObjectInspection
|
4
4
|
module Inspectors
|
5
|
-
CollectionIncluding
|
6
|
-
def self.applies_to?(
|
7
|
-
SuperDiff::RSpec.
|
5
|
+
class CollectionIncluding < SuperDiff::ObjectInspection::Inspectors::Base
|
6
|
+
def self.applies_to?(value)
|
7
|
+
SuperDiff::RSpec.a_collection_including_something?(value)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
protected
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def inspection_tree
|
13
|
+
SuperDiff::ObjectInspection::InspectionTree.new do
|
14
|
+
add_text "#<a collection including ("
|
15
|
+
|
16
|
+
nested do |aliased_matcher|
|
17
|
+
insert_array_inspection_of(aliased_matcher.expecteds)
|
18
|
+
end
|
15
19
|
|
16
|
-
|
17
|
-
|
20
|
+
add_break
|
21
|
+
add_text ")>"
|
22
|
+
end
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
@@ -2,18 +2,28 @@ module SuperDiff
|
|
2
2
|
module RSpec
|
3
3
|
module ObjectInspection
|
4
4
|
module Inspectors
|
5
|
-
HashIncluding
|
6
|
-
|
7
|
-
|
8
|
-
nested do |aliased_matcher|
|
9
|
-
insert_hash_inspection_of(
|
10
|
-
aliased_matcher.expecteds.first,
|
11
|
-
initial_break: nil,
|
12
|
-
)
|
5
|
+
class HashIncluding < SuperDiff::ObjectInspection::Inspectors::Base
|
6
|
+
def self.applies_to?(value)
|
7
|
+
SuperDiff::RSpec.a_hash_including_something?(value)
|
13
8
|
end
|
14
9
|
|
15
|
-
|
16
|
-
|
10
|
+
protected
|
11
|
+
|
12
|
+
def inspection_tree
|
13
|
+
SuperDiff::ObjectInspection::InspectionTree.new do
|
14
|
+
add_text "#<a hash including ("
|
15
|
+
|
16
|
+
nested do |aliased_matcher|
|
17
|
+
insert_hash_inspection_of(
|
18
|
+
aliased_matcher.expecteds.first,
|
19
|
+
initial_break: nil,
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
add_break
|
24
|
+
add_text ")>"
|
25
|
+
end
|
26
|
+
end
|
17
27
|
end
|
18
28
|
end
|
19
29
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module RSpec
|
3
|
+
module ObjectInspection
|
4
|
+
module Inspectors
|
5
|
+
class InstanceOf < SuperDiff::ObjectInspection::Inspectors::Base
|
6
|
+
def self.applies_to?(value)
|
7
|
+
SuperDiff::RSpec.an_instance_of_something?(value)
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def inspection_tree
|
13
|
+
SuperDiff::ObjectInspection::InspectionTree.new do
|
14
|
+
add_text do |aliased_matcher|
|
15
|
+
"#<an instance of #{aliased_matcher.expected}>"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module RSpec
|
3
|
+
module ObjectInspection
|
4
|
+
module Inspectors
|
5
|
+
class KindOf < SuperDiff::ObjectInspection::Inspectors::Base
|
6
|
+
def self.applies_to?(value)
|
7
|
+
SuperDiff::RSpec.a_kind_of_something?(value)
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def inspection_tree
|
13
|
+
SuperDiff::ObjectInspection::InspectionTree.new do
|
14
|
+
add_text do |aliased_matcher|
|
15
|
+
"#<a kind of #{aliased_matcher.expected}>"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -2,20 +2,29 @@ module SuperDiff
|
|
2
2
|
module RSpec
|
3
3
|
module ObjectInspection
|
4
4
|
module Inspectors
|
5
|
-
ObjectHavingAttributes
|
6
|
-
|
7
|
-
|
5
|
+
class ObjectHavingAttributes < SuperDiff::ObjectInspection::Inspectors::Base
|
6
|
+
def self.applies_to?(value)
|
7
|
+
SuperDiff::RSpec.an_object_having_some_attributes?(value)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
10
|
+
protected
|
11
|
+
|
12
|
+
def inspection_tree
|
13
|
+
SuperDiff::ObjectInspection::InspectionTree.new do
|
14
|
+
add_text "#<an object having attributes ("
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
nested do |aliased_matcher|
|
17
|
+
insert_hash_inspection_of(
|
18
|
+
aliased_matcher.expected,
|
19
|
+
initial_break: nil,
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
add_break
|
24
|
+
add_text ")>"
|
25
|
+
end
|
18
26
|
end
|
27
|
+
end
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module RSpec
|
3
|
+
module ObjectInspection
|
4
|
+
module Inspectors
|
5
|
+
class Primitive < SuperDiff::ObjectInspection::Inspectors::Primitive
|
6
|
+
def self.applies_to?(value)
|
7
|
+
super || value.is_a?(::RSpec::Mocks::Double)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module RSpec
|
3
|
+
module ObjectInspection
|
4
|
+
module Inspectors
|
5
|
+
class ValueWithin < SuperDiff::ObjectInspection::Inspectors::Base
|
6
|
+
def self.applies_to?(value)
|
7
|
+
SuperDiff::RSpec.a_value_within_something?(value)
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def inspection_tree
|
13
|
+
SuperDiff::ObjectInspection::InspectionTree.new do
|
14
|
+
add_text "#<a value within "
|
15
|
+
|
16
|
+
add_inspection_of do |aliased_matcher|
|
17
|
+
aliased_matcher.base_matcher.instance_variable_get("@delta")
|
18
|
+
end
|
19
|
+
|
20
|
+
add_text " of "
|
21
|
+
add_inspection_of(&:expected)
|
22
|
+
add_text ">"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module RSpec
|
3
|
+
module OperationTreeBuilders
|
4
|
+
autoload(
|
5
|
+
:CollectionContainingExactly,
|
6
|
+
"super_diff/rspec/operation_tree_builders/collection_containing_exactly",
|
7
|
+
)
|
8
|
+
autoload(
|
9
|
+
:CollectionIncluding,
|
10
|
+
"super_diff/rspec/operation_tree_builders/collection_including",
|
11
|
+
)
|
12
|
+
autoload(
|
13
|
+
:HashIncluding,
|
14
|
+
"super_diff/rspec/operation_tree_builders/hash_including",
|
15
|
+
)
|
16
|
+
autoload(
|
17
|
+
:ObjectHavingAttributes,
|
18
|
+
"super_diff/rspec/operation_tree_builders/object_having_attributes",
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module RSpec
|
3
|
-
module
|
4
|
-
class CollectionContainingExactly < SuperDiff::
|
3
|
+
module OperationTreeBuilders
|
4
|
+
class CollectionContainingExactly < SuperDiff::OperationTreeBuilders::Base
|
5
5
|
def self.applies_to?(expected, actual)
|
6
6
|
SuperDiff::RSpec.a_collection_containing_exactly_something?(expected) &&
|
7
7
|
actual.is_a?(::Array)
|
8
8
|
end
|
9
9
|
|
10
|
-
def initialize(actual:, **
|
10
|
+
def initialize(actual:, **)
|
11
11
|
super
|
12
12
|
populate_pairings_maximizer_in_expected_with(actual)
|
13
13
|
end
|
@@ -28,8 +28,8 @@ module SuperDiff
|
|
28
28
|
operations
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
|
31
|
+
def build_operation_tree
|
32
|
+
OperationTrees::Array.new([])
|
33
33
|
end
|
34
34
|
|
35
35
|
private
|
data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_including.rb
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module RSpec
|
3
|
-
module
|
4
|
-
class CollectionIncluding < SuperDiff::
|
3
|
+
module OperationTreeBuilders
|
4
|
+
class CollectionIncluding < SuperDiff::OperationTreeBuilders::Array
|
5
5
|
def self.applies_to?(expected, actual)
|
6
6
|
SuperDiff::RSpec.a_collection_including_something?(expected) &&
|
7
7
|
actual.is_a?(::Array)
|
data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/hash_including.rb
RENAMED
@@ -1,16 +1,14 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module RSpec
|
3
|
-
module
|
4
|
-
class HashIncluding < SuperDiff::
|
3
|
+
module OperationTreeBuilders
|
4
|
+
class HashIncluding < SuperDiff::OperationTreeBuilders::Hash
|
5
5
|
def self.applies_to?(expected, actual)
|
6
6
|
SuperDiff::RSpec.a_hash_including_something?(expected) &&
|
7
7
|
actual.is_a?(::Hash)
|
8
8
|
end
|
9
9
|
|
10
10
|
def initialize(expected:, **rest)
|
11
|
-
super
|
12
|
-
|
13
|
-
@expected = expected.expecteds.first
|
11
|
+
super(expected: expected.expecteds.first, **rest)
|
14
12
|
end
|
15
13
|
|
16
14
|
private
|
@@ -21,12 +19,6 @@ module SuperDiff
|
|
21
19
|
expected[key] == actual[key]
|
22
20
|
)
|
23
21
|
end
|
24
|
-
|
25
|
-
def should_add_insert_operation?(key)
|
26
|
-
expected.include?(key) &&
|
27
|
-
actual.include?(key) &&
|
28
|
-
expected[key] != actual[key]
|
29
|
-
end
|
30
22
|
end
|
31
23
|
end
|
32
24
|
end
|