super_diff 0.5.3 → 0.8.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 +46 -20
- data/lib/super_diff.rb +46 -7
- data/lib/super_diff/active_record.rb +7 -7
- data/lib/super_diff/active_record/differs/active_record_relation.rb +3 -13
- data/lib/super_diff/active_record/object_inspection.rb +2 -6
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +16 -0
- data/lib/super_diff/active_record/object_inspection/{inspectors → inspection_tree_builders}/active_record_model.rb +19 -20
- data/lib/super_diff/active_record/object_inspection/{inspectors → inspection_tree_builders}/active_record_relation.rb +9 -8
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +10 -0
- data/lib/super_diff/active_record/operation_tree_flatteners/active_record_relation.rb +17 -0
- data/lib/super_diff/active_record/operation_trees/active_record_relation.rb +8 -7
- data/lib/super_diff/active_support.rb +8 -8
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +3 -13
- data/lib/super_diff/active_support/object_inspection.rb +2 -6
- data/lib/super_diff/active_support/object_inspection/{inspectors.rb → inspection_tree_builders.rb} +2 -2
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +37 -0
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +17 -0
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +10 -0
- data/lib/super_diff/active_support/operation_tree_flatteners/hash_with_indifferent_access.rb +17 -0
- data/lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb +4 -7
- data/lib/super_diff/colorized_document_extensions.rb +9 -6
- data/lib/super_diff/configuration.rb +102 -19
- data/lib/super_diff/csi.rb +1 -1
- data/lib/super_diff/csi/four_bit_color.rb +0 -2
- data/lib/super_diff/diff_formatters/collection.rb +2 -2
- data/lib/super_diff/diff_formatters/multiline_string.rb +4 -4
- data/lib/super_diff/differs/array.rb +1 -1
- data/lib/super_diff/differs/base.rb +3 -21
- data/lib/super_diff/differs/custom_object.rb +1 -1
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/hash.rb +1 -1
- data/lib/super_diff/differs/main.rb +1 -7
- data/lib/super_diff/differs/multiline_string.rb +1 -1
- data/lib/super_diff/differs/time_like.rb +1 -1
- data/lib/super_diff/equality_matchers/array.rb +4 -4
- data/lib/super_diff/equality_matchers/default.rb +4 -4
- data/lib/super_diff/equality_matchers/hash.rb +4 -4
- data/lib/super_diff/equality_matchers/multiline_string.rb +4 -4
- data/lib/super_diff/equality_matchers/primitive.rb +6 -9
- data/lib/super_diff/equality_matchers/singleline_string.rb +4 -4
- data/lib/super_diff/gem_version.rb +45 -0
- data/lib/super_diff/helpers.rb +52 -2
- data/lib/super_diff/line.rb +83 -0
- data/lib/super_diff/object_inspection.rb +12 -9
- data/lib/super_diff/object_inspection/inspection_tree.rb +183 -81
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +44 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +38 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/base.rb +27 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +37 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +63 -0
- data/lib/super_diff/object_inspection/{inspectors → inspection_tree_builders}/defaults.rb +1 -2
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +46 -0
- data/lib/super_diff/object_inspection/{inspectors → inspection_tree_builders}/main.rb +5 -10
- data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +21 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +64 -0
- data/lib/super_diff/object_inspection/nodes.rb +33 -32
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +97 -0
- data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +27 -0
- data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +27 -0
- data/lib/super_diff/object_inspection/nodes/as_single_line.rb +33 -0
- data/lib/super_diff/object_inspection/nodes/base.rb +55 -20
- data/lib/super_diff/object_inspection/nodes/inspection.rb +47 -7
- data/lib/super_diff/object_inspection/nodes/nesting.rb +16 -5
- data/lib/super_diff/object_inspection/nodes/only_when.rb +54 -0
- data/lib/super_diff/object_inspection/nodes/text.rb +16 -2
- data/lib/super_diff/object_inspection/nodes/when_empty.rb +21 -6
- data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +20 -5
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +27 -0
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +27 -0
- data/lib/super_diff/object_inspection/prefix_for_next_node.rb +6 -0
- data/lib/super_diff/object_inspection/prelude_for_next_node.rb +6 -0
- data/lib/super_diff/operation_tree_builders/array.rb +7 -10
- data/lib/super_diff/operation_tree_builders/base.rb +6 -6
- data/lib/super_diff/operation_tree_builders/custom_object.rb +5 -2
- data/lib/super_diff/operation_tree_builders/default_object.rb +1 -1
- data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/operation_tree_builders/hash.rb +1 -8
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +2 -6
- data/lib/super_diff/operation_tree_builders/time_like.rb +2 -2
- data/lib/super_diff/operation_tree_flatteners.rb +20 -0
- data/lib/super_diff/operation_tree_flatteners/array.rb +15 -0
- data/lib/super_diff/operation_tree_flatteners/base.rb +54 -0
- data/lib/super_diff/operation_tree_flatteners/collection.rb +139 -0
- data/lib/super_diff/operation_tree_flatteners/custom_object.rb +28 -0
- data/lib/super_diff/operation_tree_flatteners/default_object.rb +32 -0
- data/lib/super_diff/operation_tree_flatteners/hash.rb +41 -0
- data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +17 -0
- data/lib/super_diff/operation_trees/array.rb +4 -7
- data/lib/super_diff/operation_trees/base.rb +39 -16
- data/lib/super_diff/operation_trees/custom_object.rb +4 -8
- data/lib/super_diff/operation_trees/default_object.rb +28 -13
- data/lib/super_diff/operation_trees/hash.rb +4 -7
- data/lib/super_diff/operation_trees/main.rb +1 -1
- data/lib/super_diff/operation_trees/multiline_string.rb +4 -7
- data/lib/super_diff/operations/binary_operation.rb +1 -6
- data/lib/super_diff/operations/unary_operation.rb +2 -30
- data/lib/super_diff/recursion_guard.rb +3 -3
- data/lib/super_diff/rspec.rb +41 -13
- data/lib/super_diff/rspec/differs/collection_including.rb +4 -2
- data/lib/super_diff/rspec/differs/hash_including.rb +4 -2
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +7 -7
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +6 -6
- data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +4 -4
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +5 -5
- data/lib/super_diff/rspec/monkey_patches.rb +353 -306
- data/lib/super_diff/rspec/object_inspection.rb +4 -1
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +44 -0
- data/lib/super_diff/rspec/object_inspection/{inspectors → inspection_tree_builders}/collection_containing_exactly.rb +9 -8
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +34 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +103 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +36 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +26 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +26 -0
- data/lib/super_diff/rspec/object_inspection/{inspectors → inspection_tree_builders}/object_having_attributes.rb +10 -12
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/primitive.rb +10 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +33 -0
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +12 -4
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +10 -3
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +10 -3
- data/lib/super_diff/tiered_lines.rb +4 -0
- data/lib/super_diff/tiered_lines_elider.rb +490 -0
- data/lib/super_diff/tiered_lines_formatter.rb +79 -0
- data/lib/super_diff/version.rb +1 -1
- data/spec/examples.txt +407 -5
- data/spec/integration/rails/active_support_spec.rb +19 -0
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +10 -10
- data/spec/integration/rspec/be_matcher_spec.rb +100 -100
- data/spec/integration/rspec/be_nil_matcher_spec.rb +10 -10
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +103 -103
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +10 -10
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +113 -107
- data/spec/integration/rspec/eq_matcher_spec.rb +223 -277
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +138 -129
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +65 -65
- data/spec/integration/rspec/include_matcher_spec.rb +73 -73
- data/spec/integration/rspec/match_array_matcher_spec.rb +126 -119
- data/spec/integration/rspec/match_matcher_spec.rb +362 -274
- data/spec/integration/rspec/raise_error_matcher_spec.rb +86 -86
- data/spec/integration/rspec/respond_to_matcher_spec.rb +240 -240
- data/spec/integration/rspec/third_party_matcher_spec.rb +8 -8
- data/spec/integration/rspec/unhandled_errors_spec.rb +5 -5
- data/spec/spec_helper.rb +33 -13
- data/spec/support/command_runner.rb +15 -25
- data/spec/support/helpers.rb +21 -0
- data/spec/support/integration/helpers.rb +8 -2
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +4 -4
- data/spec/support/integration/test_programs/base.rb +38 -10
- data/spec/support/integration/test_programs/rspec_active_record.rb +1 -1
- data/spec/support/integration/test_programs/rspec_active_support.rb +17 -0
- data/spec/support/integration/test_programs/rspec_rails.rb +1 -1
- data/spec/support/shared_examples/active_record.rb +109 -108
- data/spec/support/shared_examples/active_support.rb +65 -0
- data/spec/support/shared_examples/elided_diffs.rb +914 -0
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +196 -232
- data/spec/support/unit/helpers.rb +15 -0
- data/spec/support/unit/matchers/match_output.rb +41 -0
- data/spec/unit/active_record/object_inspection_spec.rb +273 -0
- data/spec/unit/equality_matchers/main_spec.rb +445 -465
- data/spec/unit/helpers_spec.rb +61 -0
- data/spec/unit/operation_tree_flatteners/array_spec.rb +604 -0
- data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +667 -0
- data/spec/unit/operation_tree_flatteners/default_object_spec.rb +687 -0
- data/spec/unit/operation_tree_flatteners/hash_spec.rb +632 -0
- data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +121 -0
- data/spec/unit/rspec/object_inspection_spec.rb +446 -0
- data/spec/unit/super_diff_spec.rb +1958 -0
- data/spec/unit/tiered_lines_elider_spec.rb +6356 -0
- data/spec/unit/tiered_lines_formatter_spec.rb +193 -0
- data/super_diff.gemspec +1 -1
- metadata +95 -50
- data/lib/super_diff/active_record/diff_formatters.rb +0 -10
- data/lib/super_diff/active_record/diff_formatters/active_record_relation.rb +0 -23
- data/lib/super_diff/active_record/object_inspection/inspectors.rb +0 -16
- data/lib/super_diff/active_support/diff_formatters.rb +0 -10
- data/lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb +0 -36
- data/lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb +0 -28
- data/lib/super_diff/diff_formatters.rb +0 -14
- data/lib/super_diff/diff_formatters/array.rb +0 -21
- data/lib/super_diff/diff_formatters/base.rb +0 -33
- data/lib/super_diff/diff_formatters/custom_object.rb +0 -30
- data/lib/super_diff/diff_formatters/default_object.rb +0 -46
- data/lib/super_diff/diff_formatters/defaults.rb +0 -10
- data/lib/super_diff/diff_formatters/hash.rb +0 -34
- data/lib/super_diff/diff_formatters/main.rb +0 -41
- data/lib/super_diff/object_inspection/inspectors.rb +0 -23
- data/lib/super_diff/object_inspection/inspectors/array.rb +0 -32
- data/lib/super_diff/object_inspection/inspectors/base.rb +0 -36
- data/lib/super_diff/object_inspection/inspectors/custom_object.rb +0 -37
- data/lib/super_diff/object_inspection/inspectors/default_object.rb +0 -61
- data/lib/super_diff/object_inspection/inspectors/hash.rb +0 -32
- data/lib/super_diff/object_inspection/inspectors/primitive.rb +0 -28
- data/lib/super_diff/object_inspection/inspectors/string.rb +0 -23
- data/lib/super_diff/object_inspection/inspectors/time_like.rb +0 -23
- data/lib/super_diff/object_inspection/nodes/break.rb +0 -15
- data/lib/super_diff/object_inspection/nodes/when_multiline.rb +0 -22
- data/lib/super_diff/object_inspection/nodes/when_singleline.rb +0 -24
- data/lib/super_diff/rspec/object_inspection/inspectors.rb +0 -40
- data/lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb +0 -28
- data/lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb +0 -31
- data/lib/super_diff/rspec/object_inspection/inspectors/instance_of.rb +0 -23
- data/lib/super_diff/rspec/object_inspection/inspectors/kind_of.rb +0 -23
- data/lib/super_diff/rspec/object_inspection/inspectors/primitive.rb +0 -13
- data/lib/super_diff/rspec/object_inspection/inspectors/value_within.rb +0 -29
- data/spec/support/object_id.rb +0 -27
- data/spec/support/ruby_versions.rb +0 -11
- data/spec/unit/object_inspection_spec.rb +0 -1168
@@ -13,11 +13,11 @@ RSpec.describe "Integration with RSpec's #be_truthy matcher", type: :integration
|
|
13
13
|
snippet: %|expect(nil).to be_truthy|,
|
14
14
|
expectation: proc {
|
15
15
|
line do
|
16
|
-
plain
|
17
|
-
|
18
|
-
plain
|
19
|
-
|
20
|
-
plain
|
16
|
+
plain %|Expected |
|
17
|
+
actual %|nil|
|
18
|
+
plain %| to be |
|
19
|
+
expected %|truthy|
|
20
|
+
plain %|.|
|
21
21
|
end
|
22
22
|
},
|
23
23
|
)
|
@@ -40,11 +40,11 @@ RSpec.describe "Integration with RSpec's #be_truthy matcher", type: :integration
|
|
40
40
|
snippet: %|expect(true).not_to be_truthy|,
|
41
41
|
expectation: proc {
|
42
42
|
line do
|
43
|
-
plain
|
44
|
-
|
45
|
-
plain
|
46
|
-
|
47
|
-
plain
|
43
|
+
plain %|Expected |
|
44
|
+
actual %|true|
|
45
|
+
plain %| not to be |
|
46
|
+
expected %|truthy|
|
47
|
+
plain %|.|
|
48
48
|
end
|
49
49
|
},
|
50
50
|
)
|
@@ -6,7 +6,7 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
6
6
|
as_both_colored_and_uncolored do |color_enabled|
|
7
7
|
snippet = <<~TEST.strip
|
8
8
|
expected = ["Einie", "Marty"]
|
9
|
-
actual
|
9
|
+
actual = ["Marty", "Jennifer", "Doc"]
|
10
10
|
expect(actual).to contain_exactly(*expected)
|
11
11
|
TEST
|
12
12
|
program = make_plain_test_program(
|
@@ -19,22 +19,23 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
19
19
|
snippet: %|expect(actual).to contain_exactly(*expected)|,
|
20
20
|
expectation: proc {
|
21
21
|
line do
|
22
|
-
plain
|
23
|
-
|
24
|
-
plain
|
25
|
-
|
26
|
-
plain
|
27
|
-
|
28
|
-
plain
|
22
|
+
plain %|Expected |
|
23
|
+
actual %|["Marty", "Jennifer", "Doc"]|
|
24
|
+
plain %| to contain exactly |
|
25
|
+
expected %|"Einie"|
|
26
|
+
plain %| and |
|
27
|
+
expected %|"Marty"|
|
28
|
+
plain %|.|
|
29
29
|
end
|
30
30
|
},
|
31
31
|
diff: proc {
|
32
|
-
plain_line
|
33
|
-
plain_line
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
plain_line %| [|
|
33
|
+
plain_line %| "Marty",|
|
34
|
+
actual_line %|+ "Jennifer",|
|
35
|
+
actual_line %|+ "Doc",|
|
36
|
+
# expected_line %|- "Einie"| # TODO
|
37
|
+
expected_line %|- "Einie",|
|
38
|
+
plain_line %| ]|
|
38
39
|
},
|
39
40
|
)
|
40
41
|
|
@@ -60,13 +61,13 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
60
61
|
snippet: %|expect(values).not_to contain_exactly(*values)|,
|
61
62
|
expectation: proc {
|
62
63
|
line do
|
63
|
-
plain
|
64
|
-
|
65
|
-
plain
|
66
|
-
|
67
|
-
plain
|
68
|
-
|
69
|
-
plain
|
64
|
+
plain %|Expected |
|
65
|
+
actual %|["Einie", "Marty"]|
|
66
|
+
plain %| not to contain exactly |
|
67
|
+
expected %|"Einie"|
|
68
|
+
plain %| and |
|
69
|
+
expected %|"Marty"|
|
70
|
+
plain %|.|
|
70
71
|
end
|
71
72
|
},
|
72
73
|
)
|
@@ -90,7 +91,7 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
90
91
|
"George McFly",
|
91
92
|
"Lorraine McFly"
|
92
93
|
]
|
93
|
-
actual
|
94
|
+
actual = [
|
94
95
|
"Marty McFly",
|
95
96
|
"Doc Brown",
|
96
97
|
"Einie",
|
@@ -108,32 +109,33 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
108
109
|
snippet: %|expect(actual).to contain_exactly(*expected)|,
|
109
110
|
expectation: proc {
|
110
111
|
line do
|
111
|
-
plain
|
112
|
-
|
112
|
+
plain %| Expected |
|
113
|
+
actual %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
|
113
114
|
end
|
114
115
|
|
115
116
|
line do
|
116
|
-
plain
|
117
|
-
|
118
|
-
plain
|
119
|
-
|
120
|
-
plain
|
121
|
-
|
122
|
-
plain
|
123
|
-
|
124
|
-
plain
|
125
|
-
|
117
|
+
plain %|to contain exactly |
|
118
|
+
expected %|"Doc Brown"|
|
119
|
+
plain %|, |
|
120
|
+
expected %|"Marty McFly"|
|
121
|
+
plain %|, |
|
122
|
+
expected %|"Biff Tannen"|
|
123
|
+
plain %|, |
|
124
|
+
expected %|"George McFly"|
|
125
|
+
plain %| and |
|
126
|
+
expected %|"Lorraine McFly"|
|
126
127
|
end
|
127
128
|
},
|
128
129
|
diff: proc {
|
129
|
-
plain_line
|
130
|
-
plain_line
|
131
|
-
plain_line
|
132
|
-
plain_line
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
130
|
+
plain_line %| [|
|
131
|
+
plain_line %| "Marty McFly",|
|
132
|
+
plain_line %| "Doc Brown",|
|
133
|
+
plain_line %| "Lorraine McFly",|
|
134
|
+
actual_line %|+ "Einie",|
|
135
|
+
expected_line %|- "Biff Tannen",|
|
136
|
+
# expected_line %|- "George McFly"| # TODO
|
137
|
+
expected_line %|- "George McFly",|
|
138
|
+
plain_line %| ]|
|
137
139
|
},
|
138
140
|
)
|
139
141
|
|
@@ -165,19 +167,19 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
165
167
|
newline_before_expectation: true,
|
166
168
|
expectation: proc {
|
167
169
|
line do
|
168
|
-
plain
|
169
|
-
|
170
|
+
plain %| Expected |
|
171
|
+
actual %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
|
170
172
|
end
|
171
173
|
|
172
174
|
line do
|
173
|
-
plain
|
174
|
-
|
175
|
-
plain
|
176
|
-
|
177
|
-
plain
|
178
|
-
|
179
|
-
plain
|
180
|
-
|
175
|
+
plain %|not to contain exactly |
|
176
|
+
expected %|"Marty McFly"|
|
177
|
+
plain %|, |
|
178
|
+
expected %|"Doc Brown"|
|
179
|
+
plain %|, |
|
180
|
+
expected %|"Einie"|
|
181
|
+
plain %| and |
|
182
|
+
expected %|"Lorraine McFly"|
|
181
183
|
end
|
182
184
|
},
|
183
185
|
)
|
@@ -200,7 +202,7 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
200
202
|
/Georg McFly/,
|
201
203
|
/Lorrain McFly/
|
202
204
|
]
|
203
|
-
actual
|
205
|
+
actual = [
|
204
206
|
"Marty McFly",
|
205
207
|
"Doc Brown",
|
206
208
|
"Einie",
|
@@ -218,33 +220,34 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
218
220
|
snippet: %|expect(actual).to contain_exactly(*expected)|,
|
219
221
|
expectation: proc {
|
220
222
|
line do
|
221
|
-
plain
|
222
|
-
|
223
|
+
plain %| Expected |
|
224
|
+
actual %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
|
223
225
|
end
|
224
226
|
|
225
227
|
line do
|
226
|
-
plain
|
227
|
-
|
228
|
-
plain
|
229
|
-
|
230
|
-
plain
|
231
|
-
|
232
|
-
plain
|
233
|
-
|
234
|
-
plain
|
235
|
-
|
228
|
+
plain %|to contain exactly |
|
229
|
+
expected %|/ Brown$/|
|
230
|
+
plain %|, |
|
231
|
+
expected %|"Marty McFly"|
|
232
|
+
plain %|, |
|
233
|
+
expected %|"Biff Tannen"|
|
234
|
+
plain %|, |
|
235
|
+
expected %|/Georg McFly/|
|
236
|
+
plain %| and |
|
237
|
+
expected %|/Lorrain McFly/|
|
236
238
|
end
|
237
239
|
},
|
238
240
|
diff: proc {
|
239
|
-
plain_line
|
240
|
-
plain_line
|
241
|
-
plain_line
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
241
|
+
plain_line %| [|
|
242
|
+
plain_line %| "Marty McFly",|
|
243
|
+
plain_line %| "Doc Brown",|
|
244
|
+
actual_line %|+ "Einie",|
|
245
|
+
actual_line %|+ "Lorraine McFly",|
|
246
|
+
expected_line %|- "Biff Tannen",|
|
247
|
+
expected_line %|- /Georg McFly/,|
|
248
|
+
# expected_line %|- /Lorrain McFly/| # TODO
|
249
|
+
expected_line %|- /Lorrain McFly/,|
|
250
|
+
plain_line %| ]|
|
248
251
|
},
|
249
252
|
)
|
250
253
|
|
@@ -277,21 +280,21 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
277
280
|
newline_before_expectation: true,
|
278
281
|
expectation: proc {
|
279
282
|
line do
|
280
|
-
plain
|
281
|
-
|
283
|
+
plain %| Expected |
|
284
|
+
actual %|[/ Brown$/, "Marty McFly", "Biff Tannen", /Georg McFly/, /Lorrain McFly/]|
|
282
285
|
end
|
283
286
|
|
284
287
|
line do
|
285
|
-
plain
|
286
|
-
|
287
|
-
plain
|
288
|
-
|
289
|
-
plain
|
290
|
-
|
291
|
-
plain
|
292
|
-
|
293
|
-
plain
|
294
|
-
|
288
|
+
plain %|not to contain exactly |
|
289
|
+
expected %|/ Brown$/|
|
290
|
+
plain %|, |
|
291
|
+
expected %|"Marty McFly"|
|
292
|
+
plain %|, |
|
293
|
+
expected %|"Biff Tannen"|
|
294
|
+
plain %|, |
|
295
|
+
expected %|/Georg McFly/|
|
296
|
+
plain %| and |
|
297
|
+
expected %|/Lorrain McFly/|
|
295
298
|
end
|
296
299
|
},
|
297
300
|
)
|
@@ -312,7 +315,7 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
312
315
|
a_collection_containing_exactly("zing"),
|
313
316
|
an_object_having_attributes(baz: "qux"),
|
314
317
|
]
|
315
|
-
actual
|
318
|
+
actual = [
|
316
319
|
{ foo: "bar" },
|
317
320
|
double(baz: "qux"),
|
318
321
|
{ blargh: "riddle" }
|
@@ -329,32 +332,35 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
329
332
|
snippet: %|expect(actual).to contain_exactly(*expected)|,
|
330
333
|
expectation: proc {
|
331
334
|
line do
|
332
|
-
plain
|
333
|
-
|
335
|
+
plain %| Expected |
|
336
|
+
actual %|[{ foo: "bar" }, #<Double (anonymous) baz: "qux">, { blargh: "riddle" }]|
|
334
337
|
end
|
335
338
|
|
336
339
|
line do
|
337
|
-
plain
|
338
|
-
|
339
|
-
plain
|
340
|
-
|
341
|
-
plain
|
342
|
-
|
340
|
+
plain %|to contain exactly |
|
341
|
+
expected %|#<a hash including (foo: "bar")>|
|
342
|
+
plain %|, |
|
343
|
+
expected %|#<a collection containing exactly ("zing")>|
|
344
|
+
plain %| and |
|
345
|
+
expected %|#<an object having attributes (baz: "qux")>|
|
343
346
|
end
|
344
347
|
},
|
345
348
|
diff: proc {
|
346
|
-
plain_line
|
347
|
-
plain_line
|
348
|
-
plain_line
|
349
|
-
plain_line
|
350
|
-
plain_line
|
351
|
-
plain_line
|
352
|
-
plain_line
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
349
|
+
plain_line %| [|
|
350
|
+
plain_line %| {|
|
351
|
+
plain_line %| foo: "bar"|
|
352
|
+
plain_line %| },|
|
353
|
+
plain_line %| #<Double (anonymous) {|
|
354
|
+
plain_line %| baz: "qux"|
|
355
|
+
plain_line %| }>,|
|
356
|
+
actual_line %|+ {|
|
357
|
+
actual_line %|+ blargh: "riddle"|
|
358
|
+
actual_line %|+ },|
|
359
|
+
expected_line %|- #<a collection containing exactly (|
|
360
|
+
expected_line %|- "zing"|
|
361
|
+
# expected_line %|- )>| # TODO
|
362
|
+
expected_line %|- )>,|
|
363
|
+
plain_line %| ]|
|
358
364
|
},
|
359
365
|
)
|
360
366
|
|
@@ -12,11 +12,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
12
12
|
snippet: snippet,
|
13
13
|
expectation: proc {
|
14
14
|
line do
|
15
|
-
plain
|
16
|
-
|
17
|
-
plain
|
18
|
-
|
19
|
-
plain
|
15
|
+
plain %|Expected |
|
16
|
+
actual %|1|
|
17
|
+
plain %| to eq |
|
18
|
+
expected %|42|
|
19
|
+
plain %|.|
|
20
20
|
end
|
21
21
|
},
|
22
22
|
)
|
@@ -37,11 +37,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
37
37
|
snippet: snippet,
|
38
38
|
expectation: proc {
|
39
39
|
line do
|
40
|
-
plain
|
41
|
-
|
42
|
-
plain
|
43
|
-
|
44
|
-
plain
|
40
|
+
plain %|Expected |
|
41
|
+
actual %|42|
|
42
|
+
plain %| not to eq |
|
43
|
+
expected %|42|
|
44
|
+
plain %|.|
|
45
45
|
end
|
46
46
|
},
|
47
47
|
)
|
@@ -67,11 +67,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
67
67
|
snippet: snippet,
|
68
68
|
expectation: proc {
|
69
69
|
line do
|
70
|
-
plain
|
71
|
-
|
72
|
-
plain
|
73
|
-
|
74
|
-
plain
|
70
|
+
plain %|Expected |
|
71
|
+
actual %|:bar|
|
72
|
+
plain %| to eq |
|
73
|
+
expected %|:foo|
|
74
|
+
plain %|.|
|
75
75
|
end
|
76
76
|
},
|
77
77
|
)
|
@@ -95,11 +95,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
95
95
|
snippet: snippet,
|
96
96
|
expectation: proc {
|
97
97
|
line do
|
98
|
-
plain
|
99
|
-
|
100
|
-
plain
|
101
|
-
|
102
|
-
plain
|
98
|
+
plain %|Expected |
|
99
|
+
actual %|:foo|
|
100
|
+
plain %| not to eq |
|
101
|
+
expected %|:foo|
|
102
|
+
plain %|.|
|
103
103
|
end
|
104
104
|
},
|
105
105
|
)
|
@@ -125,11 +125,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
125
125
|
snippet: %|expect("Jennifer").to eq("Marty")|,
|
126
126
|
expectation: proc {
|
127
127
|
line do
|
128
|
-
plain
|
129
|
-
|
130
|
-
plain
|
131
|
-
|
132
|
-
plain
|
128
|
+
plain %|Expected |
|
129
|
+
actual %|"Jennifer"|
|
130
|
+
plain %| to eq |
|
131
|
+
expected %|"Marty"|
|
132
|
+
plain %|.|
|
133
133
|
end
|
134
134
|
},
|
135
135
|
)
|
@@ -153,11 +153,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
153
153
|
snippet: %|expect("Jennifer").not_to eq("Jennifer")|,
|
154
154
|
expectation: proc {
|
155
155
|
line do
|
156
|
-
plain
|
157
|
-
|
158
|
-
plain
|
159
|
-
|
160
|
-
plain
|
156
|
+
plain %|Expected |
|
157
|
+
actual %|"Jennifer"|
|
158
|
+
plain %| not to eq |
|
159
|
+
expected %|"Jennifer"|
|
160
|
+
plain %|.|
|
161
161
|
end
|
162
162
|
},
|
163
163
|
)
|
@@ -174,7 +174,7 @@ 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
180
|
program = make_plain_test_program(
|
@@ -187,26 +187,28 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
187
187
|
snippet: %|expect(expected).to eq(actual)|,
|
188
188
|
expectation: proc {
|
189
189
|
line do
|
190
|
-
plain
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
190
|
+
plain %|Expected |
|
191
|
+
actual %|#<Time 2011-12-13 14:15:16 +00:00 (UTC)>|
|
192
|
+
end
|
193
|
+
|
194
|
+
line do
|
195
|
+
plain %| to eq |
|
196
|
+
expected %|#<Time 2011-12-13 14:15:16+(1/2) +00:00 (UTC)>|
|
195
197
|
end
|
196
198
|
},
|
197
199
|
diff: proc {
|
198
|
-
plain_line
|
199
|
-
plain_line
|
200
|
-
plain_line
|
201
|
-
plain_line
|
202
|
-
plain_line
|
203
|
-
plain_line
|
204
|
-
plain_line
|
205
|
-
|
206
|
-
|
207
|
-
plain_line
|
208
|
-
plain_line
|
209
|
-
plain_line
|
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 " }>"
|
210
212
|
},
|
211
213
|
)
|
212
214
|
|
@@ -233,69 +235,15 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
233
235
|
newline_before_expectation: true,
|
234
236
|
expectation: proc {
|
235
237
|
line do
|
236
|
-
plain
|
237
|
-
|
238
|
-
end
|
239
|
-
|
240
|
-
line do
|
241
|
-
plain "not to eq "
|
242
|
-
alpha %|2011-12-13 14:15:16.000 UTC +00:00 (Time)|
|
243
|
-
end
|
244
|
-
},
|
245
|
-
)
|
246
|
-
|
247
|
-
expect(program).
|
248
|
-
to produce_output_when_run(expected_output).
|
249
|
-
in_color(color_enabled)
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
context "when comparing two different Time and ActiveSupport::TimeWithZone instances", active_record: true do
|
255
|
-
it "produces the correct failure message when used in the positive" do
|
256
|
-
as_both_colored_and_uncolored do |color_enabled|
|
257
|
-
snippet = <<~RUBY
|
258
|
-
expected = Time.utc(2011, 12, 13, 14, 15, 16)
|
259
|
-
actual = Time.utc(2011, 12, 13, 15, 15, 16).in_time_zone("Europe/Stockholm")
|
260
|
-
expect(expected).to eq(actual)
|
261
|
-
RUBY
|
262
|
-
program = make_rspec_rails_test_program(
|
263
|
-
snippet,
|
264
|
-
color_enabled: color_enabled,
|
265
|
-
)
|
266
|
-
|
267
|
-
expected_output = build_expected_output(
|
268
|
-
color_enabled: color_enabled,
|
269
|
-
snippet: %|expect(expected).to eq(actual)|,
|
270
|
-
expectation: proc {
|
271
|
-
line do
|
272
|
-
plain "Expected "
|
273
|
-
beta %|2011-12-13 14:15:16.000 UTC +00:00 (Time)|
|
238
|
+
plain %| Expected |
|
239
|
+
actual %|#<Time 2011-12-13 14:15:16 +00:00 (UTC)>|
|
274
240
|
end
|
275
241
|
|
276
242
|
line do
|
277
|
-
plain
|
278
|
-
|
243
|
+
plain %|not to eq |
|
244
|
+
expected %|#<Time 2011-12-13 14:15:16 +00:00 (UTC)>|
|
279
245
|
end
|
280
246
|
},
|
281
|
-
diff: proc {
|
282
|
-
plain_line " #<ActiveSupport::TimeWithZone {"
|
283
|
-
plain_line " year: 2011,"
|
284
|
-
plain_line " month: 12,"
|
285
|
-
plain_line " day: 13,"
|
286
|
-
alpha_line "- hour: 16,"
|
287
|
-
beta_line "+ hour: 14,"
|
288
|
-
plain_line " min: 15,"
|
289
|
-
plain_line " sec: 16,"
|
290
|
-
plain_line " nsec: 0,"
|
291
|
-
alpha_line "- zone: \"CET\","
|
292
|
-
beta_line "+ zone: \"UTC\","
|
293
|
-
alpha_line "- gmt_offset: 3600,"
|
294
|
-
beta_line "+ gmt_offset: 0,"
|
295
|
-
alpha_line "- utc: 2011-12-13 15:15:16.000 UTC +00:00 (Time)"
|
296
|
-
beta_line "+ utc: 2011-12-13 14:15:16.000 UTC +00:00 (Time)"
|
297
|
-
plain_line " }>"
|
298
|
-
},
|
299
247
|
)
|
300
248
|
|
301
249
|
expect(program).
|
@@ -310,7 +258,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
310
258
|
as_both_colored_and_uncolored do |color_enabled|
|
311
259
|
snippet = <<~TEST.strip
|
312
260
|
expected = "Something entirely different"
|
313
|
-
actual
|
261
|
+
actual = "This is a line\\nAnd that's another line\\n"
|
314
262
|
expect(actual).to eq(expected)
|
315
263
|
TEST
|
316
264
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
@@ -320,17 +268,17 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
320
268
|
snippet: %|expect(actual).to eq(expected)|,
|
321
269
|
expectation: proc {
|
322
270
|
line do
|
323
|
-
plain
|
324
|
-
|
325
|
-
plain
|
326
|
-
|
327
|
-
plain
|
271
|
+
plain %|Expected |
|
272
|
+
actual %|"This is a line\\nAnd that's another line\\n"|
|
273
|
+
plain %| to eq |
|
274
|
+
expected %|"Something entirely different"|
|
275
|
+
plain %|.|
|
328
276
|
end
|
329
277
|
},
|
330
278
|
diff: proc {
|
331
|
-
|
332
|
-
|
333
|
-
|
279
|
+
expected_line %|- Something entirely different|
|
280
|
+
actual_line %|+ This is a line\\n|
|
281
|
+
actual_line %|+ And that's another line\\n|
|
334
282
|
},
|
335
283
|
)
|
336
284
|
|
@@ -346,7 +294,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
346
294
|
as_both_colored_and_uncolored do |color_enabled|
|
347
295
|
snippet = <<~TEST.strip
|
348
296
|
expected = "This is a line\\nAnd that's another line\\n"
|
349
|
-
actual
|
297
|
+
actual = "Something entirely different"
|
350
298
|
expect(actual).to eq(expected)
|
351
299
|
TEST
|
352
300
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
@@ -356,17 +304,17 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
356
304
|
snippet: %|expect(actual).to eq(expected)|,
|
357
305
|
expectation: proc {
|
358
306
|
line do
|
359
|
-
plain
|
360
|
-
|
361
|
-
plain
|
362
|
-
|
363
|
-
plain
|
307
|
+
plain %|Expected |
|
308
|
+
actual %|"Something entirely different"|
|
309
|
+
plain %| to eq |
|
310
|
+
expected %|"This is a line\\nAnd that's another line\\n"|
|
311
|
+
plain %|.|
|
364
312
|
end
|
365
313
|
},
|
366
314
|
diff: proc {
|
367
|
-
|
368
|
-
|
369
|
-
|
315
|
+
expected_line %|- This is a line\\n|
|
316
|
+
expected_line %|- And that's another line\\n|
|
317
|
+
actual_line %|+ Something entirely different|
|
370
318
|
},
|
371
319
|
)
|
372
320
|
|
@@ -382,7 +330,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
382
330
|
as_both_colored_and_uncolored do |color_enabled|
|
383
331
|
snippet = <<~TEST.strip
|
384
332
|
expected = "This is a line\\nAnd that's a line\\nAnd there's a line too\\n"
|
385
|
-
actual
|
333
|
+
actual = "This is a line\\nSomething completely different\\nAnd there's a line too\\n"
|
386
334
|
expect(actual).to eq(expected)
|
387
335
|
TEST
|
388
336
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
@@ -392,20 +340,20 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
392
340
|
snippet: %|expect(actual).to eq(expected)|,
|
393
341
|
expectation: proc {
|
394
342
|
line do
|
395
|
-
plain
|
396
|
-
|
343
|
+
plain %|Expected |
|
344
|
+
actual %|"This is a line\\nSomething completely different\\nAnd there's a line too\\n"|
|
397
345
|
end
|
398
346
|
|
399
347
|
line do
|
400
|
-
plain
|
401
|
-
|
348
|
+
plain %| to eq |
|
349
|
+
expected %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
|
402
350
|
end
|
403
351
|
},
|
404
352
|
diff: proc {
|
405
|
-
plain_line
|
406
|
-
|
407
|
-
|
408
|
-
plain_line
|
353
|
+
plain_line %| This is a line\\n|
|
354
|
+
expected_line %|- And that's a line\\n|
|
355
|
+
actual_line %|+ Something completely different\\n|
|
356
|
+
plain_line %| And there's a line too\\n|
|
409
357
|
},
|
410
358
|
)
|
411
359
|
|
@@ -429,13 +377,13 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
429
377
|
newline_before_expectation: true,
|
430
378
|
expectation: proc {
|
431
379
|
line do
|
432
|
-
plain
|
433
|
-
|
380
|
+
plain %| Expected |
|
381
|
+
actual %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
|
434
382
|
end
|
435
383
|
|
436
384
|
line do
|
437
|
-
plain
|
438
|
-
|
385
|
+
plain %|not to eq |
|
386
|
+
expected %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
|
439
387
|
end
|
440
388
|
},
|
441
389
|
)
|
@@ -464,7 +412,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
464
412
|
}
|
465
413
|
]
|
466
414
|
]
|
467
|
-
actual
|
415
|
+
actual = [
|
468
416
|
[
|
469
417
|
:h2,
|
470
418
|
[:span, [:text, "Goodbye world"]],
|
@@ -489,45 +437,45 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
489
437
|
snippet: %|expect(actual).to eq(expected)|,
|
490
438
|
expectation: proc {
|
491
439
|
line do
|
492
|
-
plain
|
493
|
-
|
440
|
+
plain %|Expected |
|
441
|
+
actual %|[[:h2, [:span, [:text, "Goodbye world"]], { id: "hero", class: "header", data: { "sticky" => false, :role => "deprecated", :person => #<SuperDiff::Test::Person name: "Doc", age: 60> } }], :br]|
|
494
442
|
end
|
495
443
|
|
496
444
|
line do
|
497
|
-
plain
|
498
|
-
|
445
|
+
plain %| to eq |
|
446
|
+
expected %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
|
499
447
|
end
|
500
448
|
},
|
501
449
|
diff: proc {
|
502
|
-
plain_line
|
503
|
-
plain_line
|
504
|
-
|
505
|
-
|
506
|
-
plain_line
|
507
|
-
plain_line
|
508
|
-
plain_line
|
509
|
-
plain_line
|
510
|
-
|
511
|
-
|
512
|
-
plain_line
|
513
|
-
plain_line
|
514
|
-
plain_line
|
515
|
-
|
516
|
-
plain_line
|
517
|
-
plain_line
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
plain_line
|
522
|
-
|
523
|
-
|
524
|
-
plain_line
|
525
|
-
plain_line
|
526
|
-
plain_line
|
527
|
-
plain_line
|
528
|
-
plain_line
|
529
|
-
|
530
|
-
plain_line
|
450
|
+
plain_line %| [|
|
451
|
+
plain_line %| [|
|
452
|
+
expected_line %|- :h1,|
|
453
|
+
actual_line %|+ :h2,|
|
454
|
+
plain_line %| [|
|
455
|
+
plain_line %| :span,|
|
456
|
+
plain_line %| [|
|
457
|
+
plain_line %| :text,|
|
458
|
+
expected_line %|- "Hello world"|
|
459
|
+
actual_line %|+ "Goodbye world"|
|
460
|
+
plain_line %| ]|
|
461
|
+
plain_line %| ],|
|
462
|
+
plain_line %| {|
|
463
|
+
actual_line %|+ id: "hero",|
|
464
|
+
plain_line %| class: "header",|
|
465
|
+
plain_line %| data: {|
|
466
|
+
expected_line %|- "sticky" => true,|
|
467
|
+
actual_line %|+ "sticky" => false,|
|
468
|
+
actual_line %|+ :role => "deprecated",|
|
469
|
+
plain_line %| :person => #<SuperDiff::Test::Person {|
|
470
|
+
expected_line %|- name: "Marty",|
|
471
|
+
actual_line %|+ name: "Doc",|
|
472
|
+
plain_line %| age: 60|
|
473
|
+
plain_line %| }>|
|
474
|
+
plain_line %| }|
|
475
|
+
plain_line %| }|
|
476
|
+
plain_line %| ],|
|
477
|
+
actual_line %|+ :br|
|
478
|
+
plain_line %| ]|
|
531
479
|
},
|
532
480
|
)
|
533
481
|
|
@@ -563,13 +511,13 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
563
511
|
newline_before_expectation: true,
|
564
512
|
expectation: proc {
|
565
513
|
line do
|
566
|
-
plain
|
567
|
-
|
514
|
+
plain %| Expected |
|
515
|
+
actual %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
|
568
516
|
end
|
569
517
|
|
570
518
|
line do
|
571
|
-
plain
|
572
|
-
|
519
|
+
plain %|not to eq |
|
520
|
+
expected %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
|
573
521
|
end
|
574
522
|
},
|
575
523
|
)
|
@@ -604,7 +552,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
604
552
|
{ name: "Chevy 4x4" }
|
605
553
|
]
|
606
554
|
}
|
607
|
-
actual
|
555
|
+
actual = {
|
608
556
|
customer: {
|
609
557
|
person: SuperDiff::Test::Person.new(name: "Marty McFly, Jr.", age: 17),
|
610
558
|
shipping_address: {
|
@@ -632,47 +580,47 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
632
580
|
snippet: %|expect(actual).to eq(expected)|,
|
633
581
|
expectation: proc {
|
634
582
|
line do
|
635
|
-
plain
|
636
|
-
|
583
|
+
plain %|Expected |
|
584
|
+
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" }] }|
|
637
585
|
end
|
638
586
|
|
639
587
|
line do
|
640
|
-
plain
|
641
|
-
|
588
|
+
plain %| to eq |
|
589
|
+
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" }] }|
|
642
590
|
end
|
643
591
|
},
|
644
592
|
diff: proc {
|
645
|
-
plain_line
|
646
|
-
plain_line
|
647
|
-
plain_line
|
648
|
-
|
649
|
-
|
650
|
-
plain_line
|
651
|
-
plain_line
|
652
|
-
plain_line
|
653
|
-
|
654
|
-
|
655
|
-
plain_line
|
656
|
-
plain_line
|
657
|
-
plain_line
|
658
|
-
plain_line
|
659
|
-
plain_line
|
660
|
-
plain_line
|
661
|
-
plain_line
|
662
|
-
plain_line
|
663
|
-
plain_line
|
664
|
-
plain_line
|
665
|
-
plain_line
|
666
|
-
plain_line
|
667
|
-
plain_line
|
668
|
-
plain_line
|
669
|
-
plain_line
|
670
|
-
plain_line
|
671
|
-
|
672
|
-
|
673
|
-
plain_line
|
674
|
-
plain_line
|
675
|
-
plain_line
|
593
|
+
plain_line %| {|
|
594
|
+
plain_line %| customer: {|
|
595
|
+
plain_line %| person: #<SuperDiff::Test::Person {|
|
596
|
+
expected_line %|- name: "Marty McFly",|
|
597
|
+
actual_line %|+ name: "Marty McFly, Jr.",|
|
598
|
+
plain_line %| age: 17|
|
599
|
+
plain_line %| }>,|
|
600
|
+
plain_line %| shipping_address: {|
|
601
|
+
expected_line %|- line_1: "123 Main St.",|
|
602
|
+
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
603
|
+
plain_line %| city: "Hill Valley",|
|
604
|
+
plain_line %| state: "CA",|
|
605
|
+
plain_line %| zip: "90382"|
|
606
|
+
plain_line %| }|
|
607
|
+
plain_line %| },|
|
608
|
+
plain_line %| items: [|
|
609
|
+
plain_line %| {|
|
610
|
+
plain_line %| name: "Fender Stratocaster",|
|
611
|
+
plain_line %| cost: 100000,|
|
612
|
+
plain_line %| options: [|
|
613
|
+
plain_line %| "red",|
|
614
|
+
plain_line %| "blue",|
|
615
|
+
plain_line %| "green"|
|
616
|
+
plain_line %| ]|
|
617
|
+
plain_line %| },|
|
618
|
+
plain_line %| {|
|
619
|
+
expected_line %|- name: "Chevy 4x4"|
|
620
|
+
actual_line %|+ name: "Mattel Hoverboard"|
|
621
|
+
plain_line %| }|
|
622
|
+
plain_line %| ]|
|
623
|
+
plain_line %| }|
|
676
624
|
},
|
677
625
|
)
|
678
626
|
|
@@ -714,13 +662,13 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
714
662
|
newline_before_expectation: true,
|
715
663
|
expectation: proc {
|
716
664
|
line do
|
717
|
-
plain
|
718
|
-
|
665
|
+
plain %| Expected |
|
666
|
+
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" }] }|
|
719
667
|
end
|
720
668
|
|
721
669
|
line do
|
722
|
-
plain
|
723
|
-
|
670
|
+
plain %|not to eq |
|
671
|
+
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" }] }|
|
724
672
|
end
|
725
673
|
},
|
726
674
|
)
|
@@ -740,7 +688,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
740
688
|
name: "Marty",
|
741
689
|
age: 31,
|
742
690
|
)
|
743
|
-
actual
|
691
|
+
actual = SuperDiff::Test::Customer.new(
|
744
692
|
name: "Doc",
|
745
693
|
shipping_address: :some_shipping_address,
|
746
694
|
phone: "1234567890",
|
@@ -755,13 +703,13 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
755
703
|
newline_before_expectation: true,
|
756
704
|
expectation: proc {
|
757
705
|
line do
|
758
|
-
plain
|
759
|
-
|
706
|
+
plain %|Expected |
|
707
|
+
actual %|#<SuperDiff::Test::Customer name: "Doc", shipping_address: :some_shipping_address, phone: "1234567890">|
|
760
708
|
end
|
761
709
|
|
762
710
|
line do
|
763
|
-
plain
|
764
|
-
|
711
|
+
plain %| to eq |
|
712
|
+
expected %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
|
765
713
|
end
|
766
714
|
},
|
767
715
|
)
|
@@ -789,13 +737,13 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
789
737
|
newline_before_expectation: true,
|
790
738
|
expectation: proc {
|
791
739
|
line do
|
792
|
-
plain
|
793
|
-
|
740
|
+
plain %| Expected |
|
741
|
+
actual %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
|
794
742
|
end
|
795
743
|
|
796
744
|
line do
|
797
|
-
plain
|
798
|
-
|
745
|
+
plain %|not to eq |
|
746
|
+
expected %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
|
799
747
|
end
|
800
748
|
},
|
801
749
|
)
|
@@ -815,7 +763,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
815
763
|
name: "camera",
|
816
764
|
quantity: 3,
|
817
765
|
)
|
818
|
-
actual
|
766
|
+
actual = SuperDiff::Test::Player.new(
|
819
767
|
handle: "mcmire",
|
820
768
|
character: "Jon",
|
821
769
|
inventory: ["sword"],
|
@@ -832,17 +780,14 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
832
780
|
snippet: %|expect(actual).to eq(expected)|,
|
833
781
|
newline_before_expectation: true,
|
834
782
|
expectation: proc {
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
plain " to eq "
|
844
|
-
alpha %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
|
845
|
-
end
|
783
|
+
line do
|
784
|
+
plain %|Expected |
|
785
|
+
actual %|#<SuperDiff::Test::Player @character="Jon", @handle="mcmire", @health=4, @inventory=["sword"], @shields=11.4, @ultimate=true>|
|
786
|
+
end
|
787
|
+
|
788
|
+
line do
|
789
|
+
plain %| to eq |
|
790
|
+
expected %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
|
846
791
|
end
|
847
792
|
},
|
848
793
|
)
|
@@ -870,17 +815,14 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
870
815
|
snippet: %|expect(value).not_to eq(value)|,
|
871
816
|
newline_before_expectation: true,
|
872
817
|
expectation: proc {
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
plain "not to eq "
|
882
|
-
alpha %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
|
883
|
-
end
|
818
|
+
line do
|
819
|
+
plain %| Expected |
|
820
|
+
actual %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
|
821
|
+
end
|
822
|
+
|
823
|
+
line do
|
824
|
+
plain %|not to eq |
|
825
|
+
expected %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
|
884
826
|
end
|
885
827
|
},
|
886
828
|
)
|
@@ -898,7 +840,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
898
840
|
as_both_colored_and_uncolored do |color_enabled|
|
899
841
|
snippet = <<~TEST.strip
|
900
842
|
expected = { foo: nil }
|
901
|
-
actual
|
843
|
+
actual = { foo: [] }
|
902
844
|
expect(actual).to eq(expected)
|
903
845
|
TEST
|
904
846
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
@@ -909,18 +851,18 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
909
851
|
newline_before_expectation: true,
|
910
852
|
expectation: proc {
|
911
853
|
line do
|
912
|
-
plain
|
913
|
-
|
914
|
-
plain
|
915
|
-
|
916
|
-
plain
|
854
|
+
plain %|Expected |
|
855
|
+
actual %|{ foo: [] }|
|
856
|
+
plain %| to eq |
|
857
|
+
expected %|{ foo: nil }|
|
858
|
+
plain %|.|
|
917
859
|
end
|
918
860
|
},
|
919
861
|
diff: proc {
|
920
|
-
plain_line
|
921
|
-
|
922
|
-
|
923
|
-
plain_line
|
862
|
+
plain_line %| {|
|
863
|
+
expected_line %|- foo: nil|
|
864
|
+
actual_line %|+ foo: []|
|
865
|
+
plain_line %| }|
|
924
866
|
}
|
925
867
|
)
|
926
868
|
|
@@ -936,7 +878,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
936
878
|
as_both_colored_and_uncolored do |color_enabled|
|
937
879
|
snippet = <<~TEST.strip
|
938
880
|
expected = { foo: nil }
|
939
|
-
actual
|
881
|
+
actual = { foo: {} }
|
940
882
|
expect(actual).to eq(expected)
|
941
883
|
TEST
|
942
884
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
@@ -947,18 +889,18 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
947
889
|
newline_before_expectation: true,
|
948
890
|
expectation: proc {
|
949
891
|
line do
|
950
|
-
plain
|
951
|
-
|
952
|
-
plain
|
953
|
-
|
954
|
-
plain
|
892
|
+
plain %|Expected |
|
893
|
+
actual %|{ foo: {} }|
|
894
|
+
plain %| to eq |
|
895
|
+
expected %|{ foo: nil }|
|
896
|
+
plain %|.|
|
955
897
|
end
|
956
898
|
},
|
957
899
|
diff: proc {
|
958
|
-
plain_line
|
959
|
-
|
960
|
-
|
961
|
-
plain_line
|
900
|
+
plain_line %| {|
|
901
|
+
expected_line %|- foo: nil|
|
902
|
+
actual_line %|+ foo: {}|
|
903
|
+
plain_line %| }|
|
962
904
|
}
|
963
905
|
)
|
964
906
|
|
@@ -974,7 +916,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
974
916
|
as_both_colored_and_uncolored do |color_enabled|
|
975
917
|
snippet = <<~TEST.strip
|
976
918
|
expected = { foo: nil }
|
977
|
-
actual
|
919
|
+
actual = { foo: SuperDiff::Test::EmptyClass.new }
|
978
920
|
expect(actual).to eq(expected)
|
979
921
|
TEST
|
980
922
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
@@ -985,18 +927,18 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
985
927
|
newline_before_expectation: true,
|
986
928
|
expectation: proc {
|
987
929
|
line do
|
988
|
-
plain
|
989
|
-
|
990
|
-
plain
|
991
|
-
|
992
|
-
plain
|
930
|
+
plain %|Expected |
|
931
|
+
actual %|{ foo: #<SuperDiff::Test::EmptyClass> }|
|
932
|
+
plain %| to eq |
|
933
|
+
expected %|{ foo: nil }|
|
934
|
+
plain %|.|
|
993
935
|
end
|
994
936
|
},
|
995
937
|
diff: proc {
|
996
|
-
plain_line
|
997
|
-
|
998
|
-
|
999
|
-
plain_line
|
938
|
+
plain_line %| {|
|
939
|
+
expected_line %|- foo: nil|
|
940
|
+
actual_line %|+ foo: #<SuperDiff::Test::EmptyClass>|
|
941
|
+
plain_line %| }|
|
1000
942
|
}
|
1001
943
|
)
|
1002
944
|
|
@@ -1007,4 +949,8 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
1007
949
|
end
|
1008
950
|
end
|
1009
951
|
end
|
952
|
+
|
953
|
+
it_behaves_like "a matcher that supports elided diffs" do
|
954
|
+
let(:matcher) { :eq }
|
955
|
+
end
|
1010
956
|
end
|