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
@@ -9,26 +9,27 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
9
9
|
snippet = <<~TEST.strip
|
10
10
|
expect(:anything).to fail_with_indented_multiline_failure_message
|
11
11
|
TEST
|
12
|
-
program =
|
13
|
-
snippet,
|
14
|
-
color_enabled: color_enabled,
|
15
|
-
)
|
12
|
+
program =
|
13
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
16
14
|
|
17
|
-
expected_output =
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
15
|
+
expected_output =
|
16
|
+
build_expected_output(
|
17
|
+
color_enabled: color_enabled,
|
18
|
+
snippet:
|
19
|
+
"expect(:anything).to fail_with_indented_multiline_failure_message",
|
20
|
+
newline_before_expectation: true,
|
21
|
+
expectation:
|
22
|
+
proc do
|
23
|
+
red_line "This is a message that spans multiple lines."
|
24
|
+
red_line "Here is the next line."
|
25
|
+
plain_line " This part is indented, for whatever reason. It just kinda keeps"
|
26
|
+
plain_line " going until we finish saying whatever it is we want to say."
|
27
|
+
end
|
28
|
+
)
|
28
29
|
|
29
|
-
expect(program).
|
30
|
-
|
31
|
-
|
30
|
+
expect(program).to produce_output_when_run(
|
31
|
+
expected_output
|
32
|
+
).in_color(color_enabled)
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -40,25 +41,26 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
40
41
|
snippet = <<~TEST.strip
|
41
42
|
expect(:anything).to fail_with_paragraphed_failure_message
|
42
43
|
TEST
|
43
|
-
program =
|
44
|
-
snippet,
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
44
|
+
program =
|
45
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
46
|
+
|
47
|
+
expected_output =
|
48
|
+
build_expected_output(
|
49
|
+
color_enabled: color_enabled,
|
50
|
+
snippet:
|
51
|
+
"expect(:anything).to fail_with_paragraphed_failure_message",
|
52
|
+
newline_before_expectation: true,
|
53
|
+
expectation:
|
54
|
+
proc do
|
55
|
+
red_line "This is a message that spans multiple paragraphs."
|
56
|
+
newline
|
57
|
+
plain_line "Here is the next paragraph."
|
58
|
+
end
|
59
|
+
)
|
60
|
+
|
61
|
+
expect(program).to produce_output_when_run(
|
62
|
+
expected_output
|
63
|
+
).in_color(color_enabled)
|
62
64
|
end
|
63
65
|
end
|
64
66
|
end
|
@@ -69,24 +71,25 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
69
71
|
snippet = <<~TEST.strip
|
70
72
|
expect(:anything).to fail_with_non_indented_multiline_failure_message
|
71
73
|
TEST
|
72
|
-
program =
|
73
|
-
snippet,
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
74
|
+
program =
|
75
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
76
|
+
|
77
|
+
expected_output =
|
78
|
+
build_expected_output(
|
79
|
+
color_enabled: color_enabled,
|
80
|
+
snippet:
|
81
|
+
"expect(:anything).to fail_with_non_indented_multiline_failure_message",
|
82
|
+
newline_before_expectation: true,
|
83
|
+
expectation:
|
84
|
+
proc do
|
85
|
+
red_line "This is a message that spans multiple lines."
|
86
|
+
red_line "Here is the next line."
|
87
|
+
end
|
88
|
+
)
|
89
|
+
|
90
|
+
expect(program).to produce_output_when_run(
|
91
|
+
expected_output
|
92
|
+
).in_color(color_enabled)
|
90
93
|
end
|
91
94
|
end
|
92
95
|
end
|
@@ -99,22 +102,21 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
99
102
|
snippet = <<~TEST.strip
|
100
103
|
expect(:anything).to fail_with_singleline_failure_message
|
101
104
|
TEST
|
102
|
-
program =
|
103
|
-
snippet,
|
104
|
-
color_enabled: color_enabled,
|
105
|
-
)
|
105
|
+
program =
|
106
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
106
107
|
|
107
|
-
expected_output =
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
108
|
+
expected_output =
|
109
|
+
build_expected_output(
|
110
|
+
color_enabled: color_enabled,
|
111
|
+
snippet:
|
112
|
+
"expect(:anything).to fail_with_singleline_failure_message",
|
113
|
+
expectation:
|
114
|
+
proc { red_line "This is a message that spans only one line." }
|
115
|
+
)
|
114
116
|
|
115
|
-
expect(program).
|
116
|
-
|
117
|
-
|
117
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
118
|
+
color_enabled
|
119
|
+
)
|
118
120
|
end
|
119
121
|
end
|
120
122
|
end
|
@@ -128,26 +130,27 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
128
130
|
snippet = <<~TEST.strip
|
129
131
|
expect(:anything).not_to pass_with_indented_multiline_failure_message
|
130
132
|
TEST
|
131
|
-
program =
|
132
|
-
snippet,
|
133
|
-
color_enabled: color_enabled,
|
134
|
-
)
|
133
|
+
program =
|
134
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
135
135
|
|
136
|
-
expected_output =
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
136
|
+
expected_output =
|
137
|
+
build_expected_output(
|
138
|
+
color_enabled: color_enabled,
|
139
|
+
snippet:
|
140
|
+
"expect(:anything).not_to pass_with_indented_multiline_failure_message",
|
141
|
+
newline_before_expectation: true,
|
142
|
+
expectation:
|
143
|
+
proc do
|
144
|
+
red_line "This is a message that spans multiple lines."
|
145
|
+
red_line "Here is the next line."
|
146
|
+
plain_line " This part is indented, for whatever reason. It just kinda keeps"
|
147
|
+
plain_line " going until we finish saying whatever it is we want to say."
|
148
|
+
end
|
149
|
+
)
|
147
150
|
|
148
|
-
expect(program).
|
149
|
-
|
150
|
-
|
151
|
+
expect(program).to produce_output_when_run(
|
152
|
+
expected_output
|
153
|
+
).in_color(color_enabled)
|
151
154
|
end
|
152
155
|
end
|
153
156
|
end
|
@@ -159,25 +162,26 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
159
162
|
snippet = <<~TEST.strip
|
160
163
|
expect(:anything).not_to pass_with_paragraphed_failure_message
|
161
164
|
TEST
|
162
|
-
program =
|
163
|
-
snippet,
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
165
|
+
program =
|
166
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
167
|
+
|
168
|
+
expected_output =
|
169
|
+
build_expected_output(
|
170
|
+
color_enabled: color_enabled,
|
171
|
+
snippet:
|
172
|
+
"expect(:anything).not_to pass_with_paragraphed_failure_message",
|
173
|
+
newline_before_expectation: true,
|
174
|
+
expectation:
|
175
|
+
proc do
|
176
|
+
red_line "This is a message that spans multiple paragraphs."
|
177
|
+
newline
|
178
|
+
plain_line "Here is the next paragraph."
|
179
|
+
end
|
180
|
+
)
|
181
|
+
|
182
|
+
expect(program).to produce_output_when_run(
|
183
|
+
expected_output
|
184
|
+
).in_color(color_enabled)
|
181
185
|
end
|
182
186
|
end
|
183
187
|
end
|
@@ -188,24 +192,25 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
188
192
|
snippet = <<~TEST.strip
|
189
193
|
expect(:anything).not_to pass_with_non_indented_multiline_failure_message
|
190
194
|
TEST
|
191
|
-
program =
|
192
|
-
snippet,
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
195
|
+
program =
|
196
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
197
|
+
|
198
|
+
expected_output =
|
199
|
+
build_expected_output(
|
200
|
+
color_enabled: color_enabled,
|
201
|
+
snippet:
|
202
|
+
"expect(:anything).not_to pass_with_non_indented_multiline_failure_message",
|
203
|
+
newline_before_expectation: true,
|
204
|
+
expectation:
|
205
|
+
proc do
|
206
|
+
red_line "This is a message that spans multiple lines."
|
207
|
+
red_line "Here is the next line."
|
208
|
+
end
|
209
|
+
)
|
210
|
+
|
211
|
+
expect(program).to produce_output_when_run(
|
212
|
+
expected_output
|
213
|
+
).in_color(color_enabled)
|
209
214
|
end
|
210
215
|
end
|
211
216
|
end
|
@@ -218,22 +223,21 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
218
223
|
snippet = <<~TEST.strip
|
219
224
|
expect(:anything).not_to pass_with_singleline_failure_message
|
220
225
|
TEST
|
221
|
-
program =
|
222
|
-
snippet,
|
223
|
-
color_enabled: color_enabled,
|
224
|
-
)
|
226
|
+
program =
|
227
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
225
228
|
|
226
|
-
expected_output =
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
229
|
+
expected_output =
|
230
|
+
build_expected_output(
|
231
|
+
color_enabled: color_enabled,
|
232
|
+
snippet:
|
233
|
+
"expect(:anything).not_to pass_with_singleline_failure_message",
|
234
|
+
expectation:
|
235
|
+
proc { red_line "This is a message that spans only one line." }
|
236
|
+
)
|
233
237
|
|
234
|
-
expect(program).
|
235
|
-
|
236
|
-
|
238
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
239
|
+
color_enabled
|
240
|
+
)
|
237
241
|
end
|
238
242
|
end
|
239
243
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
RSpec.describe "Integration with RSpec and unhandled errors",
|
3
|
+
RSpec.describe "Integration with RSpec and unhandled errors",
|
4
|
+
type: :integration do
|
4
5
|
context "when a random exception occurs" do
|
5
6
|
context "and the message spans multiple lines" do
|
6
7
|
it "highlights the first line in red, and then leaves the rest of the message alone" do
|
@@ -8,29 +9,29 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
|
|
8
9
|
snippet = <<~TEST.strip
|
9
10
|
raise "Some kind of error or whatever\\n\\nThis is another line"
|
10
11
|
TEST
|
11
|
-
program =
|
12
|
-
snippet,
|
13
|
-
|
12
|
+
program =
|
13
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
14
|
+
|
15
|
+
expected_output =
|
16
|
+
build_expected_output(
|
17
|
+
color_enabled: color_enabled,
|
18
|
+
snippet: snippet,
|
19
|
+
newline_before_expectation: true,
|
20
|
+
indentation: 5,
|
21
|
+
expectation:
|
22
|
+
proc do
|
23
|
+
red_line "RuntimeError:"
|
24
|
+
indent by: 2 do
|
25
|
+
red_line "Some kind of error or whatever"
|
26
|
+
newline
|
27
|
+
plain_line "This is another line"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
)
|
31
|
+
|
32
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
33
|
+
color_enabled
|
14
34
|
)
|
15
|
-
|
16
|
-
expected_output = build_expected_output(
|
17
|
-
color_enabled: color_enabled,
|
18
|
-
snippet: snippet,
|
19
|
-
newline_before_expectation: true,
|
20
|
-
indentation: 5,
|
21
|
-
expectation: proc {
|
22
|
-
red_line "RuntimeError:"
|
23
|
-
indent by: 2 do
|
24
|
-
red_line "Some kind of error or whatever"
|
25
|
-
newline
|
26
|
-
plain_line "This is another line"
|
27
|
-
end
|
28
|
-
},
|
29
|
-
)
|
30
|
-
|
31
|
-
expect(program).
|
32
|
-
to produce_output_when_run(expected_output).
|
33
|
-
in_color(color_enabled)
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
@@ -41,27 +42,27 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
|
|
41
42
|
snippet = <<~TEST.strip
|
42
43
|
raise "Some kind of error or whatever"
|
43
44
|
TEST
|
44
|
-
program =
|
45
|
-
snippet,
|
46
|
-
|
45
|
+
program =
|
46
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
47
|
+
|
48
|
+
expected_output =
|
49
|
+
build_expected_output(
|
50
|
+
color_enabled: color_enabled,
|
51
|
+
snippet: snippet,
|
52
|
+
newline_before_expectation: true,
|
53
|
+
indentation: 5,
|
54
|
+
expectation:
|
55
|
+
proc do
|
56
|
+
red_line "RuntimeError:"
|
57
|
+
indent by: 2 do
|
58
|
+
red_line "Some kind of error or whatever"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
)
|
62
|
+
|
63
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
64
|
+
color_enabled
|
47
65
|
)
|
48
|
-
|
49
|
-
expected_output = build_expected_output(
|
50
|
-
color_enabled: color_enabled,
|
51
|
-
snippet: snippet,
|
52
|
-
newline_before_expectation: true,
|
53
|
-
indentation: 5,
|
54
|
-
expectation: proc {
|
55
|
-
red_line "RuntimeError:"
|
56
|
-
indent by: 2 do
|
57
|
-
red_line "Some kind of error or whatever"
|
58
|
-
end
|
59
|
-
},
|
60
|
-
)
|
61
|
-
|
62
|
-
expect(program).
|
63
|
-
to produce_output_when_run(expected_output).
|
64
|
-
in_color(color_enabled)
|
65
66
|
end
|
66
67
|
end
|
67
68
|
end
|
@@ -85,61 +86,64 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
|
|
85
86
|
end
|
86
87
|
CODE
|
87
88
|
|
88
|
-
program =
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
program =
|
90
|
+
make_plain_test_program(
|
91
|
+
code,
|
92
|
+
color_enabled: color_enabled,
|
93
|
+
preserve_as_whole_file: true
|
94
|
+
)
|
93
95
|
|
94
|
-
expected_output1 =
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
expected_output1 =
|
97
|
+
colored(color_enabled: color_enabled) do
|
98
|
+
indent by: 5 do
|
99
|
+
line do
|
100
|
+
plain "1.1) "
|
101
|
+
bold "Failure/Error: "
|
102
|
+
plain snippet
|
103
|
+
end
|
101
104
|
|
102
|
-
|
105
|
+
newline
|
103
106
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
107
|
+
indent by: 5 do
|
108
|
+
red_line "RuntimeError:"
|
109
|
+
indent by: 2 do
|
110
|
+
red_line "Some kind of error or whatever"
|
111
|
+
newline
|
112
|
+
line "This is another line"
|
113
|
+
end
|
110
114
|
end
|
111
115
|
end
|
112
116
|
end
|
113
|
-
end
|
114
117
|
|
115
|
-
expected_output2 =
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
expected_output2 =
|
119
|
+
colored(color_enabled: color_enabled) do
|
120
|
+
indent by: 5 do
|
121
|
+
line do
|
122
|
+
plain "1.2) "
|
123
|
+
bold "Failure/Error: "
|
124
|
+
plain snippet
|
125
|
+
end
|
122
126
|
|
123
|
-
|
127
|
+
newline
|
124
128
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
129
|
+
indent by: 5 do
|
130
|
+
red_line "RuntimeError:"
|
131
|
+
indent by: 2 do
|
132
|
+
red_line "Some kind of error or whatever"
|
133
|
+
newline
|
134
|
+
line "This is another line"
|
135
|
+
end
|
131
136
|
end
|
132
137
|
end
|
133
138
|
end
|
134
|
-
end
|
135
139
|
|
136
|
-
expect(program).
|
137
|
-
|
138
|
-
|
140
|
+
expect(program).to produce_output_when_run(expected_output1).in_color(
|
141
|
+
color_enabled
|
142
|
+
)
|
139
143
|
|
140
|
-
expect(program).
|
141
|
-
|
142
|
-
|
144
|
+
expect(program).to produce_output_when_run(expected_output2).in_color(
|
145
|
+
color_enabled
|
146
|
+
)
|
143
147
|
end
|
144
148
|
end
|
145
149
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
require "pp"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.2")
|
4
|
+
begin
|
5
|
+
require "pry-byebug"
|
6
|
+
rescue LoadError
|
7
|
+
end
|
7
8
|
|
8
|
-
begin
|
9
|
-
|
10
|
-
rescue LoadError
|
9
|
+
begin
|
10
|
+
require "pry-nav"
|
11
|
+
rescue LoadError
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
require "climate_control"
|
@@ -27,20 +29,19 @@ begin
|
|
27
29
|
|
28
30
|
ActiveRecord::Base.establish_connection(
|
29
31
|
adapter: "sqlite3",
|
30
|
-
database: ":memory:"
|
32
|
+
database: ":memory:"
|
31
33
|
)
|
32
34
|
rescue LoadError
|
33
35
|
active_record_available = false
|
34
36
|
end
|
35
37
|
|
36
|
-
Dir
|
37
|
-
|
38
|
-
|
38
|
+
Dir
|
39
|
+
.glob(File.expand_path("support/**/*.rb", __dir__))
|
40
|
+
.sort
|
41
|
+
.reject do |file|
|
39
42
|
file.include?("/models/active_record/") && !active_record_available
|
40
|
-
end.
|
41
|
-
each do |file|
|
42
|
-
require file
|
43
43
|
end
|
44
|
+
.each { |file| require file }
|
44
45
|
|
45
46
|
RSpec.configure do |config|
|
46
47
|
config.include(SuperDiff::UnitTests, type: :unit)
|
@@ -61,18 +62,14 @@ RSpec.configure do |config|
|
|
61
62
|
config.disable_monkey_patching!
|
62
63
|
config.warnings = true
|
63
64
|
|
64
|
-
if
|
65
|
-
config.default_formatter = "documentation"
|
66
|
-
end
|
65
|
+
config.default_formatter = "documentation" if !%w[true 1].include?(ENV["CI"])
|
67
66
|
|
68
67
|
config.filter_run_excluding active_record: true unless active_record_available
|
69
68
|
|
70
69
|
config.order = :random
|
71
70
|
Kernel.srand config.seed
|
72
71
|
|
73
|
-
if ENV["CI"] == "true"
|
74
|
-
config.color_mode = :on
|
75
|
-
end
|
72
|
+
config.color_mode = :on if ENV["CI"] == "true"
|
76
73
|
end
|
77
74
|
|
78
75
|
require "warnings_logger"
|