super_diff 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +5 -13
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +1 -3
- 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 +3 -9
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +1 -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 -11
- 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/default_object.rb +1 -1
- data/lib/super_diff/differs/defaults.rb +1 -1
- data/lib/super_diff/differs/main.rb +2 -13
- 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 +3 -3
- 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 +46 -60
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +2 -6
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +3 -9
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +5 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +4 -12
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +6 -23
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +8 -20
- 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/default_object.rb +29 -21
- 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 +1 -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 +1 -5
- 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 +122 -116
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +11 -16
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +2 -1
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +9 -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 +11 -13
- 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 +4 -9
- data/spec/examples.txt +493 -485
- data/spec/integration/rails/active_record_spec.rb +3 -1
- data/spec/integration/rails/engines_spec.rb +20 -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 +242 -239
- data/spec/integration/rspec/eq_matcher_spec.rb +595 -557
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +294 -286
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
- data/spec/integration/rspec/include_matcher_spec.rb +317 -215
- data/spec/integration/rspec/match_array_matcher_spec.rb +276 -273
- data/spec/integration/rspec/match_matcher_spec.rb +847 -834
- data/spec/integration/rspec/raise_error_matcher_spec.rb +468 -453
- 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/spec_helper.rb +17 -20
- data/spec/support/command_runner.rb +34 -57
- data/spec/support/integration/helpers.rb +35 -28
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
- data/spec/support/integration/test_programs/base.rb +12 -17
- 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 +30 -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 +232 -214
- data/spec/support/shared_examples/active_support.rb +53 -51
- data/spec/support/shared_examples/elided_diffs.rb +405 -381
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +424 -388
- 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/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 +5 -5
- data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
- data/spec/unit/rspec/object_inspection_spec.rb +349 -324
- data/spec/unit/super_diff_spec.rb +1542 -1449
- 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 +73 -73
- data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -4,51 +4,55 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
4
4
|
context "when comparing two different integers" do
|
5
5
|
it "produces the correct failure message when used in the positive" do
|
6
6
|
as_both_colored_and_uncolored do |color_enabled|
|
7
|
-
snippet =
|
7
|
+
snippet = "expect(1).to eq(42)"
|
8
8
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
9
9
|
|
10
|
-
expected_output =
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
expected_output =
|
11
|
+
build_expected_output(
|
12
|
+
color_enabled: color_enabled,
|
13
|
+
snippet: snippet,
|
14
|
+
expectation:
|
15
|
+
proc do
|
16
|
+
line do
|
17
|
+
plain "Expected "
|
18
|
+
actual "1"
|
19
|
+
plain " to eq "
|
20
|
+
expected "42"
|
21
|
+
plain "."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
)
|
23
25
|
|
24
|
-
expect(program).
|
25
|
-
|
26
|
-
|
26
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
27
|
+
color_enabled
|
28
|
+
)
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
it "produces the correct failure message when used in the negative" do
|
31
33
|
as_both_colored_and_uncolored do |color_enabled|
|
32
|
-
snippet =
|
34
|
+
snippet = "expect(42).not_to eq(42)"
|
33
35
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
34
36
|
|
35
|
-
expected_output =
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
expected_output =
|
38
|
+
build_expected_output(
|
39
|
+
color_enabled: color_enabled,
|
40
|
+
snippet: snippet,
|
41
|
+
expectation:
|
42
|
+
proc do
|
43
|
+
line do
|
44
|
+
plain "Expected "
|
45
|
+
actual "42"
|
46
|
+
plain " not to eq "
|
47
|
+
expected "42"
|
48
|
+
plain "."
|
49
|
+
end
|
50
|
+
end
|
51
|
+
)
|
48
52
|
|
49
|
-
expect(program).
|
50
|
-
|
51
|
-
|
53
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
54
|
+
color_enabled
|
55
|
+
)
|
52
56
|
end
|
53
57
|
end
|
54
58
|
end
|
@@ -56,57 +60,55 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
56
60
|
context "when comparing two different symbols" do
|
57
61
|
it "produces the correct failure message when used in the positive" do
|
58
62
|
as_both_colored_and_uncolored do |color_enabled|
|
59
|
-
snippet =
|
60
|
-
program = make_plain_test_program(
|
61
|
-
snippet,
|
62
|
-
color_enabled: color_enabled,
|
63
|
-
)
|
63
|
+
snippet = "expect(:bar).to eq(:foo)"
|
64
|
+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
64
65
|
|
65
|
-
expected_output =
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
66
|
+
expected_output =
|
67
|
+
build_expected_output(
|
68
|
+
color_enabled: color_enabled,
|
69
|
+
snippet: snippet,
|
70
|
+
expectation:
|
71
|
+
proc do
|
72
|
+
line do
|
73
|
+
plain "Expected "
|
74
|
+
actual ":bar"
|
75
|
+
plain " to eq "
|
76
|
+
expected ":foo"
|
77
|
+
plain "."
|
78
|
+
end
|
79
|
+
end
|
80
|
+
)
|
78
81
|
|
79
|
-
expect(program).
|
80
|
-
|
81
|
-
|
82
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
83
|
+
color_enabled
|
84
|
+
)
|
82
85
|
end
|
83
86
|
end
|
84
87
|
|
85
88
|
it "produces the correct failure message when used in the negative" do
|
86
89
|
as_both_colored_and_uncolored do |color_enabled|
|
87
|
-
snippet =
|
88
|
-
program = make_plain_test_program(
|
89
|
-
snippet,
|
90
|
-
color_enabled: color_enabled,
|
91
|
-
)
|
90
|
+
snippet = "expect(:foo).not_to eq(:foo)"
|
91
|
+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
92
92
|
|
93
|
-
expected_output =
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
93
|
+
expected_output =
|
94
|
+
build_expected_output(
|
95
|
+
color_enabled: color_enabled,
|
96
|
+
snippet: snippet,
|
97
|
+
expectation:
|
98
|
+
proc do
|
99
|
+
line do
|
100
|
+
plain "Expected "
|
101
|
+
actual ":foo"
|
102
|
+
plain " not to eq "
|
103
|
+
expected ":foo"
|
104
|
+
plain "."
|
105
|
+
end
|
106
|
+
end
|
107
|
+
)
|
106
108
|
|
107
|
-
expect(program).
|
108
|
-
|
109
|
-
|
109
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
110
|
+
color_enabled
|
111
|
+
)
|
110
112
|
end
|
111
113
|
end
|
112
114
|
end
|
@@ -115,56 +117,54 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
115
117
|
it "produces the correct failure message when used in the positive" do
|
116
118
|
as_both_colored_and_uncolored do |color_enabled|
|
117
119
|
snippet = %|expect("Jennifer").to eq("Marty")|
|
118
|
-
program = make_plain_test_program(
|
119
|
-
snippet,
|
120
|
-
color_enabled: color_enabled,
|
121
|
-
)
|
120
|
+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
122
121
|
|
123
|
-
expected_output =
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
122
|
+
expected_output =
|
123
|
+
build_expected_output(
|
124
|
+
color_enabled: color_enabled,
|
125
|
+
snippet: %|expect("Jennifer").to eq("Marty")|,
|
126
|
+
expectation:
|
127
|
+
proc do
|
128
|
+
line do
|
129
|
+
plain "Expected "
|
130
|
+
actual %|"Jennifer"|
|
131
|
+
plain " to eq "
|
132
|
+
expected %|"Marty"|
|
133
|
+
plain "."
|
134
|
+
end
|
135
|
+
end
|
136
|
+
)
|
136
137
|
|
137
|
-
expect(program).
|
138
|
-
|
139
|
-
|
138
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
139
|
+
color_enabled
|
140
|
+
)
|
140
141
|
end
|
141
142
|
end
|
142
143
|
|
143
144
|
it "produces the correct failure message when used in the negative" do
|
144
145
|
as_both_colored_and_uncolored do |color_enabled|
|
145
146
|
snippet = %|expect("Jennifer").not_to eq("Jennifer")|
|
146
|
-
program = make_plain_test_program(
|
147
|
-
snippet,
|
148
|
-
color_enabled: color_enabled,
|
149
|
-
)
|
147
|
+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
150
148
|
|
151
|
-
expected_output =
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
149
|
+
expected_output =
|
150
|
+
build_expected_output(
|
151
|
+
color_enabled: color_enabled,
|
152
|
+
snippet: %|expect("Jennifer").not_to eq("Jennifer")|,
|
153
|
+
expectation:
|
154
|
+
proc do
|
155
|
+
line do
|
156
|
+
plain "Expected "
|
157
|
+
actual %|"Jennifer"|
|
158
|
+
plain " not to eq "
|
159
|
+
expected %|"Jennifer"|
|
160
|
+
plain "."
|
161
|
+
end
|
162
|
+
end
|
163
|
+
)
|
164
164
|
|
165
|
-
expect(program).
|
166
|
-
|
167
|
-
|
165
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
166
|
+
color_enabled
|
167
|
+
)
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
@@ -174,47 +174,47 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
174
174
|
as_both_colored_and_uncolored do |color_enabled|
|
175
175
|
snippet = <<~RUBY
|
176
176
|
expected = Time.utc(2011, 12, 13, 14, 15, 16)
|
177
|
-
actual
|
177
|
+
actual = Time.utc(2011, 12, 13, 14, 15, 16, 500_000)
|
178
178
|
expect(expected).to eq(actual)
|
179
179
|
RUBY
|
180
|
-
program = make_plain_test_program(
|
181
|
-
snippet,
|
182
|
-
color_enabled: color_enabled,
|
183
|
-
)
|
180
|
+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
184
181
|
|
185
|
-
expected_output =
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
182
|
+
expected_output =
|
183
|
+
build_expected_output(
|
184
|
+
color_enabled: color_enabled,
|
185
|
+
snippet: "expect(expected).to eq(actual)",
|
186
|
+
expectation:
|
187
|
+
proc do
|
188
|
+
line do
|
189
|
+
plain "Expected "
|
190
|
+
actual "#<Time 2011-12-13 14:15:16 +00:00 (UTC)>"
|
191
|
+
end
|
192
|
+
|
193
|
+
line do
|
194
|
+
plain " to eq "
|
195
|
+
expected "#<Time 2011-12-13 14:15:16+(1/2) +00:00 (UTC)>"
|
196
|
+
end
|
197
|
+
end,
|
198
|
+
diff:
|
199
|
+
proc do
|
200
|
+
plain_line " #<Time {"
|
201
|
+
plain_line " year: 2011,"
|
202
|
+
plain_line " month: 12,"
|
203
|
+
plain_line " day: 13,"
|
204
|
+
plain_line " hour: 14,"
|
205
|
+
plain_line " min: 15,"
|
206
|
+
plain_line " sec: 16,"
|
207
|
+
expected_line "- subsec: (1/2),"
|
208
|
+
actual_line "+ subsec: 0,"
|
209
|
+
plain_line " zone: \"UTC\","
|
210
|
+
plain_line " utc_offset: 0"
|
211
|
+
plain_line " }>"
|
212
|
+
end
|
213
|
+
)
|
214
214
|
|
215
|
-
expect(program).
|
216
|
-
|
217
|
-
|
215
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
216
|
+
color_enabled
|
217
|
+
)
|
218
218
|
end
|
219
219
|
end
|
220
220
|
|
@@ -224,31 +224,30 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
224
224
|
time = Time.utc(2011, 12, 13, 14, 15, 16)
|
225
225
|
expect(time).not_to eq(time)
|
226
226
|
RUBY
|
227
|
-
program = make_plain_test_program(
|
228
|
-
snippet,
|
229
|
-
color_enabled: color_enabled,
|
230
|
-
)
|
227
|
+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
231
228
|
|
232
|
-
expected_output =
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
229
|
+
expected_output =
|
230
|
+
build_expected_output(
|
231
|
+
color_enabled: color_enabled,
|
232
|
+
snippet: "expect(time).not_to eq(time)",
|
233
|
+
newline_before_expectation: true,
|
234
|
+
expectation:
|
235
|
+
proc do
|
236
|
+
line do
|
237
|
+
plain " Expected "
|
238
|
+
actual "#<Time 2011-12-13 14:15:16 +00:00 (UTC)>"
|
239
|
+
end
|
240
|
+
|
241
|
+
line do
|
242
|
+
plain "not to eq "
|
243
|
+
expected "#<Time 2011-12-13 14:15:16 +00:00 (UTC)>"
|
244
|
+
end
|
245
|
+
end
|
246
|
+
)
|
248
247
|
|
249
|
-
expect(program).
|
250
|
-
|
251
|
-
|
248
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
249
|
+
color_enabled
|
250
|
+
)
|
252
251
|
end
|
253
252
|
end
|
254
253
|
end
|
@@ -258,33 +257,36 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
258
257
|
as_both_colored_and_uncolored do |color_enabled|
|
259
258
|
snippet = <<~TEST.strip
|
260
259
|
expected = "Something entirely different"
|
261
|
-
actual
|
260
|
+
actual = "This is a line\\nAnd that's another line\\n"
|
262
261
|
expect(actual).to eq(expected)
|
263
262
|
TEST
|
264
263
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
265
264
|
|
266
|
-
expected_output =
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
265
|
+
expected_output =
|
266
|
+
build_expected_output(
|
267
|
+
color_enabled: color_enabled,
|
268
|
+
snippet: "expect(actual).to eq(expected)",
|
269
|
+
expectation:
|
270
|
+
proc do
|
271
|
+
line do
|
272
|
+
plain "Expected "
|
273
|
+
actual %|"This is a line\\nAnd that's another line\\n"|
|
274
|
+
plain " to eq "
|
275
|
+
expected %|"Something entirely different"|
|
276
|
+
plain "."
|
277
|
+
end
|
278
|
+
end,
|
279
|
+
diff:
|
280
|
+
proc do
|
281
|
+
expected_line "- Something entirely different"
|
282
|
+
actual_line %|+ This is a line\\n|
|
283
|
+
actual_line %|+ And that's another line\\n|
|
284
|
+
end
|
285
|
+
)
|
284
286
|
|
285
|
-
expect(program).
|
286
|
-
|
287
|
-
|
287
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
288
|
+
color_enabled
|
289
|
+
)
|
288
290
|
end
|
289
291
|
end
|
290
292
|
end
|
@@ -294,33 +296,36 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
294
296
|
as_both_colored_and_uncolored do |color_enabled|
|
295
297
|
snippet = <<~TEST.strip
|
296
298
|
expected = "This is a line\\nAnd that's another line\\n"
|
297
|
-
actual
|
299
|
+
actual = "Something entirely different"
|
298
300
|
expect(actual).to eq(expected)
|
299
301
|
TEST
|
300
302
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
301
303
|
|
302
|
-
expected_output =
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
304
|
+
expected_output =
|
305
|
+
build_expected_output(
|
306
|
+
color_enabled: color_enabled,
|
307
|
+
snippet: "expect(actual).to eq(expected)",
|
308
|
+
expectation:
|
309
|
+
proc do
|
310
|
+
line do
|
311
|
+
plain "Expected "
|
312
|
+
actual %|"Something entirely different"|
|
313
|
+
plain " to eq "
|
314
|
+
expected %|"This is a line\\nAnd that's another line\\n"|
|
315
|
+
plain "."
|
316
|
+
end
|
317
|
+
end,
|
318
|
+
diff:
|
319
|
+
proc do
|
320
|
+
expected_line %|- This is a line\\n|
|
321
|
+
expected_line %|- And that's another line\\n|
|
322
|
+
actual_line "+ Something entirely different"
|
323
|
+
end
|
324
|
+
)
|
320
325
|
|
321
|
-
expect(program).
|
322
|
-
|
323
|
-
|
326
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
327
|
+
color_enabled
|
328
|
+
)
|
324
329
|
end
|
325
330
|
end
|
326
331
|
end
|
@@ -330,36 +335,39 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
330
335
|
as_both_colored_and_uncolored do |color_enabled|
|
331
336
|
snippet = <<~TEST.strip
|
332
337
|
expected = "This is a line\\nAnd that's a line\\nAnd there's a line too\\n"
|
333
|
-
actual
|
338
|
+
actual = "This is a line\\nSomething completely different\\nAnd there's a line too\\n"
|
334
339
|
expect(actual).to eq(expected)
|
335
340
|
TEST
|
336
341
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
337
342
|
|
338
|
-
expected_output =
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
343
|
+
expected_output =
|
344
|
+
build_expected_output(
|
345
|
+
color_enabled: color_enabled,
|
346
|
+
snippet: "expect(actual).to eq(expected)",
|
347
|
+
expectation:
|
348
|
+
proc do
|
349
|
+
line do
|
350
|
+
plain "Expected "
|
351
|
+
actual %|"This is a line\\nSomething completely different\\nAnd there's a line too\\n"|
|
352
|
+
end
|
353
|
+
|
354
|
+
line do
|
355
|
+
plain " to eq "
|
356
|
+
expected %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
|
357
|
+
end
|
358
|
+
end,
|
359
|
+
diff:
|
360
|
+
proc do
|
361
|
+
plain_line %| This is a line\\n|
|
362
|
+
expected_line %|- And that's a line\\n|
|
363
|
+
actual_line %|+ Something completely different\\n|
|
364
|
+
plain_line %| And there's a line too\\n|
|
365
|
+
end
|
366
|
+
)
|
359
367
|
|
360
|
-
expect(program).
|
361
|
-
|
362
|
-
|
368
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
369
|
+
color_enabled
|
370
|
+
)
|
363
371
|
end
|
364
372
|
end
|
365
373
|
|
@@ -371,26 +379,28 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
371
379
|
TEST
|
372
380
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
373
381
|
|
374
|
-
expected_output =
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
382
|
+
expected_output =
|
383
|
+
build_expected_output(
|
384
|
+
color_enabled: color_enabled,
|
385
|
+
snippet: "expect(string).not_to eq(string)",
|
386
|
+
newline_before_expectation: true,
|
387
|
+
expectation:
|
388
|
+
proc do
|
389
|
+
line do
|
390
|
+
plain " Expected "
|
391
|
+
actual %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
|
392
|
+
end
|
393
|
+
|
394
|
+
line do
|
395
|
+
plain "not to eq "
|
396
|
+
expected %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
|
397
|
+
end
|
398
|
+
end
|
399
|
+
)
|
390
400
|
|
391
|
-
expect(program).
|
392
|
-
|
393
|
-
|
401
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
402
|
+
color_enabled
|
403
|
+
)
|
394
404
|
end
|
395
405
|
end
|
396
406
|
end
|
@@ -412,7 +422,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
412
422
|
}
|
413
423
|
]
|
414
424
|
]
|
415
|
-
actual
|
425
|
+
actual = [
|
416
426
|
[
|
417
427
|
:h2,
|
418
428
|
[:span, [:text, "Goodbye world"]],
|
@@ -432,56 +442,59 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
432
442
|
TEST
|
433
443
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
434
444
|
|
435
|
-
expected_output =
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
445
|
+
expected_output =
|
446
|
+
build_expected_output(
|
447
|
+
color_enabled: color_enabled,
|
448
|
+
snippet: "expect(actual).to eq(expected)",
|
449
|
+
expectation:
|
450
|
+
proc do
|
451
|
+
line do
|
452
|
+
plain "Expected "
|
453
|
+
actual %|[[:h2, [:span, [:text, "Goodbye world"]], { id: "hero", class: "header", data: { "sticky" => false, :role => "deprecated", :person => #<SuperDiff::Test::Person name: "Doc", age: 60> } }], :br]|
|
454
|
+
end
|
455
|
+
|
456
|
+
line do
|
457
|
+
plain " to eq "
|
458
|
+
expected %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
|
459
|
+
end
|
460
|
+
end,
|
461
|
+
diff:
|
462
|
+
proc do
|
463
|
+
plain_line " ["
|
464
|
+
plain_line " ["
|
465
|
+
expected_line "- :h1,"
|
466
|
+
actual_line "+ :h2,"
|
467
|
+
plain_line " ["
|
468
|
+
plain_line " :span,"
|
469
|
+
plain_line " ["
|
470
|
+
plain_line " :text,"
|
471
|
+
expected_line %|- "Hello world"|
|
472
|
+
actual_line %|+ "Goodbye world"|
|
473
|
+
plain_line " ]"
|
474
|
+
plain_line " ],"
|
475
|
+
plain_line " {"
|
476
|
+
actual_line %|+ id: "hero",|
|
477
|
+
plain_line %| class: "header",|
|
478
|
+
plain_line " data: {"
|
479
|
+
expected_line %|- "sticky" => true,|
|
480
|
+
actual_line %|+ "sticky" => false,|
|
481
|
+
actual_line %|+ :role => "deprecated",|
|
482
|
+
plain_line " :person => #<SuperDiff::Test::Person {"
|
483
|
+
expected_line %|- name: "Marty",|
|
484
|
+
actual_line %|+ name: "Doc",|
|
485
|
+
plain_line " age: 60"
|
486
|
+
plain_line " }>"
|
487
|
+
plain_line " }"
|
488
|
+
plain_line " }"
|
489
|
+
plain_line " ],"
|
490
|
+
actual_line "+ :br"
|
491
|
+
plain_line " ]"
|
492
|
+
end
|
493
|
+
)
|
481
494
|
|
482
|
-
expect(program).
|
483
|
-
|
484
|
-
|
495
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
496
|
+
color_enabled
|
497
|
+
)
|
485
498
|
end
|
486
499
|
end
|
487
500
|
|
@@ -505,26 +518,28 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
505
518
|
TEST
|
506
519
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
507
520
|
|
508
|
-
expected_output =
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
521
|
+
expected_output =
|
522
|
+
build_expected_output(
|
523
|
+
color_enabled: color_enabled,
|
524
|
+
snippet: "expect(value).not_to eq(value)",
|
525
|
+
newline_before_expectation: true,
|
526
|
+
expectation:
|
527
|
+
proc do
|
528
|
+
line do
|
529
|
+
plain " Expected "
|
530
|
+
actual %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
|
531
|
+
end
|
532
|
+
|
533
|
+
line do
|
534
|
+
plain "not to eq "
|
535
|
+
expected %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
|
536
|
+
end
|
537
|
+
end
|
538
|
+
)
|
524
539
|
|
525
|
-
expect(program).
|
526
|
-
|
527
|
-
|
540
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
541
|
+
color_enabled
|
542
|
+
)
|
528
543
|
end
|
529
544
|
end
|
530
545
|
end
|
@@ -552,7 +567,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
552
567
|
{ name: "Chevy 4x4" }
|
553
568
|
]
|
554
569
|
}
|
555
|
-
actual
|
570
|
+
actual = {
|
556
571
|
customer: {
|
557
572
|
person: SuperDiff::Test::Person.new(name: "Marty McFly, Jr.", age: 17),
|
558
573
|
shipping_address: {
|
@@ -575,58 +590,61 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
575
590
|
TEST
|
576
591
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
577
592
|
|
578
|
-
expected_output =
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
593
|
+
expected_output =
|
594
|
+
build_expected_output(
|
595
|
+
color_enabled: color_enabled,
|
596
|
+
snippet: "expect(actual).to eq(expected)",
|
597
|
+
expectation:
|
598
|
+
proc do
|
599
|
+
line do
|
600
|
+
plain "Expected "
|
601
|
+
actual %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly, Jr.", age: 17>, shipping_address: { line_1: "456 Ponderosa Ct.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Mattel Hoverboard" }] }|
|
602
|
+
end
|
603
|
+
|
604
|
+
line do
|
605
|
+
plain " to eq "
|
606
|
+
expected %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly", age: 17>, shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] }|
|
607
|
+
end
|
608
|
+
end,
|
609
|
+
diff:
|
610
|
+
proc do
|
611
|
+
plain_line " {"
|
612
|
+
plain_line " customer: {"
|
613
|
+
plain_line " person: #<SuperDiff::Test::Person {"
|
614
|
+
expected_line %|- name: "Marty McFly",|
|
615
|
+
actual_line %|+ name: "Marty McFly, Jr.",|
|
616
|
+
plain_line " age: 17"
|
617
|
+
plain_line " }>,"
|
618
|
+
plain_line " shipping_address: {"
|
619
|
+
expected_line %|- line_1: "123 Main St.",|
|
620
|
+
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
621
|
+
plain_line %| city: "Hill Valley",|
|
622
|
+
plain_line %| state: "CA",|
|
623
|
+
plain_line %| zip: "90382"|
|
624
|
+
plain_line " }"
|
625
|
+
plain_line " },"
|
626
|
+
plain_line " items: ["
|
627
|
+
plain_line " {"
|
628
|
+
plain_line %| name: "Fender Stratocaster",|
|
629
|
+
plain_line " cost: 100000,"
|
630
|
+
plain_line " options: ["
|
631
|
+
plain_line %| "red",|
|
632
|
+
plain_line %| "blue",|
|
633
|
+
plain_line %| "green"|
|
634
|
+
plain_line " ]"
|
635
|
+
plain_line " },"
|
636
|
+
plain_line " {"
|
637
|
+
expected_line %|- name: "Chevy 4x4"|
|
638
|
+
actual_line %|+ name: "Mattel Hoverboard"|
|
639
|
+
plain_line " }"
|
640
|
+
plain_line " ]"
|
641
|
+
plain_line " }"
|
642
|
+
end
|
643
|
+
)
|
626
644
|
|
627
|
-
expect(program).
|
628
|
-
|
629
|
-
|
645
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
646
|
+
color_enabled
|
647
|
+
)
|
630
648
|
end
|
631
649
|
end
|
632
650
|
|
@@ -656,26 +674,28 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
656
674
|
TEST
|
657
675
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
658
676
|
|
659
|
-
expected_output =
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
677
|
+
expected_output =
|
678
|
+
build_expected_output(
|
679
|
+
color_enabled: color_enabled,
|
680
|
+
snippet: "expect(value).not_to eq(value)",
|
681
|
+
newline_before_expectation: true,
|
682
|
+
expectation:
|
683
|
+
proc do
|
684
|
+
line do
|
685
|
+
plain " Expected "
|
686
|
+
actual %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly", age: 17>, shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] }|
|
687
|
+
end
|
688
|
+
|
689
|
+
line do
|
690
|
+
plain "not to eq "
|
691
|
+
expected %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly", age: 17>, shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] }|
|
692
|
+
end
|
693
|
+
end
|
694
|
+
)
|
675
695
|
|
676
|
-
expect(program).
|
677
|
-
|
678
|
-
|
696
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
697
|
+
color_enabled
|
698
|
+
)
|
679
699
|
end
|
680
700
|
end
|
681
701
|
end
|
@@ -688,7 +708,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
688
708
|
name: "Marty",
|
689
709
|
age: 31,
|
690
710
|
)
|
691
|
-
actual
|
711
|
+
actual = SuperDiff::Test::Customer.new(
|
692
712
|
name: "Doc",
|
693
713
|
shipping_address: :some_shipping_address,
|
694
714
|
phone: "1234567890",
|
@@ -697,26 +717,28 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
697
717
|
TEST
|
698
718
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
699
719
|
|
700
|
-
expected_output =
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
720
|
+
expected_output =
|
721
|
+
build_expected_output(
|
722
|
+
color_enabled: color_enabled,
|
723
|
+
snippet: "expect(actual).to eq(expected)",
|
724
|
+
newline_before_expectation: true,
|
725
|
+
expectation:
|
726
|
+
proc do
|
727
|
+
line do
|
728
|
+
plain "Expected "
|
729
|
+
actual %|#<SuperDiff::Test::Customer name: "Doc", shipping_address: :some_shipping_address, phone: "1234567890">|
|
730
|
+
end
|
731
|
+
|
732
|
+
line do
|
733
|
+
plain " to eq "
|
734
|
+
expected %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
|
735
|
+
end
|
736
|
+
end
|
737
|
+
)
|
716
738
|
|
717
|
-
expect(program).
|
718
|
-
|
719
|
-
|
739
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
740
|
+
color_enabled
|
741
|
+
)
|
720
742
|
end
|
721
743
|
end
|
722
744
|
|
@@ -731,26 +753,28 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
731
753
|
TEST
|
732
754
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
733
755
|
|
734
|
-
expected_output =
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
756
|
+
expected_output =
|
757
|
+
build_expected_output(
|
758
|
+
color_enabled: color_enabled,
|
759
|
+
snippet: "expect(value).not_to eq(value)",
|
760
|
+
newline_before_expectation: true,
|
761
|
+
expectation:
|
762
|
+
proc do
|
763
|
+
line do
|
764
|
+
plain " Expected "
|
765
|
+
actual %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
|
766
|
+
end
|
767
|
+
|
768
|
+
line do
|
769
|
+
plain "not to eq "
|
770
|
+
expected %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
|
771
|
+
end
|
772
|
+
end
|
773
|
+
)
|
750
774
|
|
751
|
-
expect(program).
|
752
|
-
|
753
|
-
|
775
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
776
|
+
color_enabled
|
777
|
+
)
|
754
778
|
end
|
755
779
|
end
|
756
780
|
end
|
@@ -763,7 +787,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
763
787
|
name: "camera",
|
764
788
|
quantity: 3,
|
765
789
|
)
|
766
|
-
actual
|
790
|
+
actual = SuperDiff::Test::Player.new(
|
767
791
|
handle: "mcmire",
|
768
792
|
character: "Jon",
|
769
793
|
inventory: ["sword"],
|
@@ -775,27 +799,28 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
775
799
|
TEST
|
776
800
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
777
801
|
|
778
|
-
expected_output =
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
802
|
+
expected_output =
|
803
|
+
build_expected_output(
|
804
|
+
color_enabled: color_enabled,
|
805
|
+
snippet: "expect(actual).to eq(expected)",
|
806
|
+
newline_before_expectation: true,
|
807
|
+
expectation:
|
808
|
+
proc do
|
809
|
+
line do
|
810
|
+
plain "Expected "
|
811
|
+
actual %|#<SuperDiff::Test::Player @character="Jon", @handle="mcmire", @health=4, @inventory=["sword"], @shields=11.4, @ultimate=true>|
|
812
|
+
end
|
813
|
+
|
814
|
+
line do
|
815
|
+
plain " to eq "
|
816
|
+
expected %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
|
817
|
+
end
|
818
|
+
end
|
819
|
+
)
|
794
820
|
|
795
|
-
expect(program).
|
796
|
-
|
797
|
-
|
798
|
-
removing_object_ids
|
821
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
822
|
+
color_enabled
|
823
|
+
).removing_object_ids
|
799
824
|
end
|
800
825
|
end
|
801
826
|
|
@@ -810,27 +835,28 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
810
835
|
TEST
|
811
836
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
812
837
|
|
813
|
-
expected_output =
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
838
|
+
expected_output =
|
839
|
+
build_expected_output(
|
840
|
+
color_enabled: color_enabled,
|
841
|
+
snippet: "expect(value).not_to eq(value)",
|
842
|
+
newline_before_expectation: true,
|
843
|
+
expectation:
|
844
|
+
proc do
|
845
|
+
line do
|
846
|
+
plain " Expected "
|
847
|
+
actual %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
|
848
|
+
end
|
849
|
+
|
850
|
+
line do
|
851
|
+
plain "not to eq "
|
852
|
+
expected %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
|
853
|
+
end
|
854
|
+
end
|
855
|
+
)
|
829
856
|
|
830
|
-
expect(program).
|
831
|
-
|
832
|
-
|
833
|
-
removing_object_ids
|
857
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
858
|
+
color_enabled
|
859
|
+
).removing_object_ids
|
834
860
|
end
|
835
861
|
end
|
836
862
|
end
|
@@ -840,35 +866,38 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
840
866
|
as_both_colored_and_uncolored do |color_enabled|
|
841
867
|
snippet = <<~TEST.strip
|
842
868
|
expected = { foo: nil }
|
843
|
-
actual
|
869
|
+
actual = { foo: [] }
|
844
870
|
expect(actual).to eq(expected)
|
845
871
|
TEST
|
846
872
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
847
873
|
|
848
|
-
expected_output =
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
874
|
+
expected_output =
|
875
|
+
build_expected_output(
|
876
|
+
color_enabled: color_enabled,
|
877
|
+
snippet: "expect(actual).to eq(expected)",
|
878
|
+
newline_before_expectation: true,
|
879
|
+
expectation:
|
880
|
+
proc do
|
881
|
+
line do
|
882
|
+
plain "Expected "
|
883
|
+
actual "{ foo: [] }"
|
884
|
+
plain " to eq "
|
885
|
+
expected "{ foo: nil }"
|
886
|
+
plain "."
|
887
|
+
end
|
888
|
+
end,
|
889
|
+
diff:
|
890
|
+
proc do
|
891
|
+
plain_line " {"
|
892
|
+
expected_line "- foo: nil"
|
893
|
+
actual_line "+ foo: []"
|
894
|
+
plain_line " }"
|
895
|
+
end
|
896
|
+
)
|
868
897
|
|
869
|
-
expect(program).
|
870
|
-
|
871
|
-
|
898
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
899
|
+
color_enabled
|
900
|
+
)
|
872
901
|
end
|
873
902
|
end
|
874
903
|
end
|
@@ -878,35 +907,38 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
878
907
|
as_both_colored_and_uncolored do |color_enabled|
|
879
908
|
snippet = <<~TEST.strip
|
880
909
|
expected = { foo: nil }
|
881
|
-
actual
|
910
|
+
actual = { foo: {} }
|
882
911
|
expect(actual).to eq(expected)
|
883
912
|
TEST
|
884
913
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
885
914
|
|
886
|
-
expected_output =
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
915
|
+
expected_output =
|
916
|
+
build_expected_output(
|
917
|
+
color_enabled: color_enabled,
|
918
|
+
snippet: "expect(actual).to eq(expected)",
|
919
|
+
newline_before_expectation: true,
|
920
|
+
expectation:
|
921
|
+
proc do
|
922
|
+
line do
|
923
|
+
plain "Expected "
|
924
|
+
actual "{ foo: {} }"
|
925
|
+
plain " to eq "
|
926
|
+
expected "{ foo: nil }"
|
927
|
+
plain "."
|
928
|
+
end
|
929
|
+
end,
|
930
|
+
diff:
|
931
|
+
proc do
|
932
|
+
plain_line " {"
|
933
|
+
expected_line "- foo: nil"
|
934
|
+
actual_line "+ foo: {}"
|
935
|
+
plain_line " }"
|
936
|
+
end
|
937
|
+
)
|
906
938
|
|
907
|
-
expect(program).
|
908
|
-
|
909
|
-
|
939
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
940
|
+
color_enabled
|
941
|
+
)
|
910
942
|
end
|
911
943
|
end
|
912
944
|
end
|
@@ -916,36 +948,38 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
916
948
|
as_both_colored_and_uncolored do |color_enabled|
|
917
949
|
snippet = <<~TEST.strip
|
918
950
|
expected = { foo: nil }
|
919
|
-
actual
|
951
|
+
actual = { foo: SuperDiff::Test::EmptyClass.new }
|
920
952
|
expect(actual).to eq(expected)
|
921
953
|
TEST
|
922
954
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
923
955
|
|
924
|
-
expected_output =
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
956
|
+
expected_output =
|
957
|
+
build_expected_output(
|
958
|
+
color_enabled: color_enabled,
|
959
|
+
snippet: "expect(actual).to eq(expected)",
|
960
|
+
newline_before_expectation: true,
|
961
|
+
expectation:
|
962
|
+
proc do
|
963
|
+
line do
|
964
|
+
plain "Expected "
|
965
|
+
actual "{ foo: #<SuperDiff::Test::EmptyClass> }"
|
966
|
+
plain " to eq "
|
967
|
+
expected "{ foo: nil }"
|
968
|
+
plain "."
|
969
|
+
end
|
970
|
+
end,
|
971
|
+
diff:
|
972
|
+
proc do
|
973
|
+
plain_line " {"
|
974
|
+
expected_line "- foo: nil"
|
975
|
+
actual_line "+ foo: #<SuperDiff::Test::EmptyClass>"
|
976
|
+
plain_line " }"
|
977
|
+
end
|
978
|
+
)
|
944
979
|
|
945
|
-
expect(program).
|
946
|
-
|
947
|
-
|
948
|
-
removing_object_ids
|
980
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
981
|
+
color_enabled
|
982
|
+
).removing_object_ids
|
949
983
|
end
|
950
984
|
end
|
951
985
|
end
|
@@ -953,4 +987,8 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
953
987
|
it_behaves_like "a matcher that supports elided diffs" do
|
954
988
|
let(:matcher) { :eq }
|
955
989
|
end
|
990
|
+
|
991
|
+
it_behaves_like "a matcher that supports a toggleable key" do
|
992
|
+
let(:matcher) { :eq }
|
993
|
+
end
|
956
994
|
end
|