super_diff 0.9.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +65 -26
- data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/differs.rb +1 -1
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +22 -18
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +14 -7
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/object_inspection.rb +1 -1
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_record/operation_trees.rb +1 -1
- data/lib/super_diff/active_record.rb +7 -15
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/differs.rb +1 -1
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +20 -11
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/ordered_options.rb +46 -0
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +5 -1
- data/lib/super_diff/active_support/object_inspection.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_support/operation_trees.rb +1 -1
- data/lib/super_diff/active_support.rb +6 -10
- data/lib/super_diff/colorized_document_extensions.rb +2 -4
- data/lib/super_diff/configuration.rb +14 -8
- data/lib/super_diff/csi/color.rb +4 -4
- data/lib/super_diff/csi/colorized_document.rb +12 -16
- data/lib/super_diff/csi/document.rb +8 -19
- data/lib/super_diff/csi/eight_bit_color.rb +19 -19
- data/lib/super_diff/csi/four_bit_color.rb +82 -31
- data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
- data/lib/super_diff/csi/uncolorized_document.rb +2 -6
- data/lib/super_diff/csi.rb +10 -14
- data/lib/super_diff/diff_formatters/collection.rb +35 -41
- data/lib/super_diff/differs/date_like.rb +15 -0
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/defaults.rb +2 -1
- data/lib/super_diff/differs/main.rb +2 -13
- data/lib/super_diff/differs.rb +1 -0
- data/lib/super_diff/equality_matchers/array.rb +10 -12
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +2 -4
- data/lib/super_diff/equality_matchers/defaults.rb +1 -1
- data/lib/super_diff/equality_matchers/hash.rb +10 -12
- data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
- data/lib/super_diff/equality_matchers/primitive.rb +10 -12
- data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
- data/lib/super_diff/equality_matchers.rb +1 -1
- data/lib/super_diff/errors.rb +2 -6
- data/lib/super_diff/gem_version.rb +3 -3
- data/lib/super_diff/helpers.rb +10 -10
- data/lib/super_diff/implementation_checks.rb +2 -2
- data/lib/super_diff/line.rb +3 -3
- data/lib/super_diff/object_inspection/inspection_tree.rb +64 -73
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +29 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +17 -13
- data/lib/super_diff/object_inspection/inspection_tree_builders/date_like.rb +51 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +43 -27
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +2 -1
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +35 -18
- data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +3 -5
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +30 -36
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +13 -9
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +11 -22
- data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
- data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
- data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
- data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
- data/lib/super_diff/object_inspection/nodes.rb +7 -7
- data/lib/super_diff/object_inspection.rb +3 -3
- data/lib/super_diff/operation_tree_builders/array.rb +12 -11
- data/lib/super_diff/operation_tree_builders/base.rb +17 -15
- data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
- data/lib/super_diff/operation_tree_builders/date_like.rb +15 -0
- data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
- data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
- data/lib/super_diff/operation_tree_builders/main.rb +4 -11
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
- data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
- data/lib/super_diff/operation_tree_builders.rb +2 -1
- data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
- data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
- data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
- data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
- data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
- data/lib/super_diff/operation_tree_flatteners.rb +3 -3
- data/lib/super_diff/operation_trees/base.rb +3 -5
- data/lib/super_diff/operation_trees/default_object.rb +1 -3
- data/lib/super_diff/operations/binary_operation.rb +2 -2
- data/lib/super_diff/operations/unary_operation.rb +1 -1
- data/lib/super_diff/rails.rb +2 -1
- data/lib/super_diff/recursion_guard.rb +5 -4
- data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
- data/lib/super_diff/rspec/differ.rb +6 -13
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
- 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.rb +3 -3
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +2 -10
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
- data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
- data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
- data/lib/super_diff/rspec/monkey_patches.rb +180 -123
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_containing_exactly.rb +14 -7
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +21 -13
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +35 -36
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/generic_describable_matcher.rb +19 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +21 -15
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +11 -10
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +11 -10
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/object_having_attributes.rb +14 -7
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +10 -11
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +13 -9
- data/lib/super_diff/rspec/object_inspection.rb +1 -1
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
- data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
- data/lib/super_diff/rspec.rb +17 -18
- data/lib/super_diff/tiered_lines_elider.rb +87 -115
- data/lib/super_diff/tiered_lines_formatter.rb +5 -9
- data/lib/super_diff/version.rb +1 -1
- data/lib/super_diff.rb +13 -9
- data/spec/examples.txt +541 -483
- data/spec/integration/rails/active_record_spec.rb +3 -1
- data/spec/integration/rails/engines_spec.rb +25 -0
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
- data/spec/integration/rspec/be_matcher_spec.rb +360 -320
- data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +257 -254
- data/spec/integration/rspec/eq_matcher_spec.rb +695 -585
- data/spec/integration/rspec/generic_describable_matchers_spec.rb +177 -0
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +312 -304
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
- data/spec/integration/rspec/include_matcher_spec.rb +327 -225
- data/spec/integration/rspec/magic_metadata_spec.rb +51 -0
- data/spec/integration/rspec/match_array_matcher_spec.rb +294 -291
- data/spec/integration/rspec/match_matcher_spec.rb +916 -903
- data/spec/integration/rspec/raise_error_matcher_spec.rb +1208 -449
- data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
- data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
- data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
- data/spec/internal/log/test.log +0 -0
- data/spec/spec_helper.rb +20 -20
- data/spec/support/command_runner.rb +34 -57
- data/spec/support/integration/helpers.rb +44 -32
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
- data/spec/support/integration/matchers.rb +34 -0
- data/spec/support/integration/test_programs/base.rb +17 -22
- data/spec/support/integration/test_programs/plain.rb +6 -0
- data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
- data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +20 -0
- data/spec/support/models/active_record/person.rb +6 -4
- data/spec/support/models/active_record/shipping_address.rb +9 -10
- data/spec/support/models/customer.rb +2 -4
- data/spec/support/models/player.rb +3 -6
- data/spec/support/models/shipping_address.rb +4 -13
- data/spec/support/shared_examples/active_record.rb +258 -240
- data/spec/support/shared_examples/active_support.rb +174 -51
- data/spec/support/shared_examples/elided_diffs.rb +447 -423
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +500 -464
- data/spec/support/shared_examples/key.rb +123 -0
- data/spec/support/unit/helpers.rb +1 -3
- data/spec/support/unit/matchers/match_output.rb +12 -13
- data/spec/unit/active_record/object_inspection_spec.rb +222 -206
- data/spec/unit/active_support/object_inspection_spec.rb +170 -0
- data/spec/unit/equality_matchers/main_spec.rb +1049 -984
- data/spec/unit/helpers_spec.rb +14 -21
- data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
- data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
- data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
- data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
- data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
- data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
- data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
- data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
- data/spec/unit/rspec/matchers/include_spec.rb +2 -2
- data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
- data/spec/unit/rspec/matchers/raise_error_spec.rb +43 -11
- data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
- data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +91 -0
- data/spec/unit/rspec/object_inspection_spec.rb +351 -326
- data/spec/unit/super_diff_spec.rb +1594 -1437
- data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
- data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
- data/super_diff.gemspec +13 -12
- metadata +88 -75
- data/lib/super_diff/errors/no_diff_formatter_available_error.rb +0 -21
- data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +0 -22
- data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -4,54 +4,57 @@ shared_examples_for "integration with ActiveRecord" do
|
|
4
4
|
it "produces the correct output" do
|
5
5
|
as_both_colored_and_uncolored do |color_enabled|
|
6
6
|
snippet = <<~TEST.strip
|
7
|
+
actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
8
|
+
line_1: "456 Ponderosa Ct.",
|
9
|
+
city: "Oakland",
|
10
|
+
state: "CA",
|
11
|
+
zip: "91234",
|
12
|
+
)
|
7
13
|
expected = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
8
14
|
line_1: "123 Main St.",
|
9
15
|
city: "Hill Valley",
|
10
16
|
state: "CA",
|
11
17
|
zip: "90382",
|
12
18
|
)
|
13
|
-
actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
14
|
-
line_1: "456 Ponderosa Ct.",
|
15
|
-
city: "Oakland",
|
16
|
-
state: "CA",
|
17
|
-
zip: "91234",
|
18
|
-
)
|
19
19
|
expect(actual).to eq(expected)
|
20
20
|
TEST
|
21
21
|
program = make_program(snippet, color_enabled: color_enabled)
|
22
22
|
|
23
|
-
expected_output =
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
expected_output =
|
24
|
+
build_expected_output(
|
25
|
+
color_enabled: color_enabled,
|
26
|
+
snippet: "expect(actual).to eq(expected)",
|
27
|
+
expectation:
|
28
|
+
proc do
|
29
|
+
line do
|
30
|
+
plain "Expected "
|
31
|
+
actual %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234">|
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
34
|
+
line do
|
35
|
+
plain " to eq "
|
36
|
+
expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
|
37
|
+
end
|
38
|
+
end,
|
39
|
+
diff:
|
40
|
+
proc do
|
41
|
+
plain_line " #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {"
|
42
|
+
plain_line " id: nil,"
|
43
|
+
expected_line %|- city: "Hill Valley",|
|
44
|
+
actual_line %|+ city: "Oakland",|
|
45
|
+
expected_line %|- line_1: "123 Main St.",|
|
46
|
+
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
47
|
+
plain_line %| line_2: "",|
|
48
|
+
plain_line %| state: "CA",|
|
49
|
+
expected_line %|- zip: "90382"|
|
50
|
+
actual_line %|+ zip: "91234"|
|
51
|
+
plain_line " }>"
|
52
|
+
end
|
53
|
+
)
|
51
54
|
|
52
|
-
expect(program).
|
53
|
-
|
54
|
-
|
55
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
56
|
+
color_enabled
|
57
|
+
)
|
55
58
|
end
|
56
59
|
end
|
57
60
|
end
|
@@ -60,40 +63,42 @@ shared_examples_for "integration with ActiveRecord" do
|
|
60
63
|
it "produces the correct output" do
|
61
64
|
as_both_colored_and_uncolored do |color_enabled|
|
62
65
|
snippet = <<~TEST.strip
|
66
|
+
actual = SuperDiff::Test::Models::ActiveRecord::Person.new(
|
67
|
+
name: "Elliot",
|
68
|
+
age: 31,
|
69
|
+
)
|
63
70
|
expected = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
64
71
|
line_1: "123 Main St.",
|
65
72
|
city: "Hill Valley",
|
66
73
|
state: "CA",
|
67
74
|
zip: "90382",
|
68
75
|
)
|
69
|
-
actual = SuperDiff::Test::Models::ActiveRecord::Person.new(
|
70
|
-
name: "Elliot",
|
71
|
-
age: 31,
|
72
|
-
)
|
73
76
|
expect(actual).to eq(expected)
|
74
77
|
TEST
|
75
78
|
program = make_program(snippet, color_enabled: color_enabled)
|
76
79
|
|
77
|
-
expected_output =
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
expected_output =
|
81
|
+
build_expected_output(
|
82
|
+
color_enabled: color_enabled,
|
83
|
+
snippet: "expect(actual).to eq(expected)",
|
84
|
+
newline_before_expectation: true,
|
85
|
+
expectation:
|
86
|
+
proc do
|
87
|
+
line do
|
88
|
+
plain "Expected "
|
89
|
+
actual %|#<SuperDiff::Test::Models::ActiveRecord::Person id: nil, age: 31, name: "Elliot">|
|
90
|
+
end
|
86
91
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
92
|
+
line do
|
93
|
+
plain " to eq "
|
94
|
+
expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
|
95
|
+
end
|
96
|
+
end
|
97
|
+
)
|
93
98
|
|
94
|
-
expect(program).
|
95
|
-
|
96
|
-
|
99
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
100
|
+
color_enabled
|
101
|
+
)
|
97
102
|
end
|
98
103
|
end
|
99
104
|
end
|
@@ -102,37 +107,39 @@ shared_examples_for "integration with ActiveRecord" do
|
|
102
107
|
it "produces the correct output" do
|
103
108
|
as_both_colored_and_uncolored do |color_enabled|
|
104
109
|
snippet = <<~TEST.strip
|
110
|
+
actual = nil
|
105
111
|
expected = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
106
112
|
line_1: "123 Main St.",
|
107
113
|
city: "Hill Valley",
|
108
114
|
state: "CA",
|
109
115
|
zip: "90382"
|
110
116
|
)
|
111
|
-
actual = nil
|
112
117
|
expect(actual).to eq(expected)
|
113
118
|
TEST
|
114
119
|
program = make_program(snippet, color_enabled: color_enabled)
|
115
120
|
|
116
|
-
expected_output =
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
expected_output =
|
122
|
+
build_expected_output(
|
123
|
+
color_enabled: color_enabled,
|
124
|
+
snippet: "expect(actual).to eq(expected)",
|
125
|
+
newline_before_expectation: true,
|
126
|
+
expectation:
|
127
|
+
proc do
|
128
|
+
line do
|
129
|
+
plain "Expected "
|
130
|
+
actual "nil"
|
131
|
+
end
|
125
132
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
133
|
+
line do
|
134
|
+
plain " to eq "
|
135
|
+
expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
|
136
|
+
end
|
137
|
+
end
|
138
|
+
)
|
132
139
|
|
133
|
-
expect(program).
|
134
|
-
|
135
|
-
|
140
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
141
|
+
color_enabled
|
142
|
+
)
|
136
143
|
end
|
137
144
|
end
|
138
145
|
end
|
@@ -141,63 +148,66 @@ shared_examples_for "integration with ActiveRecord" do
|
|
141
148
|
it "produces the correct output" do
|
142
149
|
as_both_colored_and_uncolored do |color_enabled|
|
143
150
|
snippet = <<~TEST.strip
|
144
|
-
|
151
|
+
actual = {
|
145
152
|
name: "Marty McFly",
|
146
153
|
shipping_address: SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
147
|
-
line_1: "
|
148
|
-
city: "
|
154
|
+
line_1: "456 Ponderosa Ct.",
|
155
|
+
city: "Oakland",
|
149
156
|
state: "CA",
|
150
|
-
zip: "
|
157
|
+
zip: "91234",
|
151
158
|
)
|
152
159
|
}
|
153
|
-
|
160
|
+
expected = {
|
154
161
|
name: "Marty McFly",
|
155
162
|
shipping_address: SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
156
|
-
line_1: "
|
157
|
-
city: "
|
163
|
+
line_1: "123 Main St.",
|
164
|
+
city: "Hill Valley",
|
158
165
|
state: "CA",
|
159
|
-
zip: "
|
166
|
+
zip: "90382",
|
160
167
|
)
|
161
168
|
}
|
162
169
|
expect(actual).to eq(expected)
|
163
170
|
TEST
|
164
171
|
program = make_program(snippet, color_enabled: color_enabled)
|
165
172
|
|
166
|
-
expected_output =
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
173
|
+
expected_output =
|
174
|
+
build_expected_output(
|
175
|
+
color_enabled: color_enabled,
|
176
|
+
snippet: "expect(actual).to eq(expected)",
|
177
|
+
expectation:
|
178
|
+
proc do
|
179
|
+
line do
|
180
|
+
plain "Expected "
|
181
|
+
actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234"> }|
|
182
|
+
end
|
174
183
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
184
|
+
line do
|
185
|
+
plain " to eq "
|
186
|
+
expected %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382"> }|
|
187
|
+
end
|
188
|
+
end,
|
189
|
+
diff:
|
190
|
+
proc do
|
191
|
+
plain_line " {"
|
192
|
+
plain_line %| name: "Marty McFly",|
|
193
|
+
plain_line " shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {"
|
194
|
+
plain_line " id: nil,"
|
195
|
+
expected_line %|- city: "Hill Valley",|
|
196
|
+
actual_line %|+ city: "Oakland",|
|
197
|
+
expected_line %|- line_1: "123 Main St.",|
|
198
|
+
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
199
|
+
plain_line %| line_2: "",|
|
200
|
+
plain_line %| state: "CA",|
|
201
|
+
expected_line %|- zip: "90382"|
|
202
|
+
actual_line %|+ zip: "91234"|
|
203
|
+
plain_line " }>"
|
204
|
+
plain_line " }"
|
205
|
+
end
|
206
|
+
)
|
197
207
|
|
198
|
-
expect(program).
|
199
|
-
|
200
|
-
|
208
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
209
|
+
color_enabled
|
210
|
+
)
|
201
211
|
end
|
202
212
|
end
|
203
213
|
end
|
@@ -206,6 +216,13 @@ shared_examples_for "integration with ActiveRecord" do
|
|
206
216
|
it "produces the correct output" do
|
207
217
|
as_both_colored_and_uncolored do |color_enabled|
|
208
218
|
snippet = <<~TEST.strip
|
219
|
+
actual = {
|
220
|
+
name: "Marty McFly",
|
221
|
+
shipping_address: SuperDiff::Test::Models::ActiveRecord::Person.new(
|
222
|
+
name: "Elliot",
|
223
|
+
age: 31,
|
224
|
+
)
|
225
|
+
}
|
209
226
|
expected = {
|
210
227
|
name: "Marty McFly",
|
211
228
|
shipping_address: SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
@@ -215,54 +232,50 @@ shared_examples_for "integration with ActiveRecord" do
|
|
215
232
|
zip: "90382",
|
216
233
|
)
|
217
234
|
}
|
218
|
-
actual = {
|
219
|
-
name: "Marty McFly",
|
220
|
-
shipping_address: SuperDiff::Test::Models::ActiveRecord::Person.new(
|
221
|
-
name: "Elliot",
|
222
|
-
age: 31,
|
223
|
-
)
|
224
|
-
}
|
225
235
|
expect(actual).to eq(expected)
|
226
236
|
TEST
|
227
237
|
program = make_program(snippet, color_enabled: color_enabled)
|
228
238
|
|
229
|
-
expected_output =
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
239
|
+
expected_output =
|
240
|
+
build_expected_output(
|
241
|
+
color_enabled: color_enabled,
|
242
|
+
snippet: "expect(actual).to eq(expected)",
|
243
|
+
expectation:
|
244
|
+
proc do
|
245
|
+
line do
|
246
|
+
plain "Expected "
|
247
|
+
actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::Person id: nil, age: 31, name: "Elliot"> }|
|
248
|
+
end
|
237
249
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
250
|
+
line do
|
251
|
+
plain " to eq "
|
252
|
+
expected %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382"> }|
|
253
|
+
end
|
254
|
+
end,
|
255
|
+
diff:
|
256
|
+
proc do
|
257
|
+
plain_line " {"
|
258
|
+
plain_line %| name: "Marty McFly",|
|
259
|
+
expected_line "- shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {"
|
260
|
+
expected_line "- id: nil,"
|
261
|
+
expected_line %|- city: "Hill Valley",|
|
262
|
+
expected_line %|- line_1: "123 Main St.",|
|
263
|
+
expected_line %|- line_2: "",|
|
264
|
+
expected_line %|- state: "CA",|
|
265
|
+
expected_line %|- zip: "90382"|
|
266
|
+
expected_line "- }>"
|
267
|
+
actual_line "+ shipping_address: #<SuperDiff::Test::Models::ActiveRecord::Person {"
|
268
|
+
actual_line "+ id: nil,"
|
269
|
+
actual_line "+ age: 31,"
|
270
|
+
actual_line %|+ name: "Elliot"|
|
271
|
+
actual_line "+ }>"
|
272
|
+
plain_line " }"
|
273
|
+
end
|
274
|
+
)
|
262
275
|
|
263
|
-
expect(program).
|
264
|
-
|
265
|
-
|
276
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
277
|
+
color_enabled
|
278
|
+
)
|
266
279
|
end
|
267
280
|
end
|
268
281
|
end
|
@@ -286,51 +299,54 @@ shared_examples_for "integration with ActiveRecord" do
|
|
286
299
|
zip: "91234",
|
287
300
|
)
|
288
301
|
]
|
302
|
+
actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.all
|
289
303
|
expected = [shipping_addresses.first]
|
290
|
-
actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.all
|
291
304
|
expect(actual).to eq(expected)
|
292
305
|
TEST
|
293
306
|
program = make_program(snippet, color_enabled: color_enabled)
|
294
307
|
|
295
|
-
expected_output =
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
308
|
+
expected_output =
|
309
|
+
build_expected_output(
|
310
|
+
color_enabled: color_enabled,
|
311
|
+
snippet: "expect(actual).to eq(expected)",
|
312
|
+
expectation:
|
313
|
+
proc do
|
314
|
+
line do
|
315
|
+
plain "Expected "
|
316
|
+
actual %|#<ActiveRecord::Relation [#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 1, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">, #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 2, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234">]>|
|
317
|
+
end
|
303
318
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
319
|
+
line do
|
320
|
+
plain " to eq "
|
321
|
+
expected %|[#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 1, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">]|
|
322
|
+
end
|
323
|
+
end,
|
324
|
+
diff:
|
325
|
+
proc do
|
326
|
+
plain_line " #<ActiveRecord::Relation ["
|
327
|
+
plain_line " #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {"
|
328
|
+
plain_line " id: 1,"
|
329
|
+
plain_line %| city: "Hill Valley",|
|
330
|
+
plain_line %| line_1: "123 Main St.",|
|
331
|
+
plain_line %| line_2: "",|
|
332
|
+
plain_line %| state: "CA",|
|
333
|
+
plain_line %| zip: "90382"|
|
334
|
+
plain_line " }>,"
|
335
|
+
actual_line "+ #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {"
|
336
|
+
actual_line "+ id: 2,"
|
337
|
+
actual_line %|+ city: "Oakland",|
|
338
|
+
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
339
|
+
actual_line %|+ line_2: "",|
|
340
|
+
actual_line %|+ state: "CA",|
|
341
|
+
actual_line %|+ zip: "91234"|
|
342
|
+
actual_line "+ }>"
|
343
|
+
plain_line " ]>"
|
344
|
+
end
|
345
|
+
)
|
330
346
|
|
331
|
-
expect(program).
|
332
|
-
|
333
|
-
|
347
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
348
|
+
color_enabled
|
349
|
+
)
|
334
350
|
end
|
335
351
|
end
|
336
352
|
end
|
@@ -346,6 +362,12 @@ shared_examples_for "integration with ActiveRecord" do
|
|
346
362
|
age: 20
|
347
363
|
)
|
348
364
|
|
365
|
+
actual = [
|
366
|
+
SuperDiff::Test::Models::ActiveRecord::Query.new(
|
367
|
+
results: SuperDiff::Test::Models::ActiveRecord::Person.all
|
368
|
+
)
|
369
|
+
]
|
370
|
+
|
349
371
|
expected = [
|
350
372
|
an_object_having_attributes(
|
351
373
|
results: [
|
@@ -354,55 +376,51 @@ shared_examples_for "integration with ActiveRecord" do
|
|
354
376
|
)
|
355
377
|
]
|
356
378
|
|
357
|
-
actual = [
|
358
|
-
SuperDiff::Test::Models::ActiveRecord::Query.new(
|
359
|
-
results: SuperDiff::Test::Models::ActiveRecord::Person.all
|
360
|
-
)
|
361
|
-
]
|
362
|
-
|
363
379
|
expect(actual).to match(expected)
|
364
380
|
TEST
|
365
381
|
|
366
382
|
program = make_program(snippet, color_enabled: color_enabled)
|
367
383
|
|
368
|
-
expected_output =
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
384
|
+
expected_output =
|
385
|
+
build_expected_output(
|
386
|
+
color_enabled: color_enabled,
|
387
|
+
snippet: "expect(actual).to match(expected)",
|
388
|
+
newline_before_expectation: true,
|
389
|
+
expectation:
|
390
|
+
proc do
|
391
|
+
line do
|
392
|
+
plain "Expected "
|
393
|
+
actual %|[#<SuperDiff::Test::Models::ActiveRecord::Query @results=#<ActiveRecord::Relation [#<SuperDiff::Test::Models::ActiveRecord::Person id: 1, age: 20, name: "Murphy">]>>]|
|
394
|
+
end
|
377
395
|
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
396
|
+
line do
|
397
|
+
plain "to match "
|
398
|
+
expected %|[#<an object having attributes (results: [#<an object having attributes (name: "John", age: 19)>])>]|
|
399
|
+
end
|
400
|
+
end,
|
401
|
+
diff:
|
402
|
+
proc do
|
403
|
+
plain_line " ["
|
404
|
+
plain_line " #<SuperDiff::Test::Models::ActiveRecord::Query {"
|
405
|
+
plain_line " @results=#<ActiveRecord::Relation ["
|
406
|
+
plain_line " #<SuperDiff::Test::Models::ActiveRecord::Person {"
|
407
|
+
plain_line " id: 1,"
|
408
|
+
# expected_line %|- age: 19,| # TODO
|
409
|
+
expected_line "- age: 19"
|
410
|
+
actual_line "+ age: 20,"
|
411
|
+
# expected_line %|- name: "John"| # TODO
|
412
|
+
expected_line %|- name: "John",|
|
413
|
+
actual_line %|+ name: "Murphy"|
|
414
|
+
plain_line " }>"
|
415
|
+
plain_line " ]>"
|
416
|
+
plain_line " }>"
|
417
|
+
plain_line " ]"
|
418
|
+
end
|
419
|
+
)
|
401
420
|
|
402
|
-
expect(program).
|
403
|
-
|
404
|
-
|
405
|
-
removing_object_ids
|
421
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
422
|
+
color_enabled
|
423
|
+
).removing_object_ids
|
406
424
|
end
|
407
425
|
end
|
408
426
|
end
|