super_diff 0.10.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -166
- data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -1
- data/lib/super_diff/active_record/inspection_tree_builders/active_record_model.rb +57 -0
- data/lib/super_diff/active_record/inspection_tree_builders/active_record_relation.rb +34 -0
- data/lib/super_diff/active_record/inspection_tree_builders.rb +14 -0
- data/lib/super_diff/active_record/monkey_patches.rb +6 -3
- data/lib/super_diff/active_record/object_inspection.rb +16 -4
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +6 -2
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -1
- data/lib/super_diff/active_record/operation_tree_flatteners/active_record_relation.rb +1 -1
- data/lib/super_diff/active_record/operation_trees/active_record_relation.rb +1 -1
- data/lib/super_diff/active_record.rb +12 -16
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +1 -1
- data/lib/super_diff/active_support/inspection_tree_builders/hash_with_indifferent_access.rb +44 -0
- data/lib/super_diff/active_support/inspection_tree_builders/ordered_options.rb +44 -0
- data/lib/super_diff/active_support/inspection_tree_builders.rb +14 -0
- data/lib/super_diff/active_support/object_inspection.rb +16 -4
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_flatteners/hash_with_indifferent_access.rb +1 -1
- data/lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb +1 -1
- data/lib/super_diff/active_support.rb +11 -14
- data/lib/super_diff/basic/diff_formatters/collection.rb +135 -0
- data/lib/super_diff/basic/diff_formatters/multiline_string.rb +34 -0
- data/lib/super_diff/basic/diff_formatters.rb +11 -0
- data/lib/super_diff/basic/differs/array.rb +17 -0
- data/lib/super_diff/basic/differs/custom_object.rb +19 -0
- data/lib/super_diff/basic/differs/date_like.rb +17 -0
- data/lib/super_diff/basic/differs/default_object.rb +24 -0
- data/lib/super_diff/basic/differs/hash.rb +17 -0
- data/lib/super_diff/basic/differs/multiline_string.rb +18 -0
- data/lib/super_diff/basic/differs/time_like.rb +17 -0
- data/lib/super_diff/basic/differs.rb +24 -0
- data/lib/super_diff/basic/inspection_tree_builders/array.rb +53 -0
- data/lib/super_diff/basic/inspection_tree_builders/custom_object.rb +41 -0
- data/lib/super_diff/basic/inspection_tree_builders/date_like.rb +51 -0
- data/lib/super_diff/basic/inspection_tree_builders/default_object.rb +77 -0
- data/lib/super_diff/basic/inspection_tree_builders/hash.rb +63 -0
- data/lib/super_diff/basic/inspection_tree_builders/primitive.rb +19 -0
- data/lib/super_diff/basic/inspection_tree_builders/time_like.rb +58 -0
- data/lib/super_diff/basic/inspection_tree_builders.rb +20 -0
- data/lib/super_diff/basic/operation_tree_builders/array.rb +111 -0
- data/lib/super_diff/basic/operation_tree_builders/custom_object.rb +42 -0
- data/lib/super_diff/basic/operation_tree_builders/date_like.rb +17 -0
- data/lib/super_diff/basic/operation_tree_builders/default_object.rb +117 -0
- data/lib/super_diff/basic/operation_tree_builders/hash.rb +222 -0
- data/lib/super_diff/basic/operation_tree_builders/multiline_string.rb +90 -0
- data/lib/super_diff/basic/operation_tree_builders/time_like.rb +26 -0
- data/lib/super_diff/basic/operation_tree_builders.rb +34 -0
- data/lib/super_diff/basic/operation_tree_flatteners/array.rb +17 -0
- data/lib/super_diff/basic/operation_tree_flatteners/collection.rb +140 -0
- data/lib/super_diff/basic/operation_tree_flatteners/custom_object.rb +30 -0
- data/lib/super_diff/basic/operation_tree_flatteners/default_object.rb +32 -0
- data/lib/super_diff/basic/operation_tree_flatteners/hash.rb +35 -0
- data/lib/super_diff/basic/operation_tree_flatteners/multiline_string.rb +20 -0
- data/lib/super_diff/basic/operation_tree_flatteners.rb +24 -0
- data/lib/super_diff/basic/operation_trees/array.rb +17 -0
- data/lib/super_diff/basic/operation_trees/custom_object.rb +17 -0
- data/lib/super_diff/basic/operation_trees/default_object.rb +42 -0
- data/lib/super_diff/basic/operation_trees/hash.rb +17 -0
- data/lib/super_diff/basic/operation_trees/multiline_string.rb +17 -0
- data/lib/super_diff/basic/operation_trees.rb +25 -0
- data/lib/super_diff/basic.rb +48 -0
- data/lib/super_diff/{differs/base.rb → core/abstract_differ.rb} +2 -2
- data/lib/super_diff/core/abstract_inspection_tree_builder.rb +26 -0
- data/lib/super_diff/{operation_trees/base.rb → core/abstract_operation_tree.rb} +6 -2
- data/lib/super_diff/{operation_tree_builders/base.rb → core/abstract_operation_tree_builder.rb} +4 -8
- data/lib/super_diff/{operation_tree_flatteners/base.rb → core/abstract_operation_tree_flattener.rb} +2 -2
- data/lib/super_diff/{operations → core}/binary_operation.rb +1 -1
- data/lib/super_diff/core/colorized_document_extensions.rb +20 -0
- data/lib/super_diff/core/configuration.rb +192 -0
- data/lib/super_diff/core/differ_dispatcher.rb +31 -0
- data/lib/super_diff/core/gem_version.rb +47 -0
- data/lib/super_diff/core/helpers.rb +88 -0
- data/lib/super_diff/core/implementation_checks.rb +21 -0
- data/lib/super_diff/{object_inspection → core}/inspection_tree.rb +32 -26
- data/lib/super_diff/core/inspection_tree_builder_dispatcher.rb +23 -0
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/as_lines_when_rendering_to_lines.rb +12 -5
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/as_prefix_when_rendering_to_lines.rb +3 -3
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/as_prelude_when_rendering_to_lines.rb +3 -3
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/as_single_line.rb +3 -3
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/base.rb +2 -2
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/inspection.rb +7 -11
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/nesting.rb +2 -2
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/only_when.rb +2 -2
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/text.rb +2 -2
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/when_empty.rb +2 -2
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/when_non_empty.rb +2 -2
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/when_rendering_to_lines.rb +2 -2
- data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/when_rendering_to_string.rb +2 -2
- data/lib/super_diff/core/inspection_tree_nodes.rb +55 -0
- data/lib/super_diff/core/line.rb +85 -0
- data/lib/super_diff/{errors → core}/no_differ_available_error.rb +1 -1
- data/lib/super_diff/core/no_inspection_tree_builder_available_error.rb +21 -0
- data/lib/super_diff/core/no_operation_tree_available_error.rb +20 -0
- data/lib/super_diff/{errors/no_operational_sequencer_available_error.rb → core/no_operation_tree_builder_available_error.rb} +6 -4
- data/lib/super_diff/{operation_tree_builders/main.rb → core/operation_tree_builder_dispatcher.rb} +9 -13
- data/lib/super_diff/core/operation_tree_finder.rb +27 -0
- data/lib/super_diff/core/prefix_for_next_inspection_tree_node.rb +6 -0
- data/lib/super_diff/core/prelude_for_next_inspection_tree_node.rb +6 -0
- data/lib/super_diff/core/recursion_guard.rb +52 -0
- data/lib/super_diff/core/tiered_lines.rb +6 -0
- data/lib/super_diff/core/tiered_lines_elider.rb +472 -0
- data/lib/super_diff/core/tiered_lines_formatter.rb +77 -0
- data/lib/super_diff/{operations → core}/unary_operation.rb +1 -1
- data/lib/super_diff/core.rb +69 -0
- data/lib/super_diff/differs.rb +19 -11
- data/lib/super_diff/equality_matchers/array.rb +3 -3
- data/lib/super_diff/equality_matchers/default.rb +8 -3
- data/lib/super_diff/equality_matchers/hash.rb +3 -3
- data/lib/super_diff/equality_matchers/multiline_string.rb +3 -3
- data/lib/super_diff/equality_matchers/primitive.rb +3 -3
- data/lib/super_diff/equality_matchers/singleline_string.rb +2 -2
- data/lib/super_diff/errors.rb +12 -12
- data/lib/super_diff/object_inspection.rb +63 -14
- data/lib/super_diff/operation_tree_builders.rb +19 -14
- data/lib/super_diff/operation_tree_flatteners.rb +19 -16
- data/lib/super_diff/operation_trees.rb +19 -9
- data/lib/super_diff/operations.rb +12 -2
- data/lib/super_diff/rspec/augmented_matcher.rb +1 -1
- data/lib/super_diff/rspec/differ.rb +4 -5
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +1 -1
- data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
- data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
- data/lib/super_diff/rspec/differs/object_having_attributes.rb +1 -1
- data/lib/super_diff/rspec/inspection_tree_builders/collection_containing_exactly.rb +34 -0
- data/lib/super_diff/rspec/inspection_tree_builders/collection_including.rb +40 -0
- data/lib/super_diff/rspec/inspection_tree_builders/double.rb +100 -0
- data/lib/super_diff/rspec/inspection_tree_builders/generic_describable_matcher.rb +17 -0
- data/lib/super_diff/rspec/inspection_tree_builders/hash_including.rb +40 -0
- data/lib/super_diff/rspec/inspection_tree_builders/instance_of.rb +25 -0
- data/lib/super_diff/rspec/inspection_tree_builders/kind_of.rb +25 -0
- data/lib/super_diff/rspec/inspection_tree_builders/object_having_attributes.rb +34 -0
- data/lib/super_diff/rspec/inspection_tree_builders/primitive.rb +9 -0
- data/lib/super_diff/rspec/inspection_tree_builders/value_within.rb +30 -0
- data/lib/super_diff/rspec/inspection_tree_builders.rb +40 -0
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +3 -7
- data/lib/super_diff/rspec/monkey_patches.rb +59 -8
- data/lib/super_diff/rspec/object_inspection.rb +14 -4
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +4 -4
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +1 -1
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +1 -1
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +2 -2
- data/lib/super_diff/rspec.rb +28 -25
- data/lib/super_diff/version.rb +1 -1
- data/lib/super_diff.rb +78 -21
- data/spec/examples.txt +704 -493
- data/spec/integration/rails/engines_spec.rb +8 -3
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +19 -19
- data/spec/integration/rspec/eq_matcher_spec.rb +111 -39
- data/spec/integration/rspec/generic_describable_matchers_spec.rb +177 -0
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +25 -25
- data/spec/integration/rspec/include_matcher_spec.rb +23 -23
- data/spec/integration/rspec/magic_metadata_spec.rb +51 -0
- data/spec/integration/rspec/match_array_matcher_spec.rb +30 -30
- data/spec/integration/rspec/match_matcher_spec.rb +93 -93
- data/spec/integration/rspec/raise_error_matcher_spec.rb +813 -69
- data/spec/internal/log/test.log +0 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/integration/helpers.rb +19 -11
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +1 -1
- data/spec/support/integration/matchers.rb +34 -0
- data/spec/support/integration/test_programs/base.rb +6 -6
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +3 -13
- data/spec/support/models/active_record/person.rb +8 -1
- data/spec/support/shared_examples/active_record.rb +38 -38
- data/spec/support/shared_examples/active_support.rb +125 -4
- data/spec/support/shared_examples/elided_diffs.rb +48 -48
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +88 -88
- data/spec/support/shared_examples/key.rb +10 -10
- data/spec/support/unit/helpers.rb +12 -1
- data/spec/support/unit/matchers/be_deprecated_in_favor_of.rb +39 -0
- data/spec/unit/active_record/object_inspection_spec.rb +5 -5
- data/spec/unit/active_support/object_inspection_spec.rb +170 -0
- data/spec/unit/{operation_tree_flatteners → basic/operation_tree_flatteners}/array_spec.rb +8 -8
- data/spec/unit/{operation_tree_flatteners → basic/operation_tree_flatteners}/custom_object_spec.rb +9 -9
- data/spec/unit/{operation_tree_flatteners → basic/operation_tree_flatteners}/default_object_spec.rb +9 -9
- data/spec/unit/{operation_tree_flatteners → basic/operation_tree_flatteners}/hash_spec.rb +8 -8
- data/spec/unit/{operation_tree_flatteners → basic/operation_tree_flatteners}/multiline_string_spec.rb +4 -4
- data/spec/unit/{helpers_spec.rb → core/helpers_spec.rb} +2 -2
- data/spec/unit/{tiered_lines_elider_spec.rb → core/tiered_lines_elider_spec.rb} +2 -2
- data/spec/unit/{tiered_lines_formatter_spec.rb → core/tiered_lines_formatter_spec.rb} +1 -1
- data/spec/unit/deprecations_spec.rb +176 -0
- data/spec/unit/equality_matchers/main_spec.rb +5 -5
- data/spec/unit/rspec/matchers/raise_error_spec.rb +43 -11
- data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +91 -0
- data/spec/unit/rspec/object_inspection_spec.rb +2 -2
- data/spec/unit/super_diff_spec.rb +64 -0
- data/super_diff.gemspec +6 -0
- metadata +137 -112
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +0 -39
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +0 -27
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +0 -16
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +0 -31
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +0 -12
- data/lib/super_diff/colorized_document_extensions.rb +0 -18
- data/lib/super_diff/configuration.rb +0 -149
- data/lib/super_diff/diff_formatters/collection.rb +0 -132
- data/lib/super_diff/diff_formatters/multiline_string.rb +0 -31
- data/lib/super_diff/differs/array.rb +0 -15
- data/lib/super_diff/differs/custom_object.rb +0 -17
- data/lib/super_diff/differs/default_object.rb +0 -19
- data/lib/super_diff/differs/defaults.rb +0 -12
- data/lib/super_diff/differs/empty.rb +0 -13
- data/lib/super_diff/differs/hash.rb +0 -15
- data/lib/super_diff/differs/main.rb +0 -31
- data/lib/super_diff/differs/multiline_string.rb +0 -16
- data/lib/super_diff/differs/time_like.rb +0 -15
- data/lib/super_diff/errors/no_diff_formatter_available_error.rb +0 -21
- data/lib/super_diff/gem_version.rb +0 -45
- data/lib/super_diff/helpers.rb +0 -86
- data/lib/super_diff/implementation_checks.rb +0 -19
- data/lib/super_diff/line.rb +0 -83
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +0 -34
- data/lib/super_diff/object_inspection/inspection_tree_builders/base.rb +0 -27
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +0 -31
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +0 -54
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +0 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +0 -38
- data/lib/super_diff/object_inspection/inspection_tree_builders/main.rb +0 -30
- data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +0 -21
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +0 -47
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +0 -44
- data/lib/super_diff/object_inspection/nodes.rb +0 -50
- data/lib/super_diff/object_inspection/prefix_for_next_node.rb +0 -6
- data/lib/super_diff/object_inspection/prelude_for_next_node.rb +0 -6
- data/lib/super_diff/operation_tree_builders/array.rb +0 -107
- data/lib/super_diff/operation_tree_builders/custom_object.rb +0 -40
- data/lib/super_diff/operation_tree_builders/default_object.rb +0 -119
- data/lib/super_diff/operation_tree_builders/defaults.rb +0 -5
- data/lib/super_diff/operation_tree_builders/hash.rb +0 -218
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +0 -86
- data/lib/super_diff/operation_tree_builders/time_like.rb +0 -24
- data/lib/super_diff/operation_tree_flatteners/array.rb +0 -15
- data/lib/super_diff/operation_tree_flatteners/collection.rb +0 -136
- data/lib/super_diff/operation_tree_flatteners/custom_object.rb +0 -28
- data/lib/super_diff/operation_tree_flatteners/default_object.rb +0 -31
- data/lib/super_diff/operation_tree_flatteners/hash.rb +0 -33
- data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +0 -18
- data/lib/super_diff/operation_trees/array.rb +0 -15
- data/lib/super_diff/operation_trees/custom_object.rb +0 -15
- data/lib/super_diff/operation_trees/default_object.rb +0 -40
- data/lib/super_diff/operation_trees/defaults.rb +0 -5
- data/lib/super_diff/operation_trees/hash.rb +0 -15
- data/lib/super_diff/operation_trees/main.rb +0 -35
- data/lib/super_diff/operation_trees/multiline_string.rb +0 -15
- data/lib/super_diff/recursion_guard.rb +0 -50
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_containing_exactly.rb +0 -29
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +0 -36
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +0 -98
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +0 -37
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +0 -28
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +0 -28
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/object_having_attributes.rb +0 -29
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/primitive.rb +0 -10
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +0 -33
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +0 -44
- data/lib/super_diff/tiered_lines.rb +0 -4
- data/lib/super_diff/tiered_lines_elider.rb +0 -462
- data/lib/super_diff/tiered_lines_formatter.rb +0 -75
@@ -18,14 +18,14 @@ module SuperDiff
|
|
18
18
|
protected
|
19
19
|
|
20
20
|
def expected_line
|
21
|
-
Helpers.style(
|
21
|
+
Core::Helpers.style(
|
22
22
|
:expected,
|
23
23
|
"Expected: " + SuperDiff.inspect_object(expected, as_lines: false)
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
27
27
|
def actual_line
|
28
|
-
Helpers.style(
|
28
|
+
Core::Helpers.style(
|
29
29
|
:actual,
|
30
30
|
" Actual: " + SuperDiff.inspect_object(actual, as_lines: false)
|
31
31
|
)
|
@@ -45,7 +45,12 @@ module SuperDiff
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def diff
|
48
|
-
|
48
|
+
SuperDiff.diff(
|
49
|
+
expected,
|
50
|
+
actual,
|
51
|
+
indent_level: 0,
|
52
|
+
raise_if_nothing_applies: false
|
53
|
+
)
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|
@@ -10,13 +10,13 @@ module SuperDiff
|
|
10
10
|
Differing hashes.
|
11
11
|
|
12
12
|
#{
|
13
|
-
Helpers.style(
|
13
|
+
Core::Helpers.style(
|
14
14
|
:expected,
|
15
15
|
"Expected: " + SuperDiff.inspect_object(expected, as_lines: false)
|
16
16
|
)
|
17
17
|
}
|
18
18
|
#{
|
19
|
-
Helpers.style(
|
19
|
+
Core::Helpers.style(
|
20
20
|
:actual,
|
21
21
|
" Actual: " + SuperDiff.inspect_object(actual, as_lines: false)
|
22
22
|
)
|
@@ -31,7 +31,7 @@ module SuperDiff
|
|
31
31
|
protected
|
32
32
|
|
33
33
|
def diff
|
34
|
-
Differs::Hash.call(expected, actual, indent_level: 0)
|
34
|
+
Basic::Differs::Hash.call(expected, actual, indent_level: 0)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -11,13 +11,13 @@ module SuperDiff
|
|
11
11
|
|
12
12
|
#{
|
13
13
|
# TODO: This whole thing should not be red or green, just the values
|
14
|
-
Helpers.style(
|
14
|
+
Core::Helpers.style(
|
15
15
|
:expected,
|
16
16
|
"Expected: " + SuperDiff.inspect_object(expected, as_lines: false)
|
17
17
|
)
|
18
18
|
}
|
19
19
|
#{
|
20
|
-
Helpers.style(
|
20
|
+
Core::Helpers.style(
|
21
21
|
:actual,
|
22
22
|
" Actual: " + SuperDiff.inspect_object(actual, as_lines: false)
|
23
23
|
)
|
@@ -32,7 +32,7 @@ module SuperDiff
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def diff
|
35
|
-
Differs::MultilineString.call(expected, actual, indent_level: 0)
|
35
|
+
Basic::Differs::MultilineString.call(expected, actual, indent_level: 0)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -8,16 +8,16 @@ module SuperDiff
|
|
8
8
|
|
9
9
|
def fail
|
10
10
|
<<~OUTPUT.strip
|
11
|
-
Differing #{Helpers.plural_type_for(actual)}.
|
11
|
+
Differing #{Core::Helpers.plural_type_for(actual)}.
|
12
12
|
|
13
13
|
#{
|
14
|
-
Helpers.style(
|
14
|
+
Core::Helpers.style(
|
15
15
|
:expected,
|
16
16
|
"Expected: " + SuperDiff.inspect_object(expected, as_lines: false)
|
17
17
|
)
|
18
18
|
}
|
19
19
|
#{
|
20
|
-
Helpers.style(
|
20
|
+
Core::Helpers.style(
|
21
21
|
:actual,
|
22
22
|
" Actual: " + SuperDiff.inspect_object(actual, as_lines: false)
|
23
23
|
)
|
@@ -10,13 +10,13 @@ module SuperDiff
|
|
10
10
|
Differing strings.
|
11
11
|
|
12
12
|
#{
|
13
|
-
Helpers.style(
|
13
|
+
Core::Helpers.style(
|
14
14
|
:expected,
|
15
15
|
"Expected: " + SuperDiff.inspect_object(expected, as_lines: false)
|
16
16
|
)
|
17
17
|
}
|
18
18
|
#{
|
19
|
-
Helpers.style(
|
19
|
+
Core::Helpers.style(
|
20
20
|
:actual,
|
21
21
|
" Actual: " + SuperDiff.inspect_object(actual, as_lines: false)
|
22
22
|
)
|
data/lib/super_diff/errors.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module Errors
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
def self.const_missing(missing_const_name)
|
4
|
+
if Core.const_defined?(missing_const_name)
|
5
|
+
warn <<~EOT
|
6
|
+
WARNING: SuperDiff::Errors::#{missing_const_name} is deprecated and will be removed in the next major release.
|
7
|
+
Please use SuperDiff::Core::#{missing_const_name} instead.
|
8
|
+
#{caller_locations.join("\n")}
|
9
|
+
EOT
|
10
|
+
Core.const_get(missing_const_name)
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,18 +1,67 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module ObjectInspection
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
module InspectionTreeBuilders
|
4
|
+
def self.const_missing(missing_const_name)
|
5
|
+
if missing_const_name == :Base
|
6
|
+
warn <<~EOT
|
7
|
+
WARNING: SuperDiff::ObjectInspection::InspectionTreeBuilders::#{missing_const_name} is deprecated and will be removed in the next major release.
|
8
|
+
Please use SuperDiff::Core::AbstractInspectionTreeBuilder instead.
|
9
|
+
#{caller_locations.join("\n")}
|
10
|
+
EOT
|
11
|
+
Core::AbstractInspectionTreeBuilder
|
12
|
+
elsif Basic::InspectionTreeBuilders.const_defined?(missing_const_name)
|
13
|
+
warn <<~EOT
|
14
|
+
WARNING: SuperDiff::ObjectInspection::InspectionTreeBuilders::#{missing_const_name} is deprecated and will be removed in the next major release.
|
15
|
+
Please use SuperDiff::Basic::InspectionTreeBuilders::#{missing_const_name} instead.
|
16
|
+
#{caller_locations.join("\n")}
|
17
|
+
EOT
|
18
|
+
Basic::InspectionTreeBuilders.const_get(missing_const_name)
|
19
|
+
else
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module Nodes
|
26
|
+
def self.const_missing(missing_const_name)
|
27
|
+
if Core::InspectionTreeNodes.const_defined?(missing_const_name)
|
28
|
+
warn <<~EOT
|
29
|
+
WARNING: SuperDiff::ObjectInspection::Nodes::#{missing_const_name} is deprecated and will be removed in the next major release.
|
30
|
+
Please use SuperDiff::Core::InspectionTreeNodes::#{missing_const_name} instead.
|
31
|
+
#{caller_locations.join("\n")}
|
32
|
+
EOT
|
33
|
+
Core::InspectionTreeNodes.const_get(missing_const_name)
|
34
|
+
else
|
35
|
+
super
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.const_missing(missing_const_name)
|
41
|
+
if missing_const_name == :PrefixForNextNode
|
42
|
+
warn <<~EOT
|
43
|
+
WARNING: SuperDiff::ObjectInspection::PrefixForNextNode is deprecated and will be removed in the next major release.
|
44
|
+
Please use SuperDiff::Core::PrefixForNextInspectionTreeNode instead.
|
45
|
+
#{caller_locations.join("\n")}
|
46
|
+
EOT
|
47
|
+
Core::PrefixForNextInspectionTreeNode
|
48
|
+
elsif missing_const_name == :PreludeForNextNode
|
49
|
+
warn <<~EOT
|
50
|
+
WARNING: SuperDiff::ObjectInspection::PreludeForNextNode is deprecated and will be removed in the next major release.
|
51
|
+
Please use SuperDiff::Core::PreludeForNextInspectionTreeNode instead.
|
52
|
+
#{caller_locations.join("\n")}
|
53
|
+
EOT
|
54
|
+
Core::PreludeForNextInspectionTreeNode
|
55
|
+
elsif Core.const_defined?(missing_const_name)
|
56
|
+
warn <<~EOT
|
57
|
+
WARNING: SuperDiff::ObjectInspection::#{missing_const_name} is deprecated and will be removed in the next major release.
|
58
|
+
Please use SuperDiff::Core::#{missing_const_name} instead.
|
59
|
+
#{caller_locations.join("\n")}
|
60
|
+
EOT
|
61
|
+
Core.const_get(missing_const_name)
|
62
|
+
else
|
63
|
+
super
|
64
|
+
end
|
65
|
+
end
|
17
66
|
end
|
18
67
|
end
|
@@ -1,18 +1,23 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module OperationTreeBuilders
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
def self.const_missing(missing_const_name)
|
4
|
+
if missing_const_name == :Base
|
5
|
+
warn <<~EOT
|
6
|
+
WARNING: SuperDiff::OperationTreeBuilders::#{missing_const_name} is deprecated and will be removed in the next major release.
|
7
|
+
Please use SuperDiff::Core::AbstractOperationTreeBuilder instead.
|
8
|
+
#{caller_locations.join("\n")}
|
9
|
+
EOT
|
10
|
+
Core::AbstractOperationTreeBuilder
|
11
|
+
elsif Basic::OperationTreeBuilders.const_defined?(missing_const_name)
|
12
|
+
warn <<~EOT
|
13
|
+
WARNING: SuperDiff::OperationTreeBuilders::#{missing_const_name} is deprecated and will be removed in the next major release.
|
14
|
+
Please use SuperDiff::Basic::OperationTreeBuilders::#{missing_const_name} instead.
|
15
|
+
#{caller_locations.join("\n")}
|
16
|
+
EOT
|
17
|
+
Basic::OperationTreeBuilders.const_get(missing_const_name)
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
15
22
|
end
|
16
23
|
end
|
17
|
-
|
18
|
-
require "super_diff/operation_tree_builders/defaults"
|
@@ -1,20 +1,23 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module OperationTreeFlatteners
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
3
|
+
def self.const_missing(missing_const_name)
|
4
|
+
if missing_const_name == :Base
|
5
|
+
warn <<~EOT
|
6
|
+
WARNING: SuperDiff::OperationTreeFlatteners::#{missing_const_name} is deprecated and will be removed in the next major release.
|
7
|
+
Please use SuperDiff::Core::AbstractOperationTreeFlattener instead.
|
8
|
+
#{caller_locations.join("\n")}
|
9
|
+
EOT
|
10
|
+
Core::AbstractOperationTreeFlattener
|
11
|
+
elsif Basic::OperationTreeFlatteners.const_defined?(missing_const_name)
|
12
|
+
warn <<~EOT
|
13
|
+
WARNING: SuperDiff::OperationTreeFlatteners::#{missing_const_name} is deprecated and will be removed in the next major release.
|
14
|
+
Please use SuperDiff::Basic::OperationTreeFlatteners::#{missing_const_name} instead.
|
15
|
+
#{caller_locations.join("\n")}
|
16
|
+
EOT
|
17
|
+
Basic::OperationTreeFlatteners.const_get(missing_const_name)
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
19
22
|
end
|
20
23
|
end
|
@@ -1,13 +1,23 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module OperationTrees
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
def self.const_missing(missing_const_name)
|
4
|
+
if missing_const_name == :Base
|
5
|
+
warn <<~EOT
|
6
|
+
WARNING: SuperDiff::OperationTrees::#{missing_const_name} is deprecated and will be removed in the next major release.
|
7
|
+
Please use SuperDiff::Core::AbstractOperationTree instead.
|
8
|
+
#{caller_locations.join("\n")}
|
9
|
+
EOT
|
10
|
+
Core::AbstractOperationTree
|
11
|
+
elsif Basic::OperationTrees.const_defined?(missing_const_name)
|
12
|
+
warn <<~EOT
|
13
|
+
WARNING: SuperDiff::OperationTrees::#{missing_const_name} is deprecated and will be removed in the next major release.
|
14
|
+
Please use SuperDiff::Basic::OperationTrees::#{missing_const_name} instead.
|
15
|
+
#{caller_locations.join("\n")}
|
16
|
+
EOT
|
17
|
+
Basic::OperationTrees.const_get(missing_const_name)
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
10
22
|
end
|
11
23
|
end
|
12
|
-
|
13
|
-
require "super_diff/operation_trees/defaults"
|
@@ -1,6 +1,16 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module Operations
|
3
|
-
|
4
|
-
|
3
|
+
def self.const_missing(missing_const_name)
|
4
|
+
if Core.const_defined?(missing_const_name)
|
5
|
+
warn <<~EOT
|
6
|
+
WARNING: SuperDiff::Operations::#{missing_const_name} is deprecated and will be removed in the next major release.
|
7
|
+
Please use SuperDiff::Core::#{missing_const_name} instead.
|
8
|
+
#{caller_locations.join("\n")}
|
9
|
+
EOT
|
10
|
+
Core.const_get(missing_const_name)
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
5
15
|
end
|
6
16
|
end
|
@@ -7,13 +7,12 @@ module SuperDiff
|
|
7
7
|
|
8
8
|
def diff
|
9
9
|
if worth_diffing?
|
10
|
-
diff =
|
11
|
-
SuperDiff::Differs::Main.call(expected, actual, omit_empty: true)
|
10
|
+
diff = SuperDiff.diff(expected, actual)
|
12
11
|
"\n\n" + diff
|
13
12
|
else
|
14
13
|
""
|
15
14
|
end
|
16
|
-
rescue
|
15
|
+
rescue Core::NoDifferAvailableError
|
17
16
|
""
|
18
17
|
end
|
19
18
|
|
@@ -39,10 +38,10 @@ module SuperDiff
|
|
39
38
|
end
|
40
39
|
|
41
40
|
def helpers
|
42
|
-
@_helpers ||=
|
41
|
+
@_helpers ||= RSpecHelpers.new
|
43
42
|
end
|
44
43
|
|
45
|
-
class
|
44
|
+
class RSpecHelpers
|
46
45
|
include ::RSpec::Matchers::Composable
|
47
46
|
|
48
47
|
public :values_match?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module RSpec
|
3
3
|
module Differs
|
4
|
-
class CollectionContainingExactly <
|
4
|
+
class CollectionContainingExactly < Basic::Differs::Array
|
5
5
|
def self.applies_to?(expected, actual)
|
6
6
|
SuperDiff::RSpec.a_collection_containing_exactly_something?(
|
7
7
|
expected
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module RSpec
|
3
3
|
module Differs
|
4
|
-
class CollectionIncluding <
|
4
|
+
class CollectionIncluding < Basic::Differs::Array
|
5
5
|
def self.applies_to?(expected, actual)
|
6
6
|
(
|
7
7
|
SuperDiff::RSpec.a_collection_including_something?(expected) ||
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module SuperDiff
|
2
2
|
module RSpec
|
3
3
|
module Differs
|
4
|
-
class ObjectHavingAttributes <
|
4
|
+
class ObjectHavingAttributes < Basic::Differs::DefaultObject
|
5
5
|
def self.applies_to?(expected, _actual)
|
6
6
|
SuperDiff::RSpec.an_object_having_some_attributes?(expected)
|
7
7
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module RSpec
|
3
|
+
module InspectionTreeBuilders
|
4
|
+
class CollectionContainingExactly < Core::AbstractInspectionTreeBuilder
|
5
|
+
def self.applies_to?(value)
|
6
|
+
SuperDiff::RSpec.a_collection_containing_exactly_something?(value)
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
Core::InspectionTree.new do |t1|
|
11
|
+
# stree-ignore
|
12
|
+
t1.as_lines_when_rendering_to_lines(
|
13
|
+
collection_bookend: :open
|
14
|
+
) do |t2|
|
15
|
+
t2.add_text "#<a collection containing exactly ("
|
16
|
+
end
|
17
|
+
|
18
|
+
# stree-ignore
|
19
|
+
t1.nested do |t2|
|
20
|
+
t2.insert_array_inspection_of(object.expected)
|
21
|
+
end
|
22
|
+
|
23
|
+
# stree-ignore
|
24
|
+
t1.as_lines_when_rendering_to_lines(
|
25
|
+
collection_bookend: :close
|
26
|
+
) do |t2|
|
27
|
+
t2.add_text ")>"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module RSpec
|
3
|
+
module InspectionTreeBuilders
|
4
|
+
class CollectionIncluding < Core::AbstractInspectionTreeBuilder
|
5
|
+
def self.applies_to?(value)
|
6
|
+
SuperDiff::RSpec.a_collection_including_something?(value) ||
|
7
|
+
SuperDiff::RSpec.array_including_something?(value)
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
Core::InspectionTree.new do |t1|
|
12
|
+
# stree-ignore
|
13
|
+
t1.as_lines_when_rendering_to_lines(
|
14
|
+
collection_bookend: :open
|
15
|
+
) do |t2|
|
16
|
+
t2.add_text "#<a collection including ("
|
17
|
+
end
|
18
|
+
|
19
|
+
t1.nested do |t2|
|
20
|
+
if SuperDiff::RSpec.a_collection_including_something?(object)
|
21
|
+
t2.insert_array_inspection_of(object.expecteds)
|
22
|
+
else
|
23
|
+
t2.insert_array_inspection_of(
|
24
|
+
object.instance_variable_get(:@expected)
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# stree-ignore
|
30
|
+
t1.as_lines_when_rendering_to_lines(
|
31
|
+
collection_bookend: :close
|
32
|
+
) do |t2|
|
33
|
+
t2.add_text ")>"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module RSpec
|
3
|
+
module InspectionTreeBuilders
|
4
|
+
class Double < Core::AbstractInspectionTreeBuilder
|
5
|
+
def self.applies_to?(value)
|
6
|
+
value.is_a?(::RSpec::Mocks::Double)
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
Core::InspectionTree.new do |t1|
|
11
|
+
t1.only_when method(:empty?) do |t2|
|
12
|
+
t2.as_lines_when_rendering_to_lines do |t3|
|
13
|
+
t3.add_text("#<#{inspected_class} #{inspected_name}>")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
t1.only_when method(:nonempty?) do |t2|
|
18
|
+
t2.as_lines_when_rendering_to_lines(
|
19
|
+
collection_bookend: :open
|
20
|
+
) do |t3|
|
21
|
+
t3.add_text("#<#{inspected_class} #{inspected_name}")
|
22
|
+
|
23
|
+
# stree-ignore
|
24
|
+
t3.when_rendering_to_lines do |t4|
|
25
|
+
t4.add_text " {"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# stree-ignore
|
30
|
+
t2.when_rendering_to_string do |t3|
|
31
|
+
t3.add_text " "
|
32
|
+
end
|
33
|
+
|
34
|
+
# stree-ignore
|
35
|
+
t2.nested do |t3|
|
36
|
+
t3.insert_hash_inspection_of doubled_methods
|
37
|
+
end
|
38
|
+
|
39
|
+
t2.as_lines_when_rendering_to_lines(
|
40
|
+
collection_bookend: :close
|
41
|
+
) do |t3|
|
42
|
+
# stree-ignore
|
43
|
+
t3.when_rendering_to_lines do |t4|
|
44
|
+
t4.add_text "}"
|
45
|
+
end
|
46
|
+
|
47
|
+
t3.add_text ">"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def empty?
|
56
|
+
doubled_methods.empty?
|
57
|
+
end
|
58
|
+
|
59
|
+
def nonempty?
|
60
|
+
!empty?
|
61
|
+
end
|
62
|
+
|
63
|
+
def inspected_class
|
64
|
+
case object
|
65
|
+
when ::RSpec::Mocks::InstanceVerifyingDouble
|
66
|
+
"InstanceDouble"
|
67
|
+
when ::RSpec::Mocks::ClassVerifyingDouble
|
68
|
+
"ClassDouble"
|
69
|
+
when ::RSpec::Mocks::ObjectVerifyingDouble
|
70
|
+
"ObjectDouble"
|
71
|
+
else
|
72
|
+
"Double"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def inspected_name
|
77
|
+
if object.instance_variable_get("@name")
|
78
|
+
object.instance_variable_get("@name").inspect
|
79
|
+
else
|
80
|
+
"(anonymous)"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def doubled_methods
|
85
|
+
@_doubled_methods ||=
|
86
|
+
doubled_method_names.reduce({}) do |hash, key|
|
87
|
+
hash.merge(key => object.public_send(key))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def doubled_method_names
|
92
|
+
object
|
93
|
+
.__send__(:__mock_proxy)
|
94
|
+
.instance_variable_get("@method_doubles")
|
95
|
+
.keys
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module RSpec
|
3
|
+
module InspectionTreeBuilders
|
4
|
+
class GenericDescribableMatcher < Core::AbstractInspectionTreeBuilder
|
5
|
+
def self.applies_to?(value)
|
6
|
+
::RSpec::Matchers.is_a_describable_matcher?(value)
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
Core::InspectionTree.new do |t1|
|
11
|
+
t1.add_text "#<#{object.description}>"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|