super_diff 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/super_diff.rb +27 -6
- 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 +81 -8
- data/lib/super_diff/csi.rb +1 -2
- data/lib/super_diff/csi/four_bit_color.rb +0 -2
- 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 +2 -2
- data/lib/super_diff/equality_matchers/default.rb +2 -2
- data/lib/super_diff/equality_matchers/hash.rb +2 -2
- data/lib/super_diff/equality_matchers/multiline_string.rb +2 -2
- data/lib/super_diff/equality_matchers/primitive.rb +4 -7
- data/lib/super_diff/equality_matchers/singleline_string.rb +2 -2
- data/lib/super_diff/helpers.rb +52 -2
- data/lib/super_diff/line.rb +83 -0
- data/lib/super_diff/object_inspection.rb +12 -1
- 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/{inspectors → inspection_tree_builders}/time_like.rb +19 -18
- 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/hash.rb +0 -7
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +2 -6
- 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 +12 -13
- data/lib/super_diff/rspec/monkey_patches.rb +2 -2
- 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/{inspectors → inspection_tree_builders}/collection_including.rb +9 -8
- 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/{inspectors → inspection_tree_builders}/instance_of.rb +3 -5
- data/lib/super_diff/rspec/object_inspection/{inspectors → inspection_tree_builders}/kind_of.rb +3 -5
- 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 +0 -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 -410
- data/spec/integration/rails/active_support_spec.rb +19 -0
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +12 -6
- data/spec/integration/rspec/eq_matcher_spec.rb +22 -88
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +6 -7
- data/spec/integration/rspec/match_array_matcher_spec.rb +14 -7
- data/spec/integration/rspec/match_matcher_spec.rb +10 -5
- data/spec/spec_helper.rb +1 -0
- data/spec/support/command_runner.rb +15 -25
- data/spec/support/helpers.rb +21 -0
- data/spec/support/integration/helpers.rb +2 -0
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +3 -3
- data/spec/support/integration/test_programs/base.rb +36 -10
- data/spec/support/shared_examples/active_record.rb +3 -2
- 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 +16 -16
- 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 +51 -71
- 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 +1488 -846
- data/spec/unit/tiered_lines_elider_spec.rb +6356 -0
- data/spec/unit/tiered_lines_formatter_spec.rb +193 -0
- metadata +88 -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/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/hash_including.rb +0 -36
- 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
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Integration with ActiveSupport", type: :integration do
|
4
|
+
context "when using 'super_diff/rspec-rails'" do
|
5
|
+
include_context "integration with ActiveSupport"
|
6
|
+
|
7
|
+
def make_program(test, color_enabled:)
|
8
|
+
make_rspec_rails_test_program(test, color_enabled: color_enabled)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "when using 'super_diff/active_support'" do
|
13
|
+
include_context "integration with ActiveSupport"
|
14
|
+
|
15
|
+
def make_program(test, color_enabled:)
|
16
|
+
make_rspec_active_record_program(test, color_enabled: color_enabled)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -33,7 +33,8 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
33
33
|
plain_line %| "Marty",|
|
34
34
|
actual_line %|+ "Jennifer",|
|
35
35
|
actual_line %|+ "Doc",|
|
36
|
-
expected_line %|- "Einie"|
|
36
|
+
# expected_line %|- "Einie"| # TODO
|
37
|
+
expected_line %|- "Einie",|
|
37
38
|
plain_line %| ]|
|
38
39
|
},
|
39
40
|
)
|
@@ -132,7 +133,8 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
132
133
|
plain_line %| "Lorraine McFly",|
|
133
134
|
actual_line %|+ "Einie",|
|
134
135
|
expected_line %|- "Biff Tannen",|
|
135
|
-
expected_line %|- "George McFly"|
|
136
|
+
# expected_line %|- "George McFly"| # TODO
|
137
|
+
expected_line %|- "George McFly",|
|
136
138
|
plain_line %| ]|
|
137
139
|
},
|
138
140
|
)
|
@@ -243,7 +245,8 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
243
245
|
actual_line %|+ "Lorraine McFly",|
|
244
246
|
expected_line %|- "Biff Tannen",|
|
245
247
|
expected_line %|- /Georg McFly/,|
|
246
|
-
expected_line %|- /Lorrain McFly/|
|
248
|
+
# expected_line %|- /Lorrain McFly/| # TODO
|
249
|
+
expected_line %|- /Lorrain McFly/,|
|
247
250
|
plain_line %| ]|
|
248
251
|
},
|
249
252
|
)
|
@@ -330,7 +333,7 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
330
333
|
expectation: proc {
|
331
334
|
line do
|
332
335
|
plain %| Expected |
|
333
|
-
actual %|[{ foo: "bar" }, #<Double (anonymous)>, { blargh: "riddle" }]|
|
336
|
+
actual %|[{ foo: "bar" }, #<Double (anonymous) baz: "qux">, { blargh: "riddle" }]|
|
334
337
|
end
|
335
338
|
|
336
339
|
line do
|
@@ -347,13 +350,16 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
|
|
347
350
|
plain_line %| {|
|
348
351
|
plain_line %| foo: "bar"|
|
349
352
|
plain_line %| },|
|
350
|
-
plain_line %| #<Double (anonymous)
|
353
|
+
plain_line %| #<Double (anonymous) {|
|
354
|
+
plain_line %| baz: "qux"|
|
355
|
+
plain_line %| }>,|
|
351
356
|
actual_line %|+ {|
|
352
357
|
actual_line %|+ blargh: "riddle"|
|
353
358
|
actual_line %|+ },|
|
354
359
|
expected_line %|- #<a collection containing exactly (|
|
355
360
|
expected_line %|- "zing"|
|
356
|
-
expected_line %|- )>|
|
361
|
+
# expected_line %|- )>| # TODO
|
362
|
+
expected_line %|- )>,|
|
357
363
|
plain_line %| ]|
|
358
364
|
},
|
359
365
|
)
|
@@ -253,70 +253,6 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
256
|
-
context "when comparing two different Time and ActiveSupport::TimeWithZone instances", active_record: true do
|
257
|
-
it "produces the correct failure message when used in the positive" do
|
258
|
-
as_both_colored_and_uncolored do |color_enabled|
|
259
|
-
snippet = <<~RUBY
|
260
|
-
expected = Time.utc(2011, 12, 13, 14, 15, 16)
|
261
|
-
actual = Time.utc(2011, 12, 13, 15, 15, 16).in_time_zone("Europe/Stockholm")
|
262
|
-
expect(expected).to eq(actual)
|
263
|
-
RUBY
|
264
|
-
program = make_rspec_rails_test_program(
|
265
|
-
snippet,
|
266
|
-
color_enabled: color_enabled,
|
267
|
-
)
|
268
|
-
|
269
|
-
expected_output = build_expected_output(
|
270
|
-
color_enabled: color_enabled,
|
271
|
-
snippet: %|expect(expected).to eq(actual)|,
|
272
|
-
expectation: proc {
|
273
|
-
line do
|
274
|
-
plain %|Expected |
|
275
|
-
actual %|#<Time 2011-12-13 14:15:16 +00:00 (UTC)>|
|
276
|
-
end
|
277
|
-
|
278
|
-
line do
|
279
|
-
plain %| to eq |
|
280
|
-
expected %|#<ActiveSupport::TimeWithZone 2011-12-13 16:15:16 +01:00 (CET)>|
|
281
|
-
end
|
282
|
-
},
|
283
|
-
diff: proc {
|
284
|
-
plain_line %| #<ActiveSupport::TimeWithZone {|
|
285
|
-
plain_line %| year: 2011,|
|
286
|
-
plain_line %| month: 12,|
|
287
|
-
plain_line %| day: 13,|
|
288
|
-
expected_line %|- hour: 16,|
|
289
|
-
actual_line %|+ hour: 14,|
|
290
|
-
plain_line %| min: 15,|
|
291
|
-
plain_line %| sec: 16,|
|
292
|
-
plain_line %| subsec: 0,|
|
293
|
-
expected_line %|- zone: \"CET\",|
|
294
|
-
actual_line %|+ zone: \"UTC\",|
|
295
|
-
expected_line %|- utc_offset: 3600,|
|
296
|
-
actual_line %|+ utc_offset: 0,|
|
297
|
-
plain_line %| utc: #<Time {|
|
298
|
-
plain_line %| year: 2011,|
|
299
|
-
plain_line %| month: 12,|
|
300
|
-
plain_line %| day: 13,|
|
301
|
-
expected_line %|- hour: 15,|
|
302
|
-
actual_line %|+ hour: 14,|
|
303
|
-
plain_line %| min: 15,|
|
304
|
-
plain_line %| sec: 16,|
|
305
|
-
plain_line %| subsec: 0,|
|
306
|
-
plain_line %| zone: "UTC",|
|
307
|
-
plain_line %| utc_offset: 0|
|
308
|
-
plain_line %| }>|
|
309
|
-
plain_line %| }>|
|
310
|
-
},
|
311
|
-
)
|
312
|
-
|
313
|
-
expect(program).
|
314
|
-
to produce_output_when_run(expected_output).
|
315
|
-
in_color(color_enabled)
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
256
|
context "when comparing a single-line string with a multi-line string" do
|
321
257
|
it "produces the correct failure message" do
|
322
258
|
as_both_colored_and_uncolored do |color_enabled|
|
@@ -529,8 +465,8 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
529
465
|
plain_line %| data: {|
|
530
466
|
expected_line %|- "sticky" => true,|
|
531
467
|
actual_line %|+ "sticky" => false,|
|
532
|
-
actual_line %|+ role
|
533
|
-
plain_line %| person
|
468
|
+
actual_line %|+ :role => "deprecated",|
|
469
|
+
plain_line %| :person => #<SuperDiff::Test::Person {|
|
534
470
|
expected_line %|- name: "Marty",|
|
535
471
|
actual_line %|+ name: "Doc",|
|
536
472
|
plain_line %| age: 60|
|
@@ -844,17 +780,14 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
844
780
|
snippet: %|expect(actual).to eq(expected)|,
|
845
781
|
newline_before_expectation: true,
|
846
782
|
expectation: proc {
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
plain %| to eq |
|
856
|
-
expected %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
|
857
|
-
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>|
|
858
791
|
end
|
859
792
|
},
|
860
793
|
)
|
@@ -882,17 +815,14 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
882
815
|
snippet: %|expect(value).not_to eq(value)|,
|
883
816
|
newline_before_expectation: true,
|
884
817
|
expectation: proc {
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
plain %|not to eq |
|
894
|
-
expected %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
|
895
|
-
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>|
|
896
826
|
end
|
897
827
|
},
|
898
828
|
)
|
@@ -1019,4 +949,8 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
|
|
1019
949
|
end
|
1020
950
|
end
|
1021
951
|
end
|
952
|
+
|
953
|
+
it_behaves_like "a matcher that supports elided diffs" do
|
954
|
+
let(:matcher) { :eq }
|
955
|
+
end
|
1022
956
|
end
|
@@ -109,8 +109,8 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ
|
|
109
109
|
plain_line %| name: "a",|
|
110
110
|
# plain_line %| age: 9,| # FIXME
|
111
111
|
plain_line %| age: 9|
|
112
|
-
# expected_line %|- foo: "bar"
|
113
|
-
expected_line %|- foo: "bar"
|
112
|
+
# expected_line %|- foo: "bar"| # FIXME
|
113
|
+
expected_line %|- foo: "bar",|
|
114
114
|
plain_line %| }>|
|
115
115
|
},
|
116
116
|
)
|
@@ -170,8 +170,7 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ
|
|
170
170
|
expected_line %|- city: "Oakland",|
|
171
171
|
actual_line %|+ city: "Hill Valley",|
|
172
172
|
plain_line %| state: "CA",|
|
173
|
-
|
174
|
-
expected_line %|- zip: "91234"|
|
173
|
+
expected_line %|- zip: "91234",| # FIXME
|
175
174
|
actual_line %|+ zip: "90382"|
|
176
175
|
plain_line %| }>|
|
177
176
|
},
|
@@ -283,9 +282,9 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher", type: :integ
|
|
283
282
|
plain_line %| state: "CA",|
|
284
283
|
# plain_line %| zip: "90382",| # FIXME
|
285
284
|
plain_line %| zip: "90382"|
|
286
|
-
|
287
|
-
expected_line %|-
|
288
|
-
expected_line %|- baz: "qux"
|
285
|
+
expected_line %|- foo: "bar",|
|
286
|
+
# expected_line %|- baz: "qux"| # TODO
|
287
|
+
expected_line %|- baz: "qux",|
|
289
288
|
plain_line %| }>|
|
290
289
|
},
|
291
290
|
)
|
@@ -33,7 +33,8 @@ RSpec.describe "Integration with RSpec's #match_array matcher", type: :integrati
|
|
33
33
|
plain_line %| "Marty",|
|
34
34
|
actual_line %|+ "Jennifer",|
|
35
35
|
actual_line %|+ "Doc",|
|
36
|
-
expected_line %|- "Einie"|
|
36
|
+
# expected_line %|- "Einie"| # TODO
|
37
|
+
expected_line %|- "Einie",|
|
37
38
|
plain_line %| ]|
|
38
39
|
},
|
39
40
|
)
|
@@ -132,7 +133,8 @@ RSpec.describe "Integration with RSpec's #match_array matcher", type: :integrati
|
|
132
133
|
plain_line %| "Lorraine McFly",|
|
133
134
|
actual_line %|+ "Einie",|
|
134
135
|
expected_line %|- "Biff Tannen",|
|
135
|
-
expected_line %|- "George McFly"|
|
136
|
+
# expected_line %|- "George McFly"| # TODO
|
137
|
+
expected_line %|- "George McFly",|
|
136
138
|
plain_line %| ]|
|
137
139
|
},
|
138
140
|
)
|
@@ -243,7 +245,8 @@ RSpec.describe "Integration with RSpec's #match_array matcher", type: :integrati
|
|
243
245
|
actual_line %|+ "Lorraine McFly",|
|
244
246
|
expected_line %|- "Biff Tannen",|
|
245
247
|
expected_line %|- /Georg McFly/,|
|
246
|
-
expected_line %|- /Lorrain McFly/|
|
248
|
+
# expected_line %|- /Lorrain McFly/| # TODO
|
249
|
+
expected_line %|- /Lorrain McFly/,|
|
247
250
|
plain_line %| ]|
|
248
251
|
},
|
249
252
|
)
|
@@ -333,7 +336,7 @@ RSpec.describe "Integration with RSpec's #match_array matcher", type: :integrati
|
|
333
336
|
line do
|
334
337
|
plain %| Expected |
|
335
338
|
# rubocop:disable Metrics/LineLength
|
336
|
-
actual %|[{ foo: "bar" }, #<Double (anonymous)>, { blargh: "riddle" }]|
|
339
|
+
actual %|[{ foo: "bar" }, #<Double (anonymous) baz: "qux">, { blargh: "riddle" }]|
|
337
340
|
# rubocop:enable Metrics/LineLength
|
338
341
|
end
|
339
342
|
|
@@ -351,13 +354,16 @@ RSpec.describe "Integration with RSpec's #match_array matcher", type: :integrati
|
|
351
354
|
plain_line %| {|
|
352
355
|
plain_line %| foo: "bar"|
|
353
356
|
plain_line %| },|
|
354
|
-
plain_line %| #<Double (anonymous)
|
357
|
+
plain_line %| #<Double (anonymous) {|
|
358
|
+
plain_line %| baz: "qux"|
|
359
|
+
plain_line %| }>,|
|
355
360
|
actual_line %|+ {|
|
356
361
|
actual_line %|+ blargh: "riddle"|
|
357
362
|
actual_line %|+ },|
|
358
363
|
expected_line %|- #<a collection containing exactly (|
|
359
364
|
expected_line %|- "zing"|
|
360
|
-
expected_line %|- )>|
|
365
|
+
# expected_line %|- )>| # TODO
|
366
|
+
expected_line %|- )>,|
|
361
367
|
plain_line %| ]|
|
362
368
|
},
|
363
369
|
)
|
@@ -400,7 +406,8 @@ RSpec.describe "Integration with RSpec's #match_array matcher", type: :integrati
|
|
400
406
|
actual_line %|+ "Marty",|
|
401
407
|
actual_line %|+ "Jennifer",|
|
402
408
|
actual_line %|+ "Doc",|
|
403
|
-
expected_line %|- "Einie"|
|
409
|
+
# expected_line %|- "Einie"| # TODO
|
410
|
+
expected_line %|- "Einie",|
|
404
411
|
plain_line %| ]|
|
405
412
|
},
|
406
413
|
)
|
@@ -855,7 +855,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
855
855
|
# actual_line %|+ zip: "90382",| # FIXME
|
856
856
|
expected_line %|- zip: "91234"|
|
857
857
|
actual_line %|+ zip: "90382"|
|
858
|
-
expected_line %|- something_else: "blah"|
|
858
|
+
# expected_line %|- something_else: "blah"| # TODO
|
859
|
+
expected_line %|- something_else: "blah",|
|
859
860
|
plain_line %| }>|
|
860
861
|
},
|
861
862
|
)
|
@@ -971,7 +972,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
971
972
|
# expected_line %|- zip: "91234",| # FIXME
|
972
973
|
expected_line %|- zip: "91234"|
|
973
974
|
actual_line %|+ zip: "90382"|
|
974
|
-
expected_line %|- something_else: "blah"|
|
975
|
+
# expected_line %|- something_else: "blah"| # TODO
|
976
|
+
expected_line %|- something_else: "blah",|
|
975
977
|
plain_line %| }>|
|
976
978
|
plain_line %| }|
|
977
979
|
},
|
@@ -1065,7 +1067,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
1065
1067
|
diff: proc {
|
1066
1068
|
plain_line %| [|
|
1067
1069
|
actual_line %|+ "b",|
|
1068
|
-
expected_line %|- "a"|
|
1070
|
+
# expected_line %|- "a"| # TODO
|
1071
|
+
expected_line %|- "a",|
|
1069
1072
|
plain_line %| ]|
|
1070
1073
|
},
|
1071
1074
|
)
|
@@ -1143,7 +1146,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
1143
1146
|
actual_line %|+ "eggs",|
|
1144
1147
|
actual_line %|+ "cheese",|
|
1145
1148
|
actual_line %|+ "English muffins",|
|
1146
|
-
expected_line %|- "bread"|
|
1149
|
+
# expected_line %|- "bread"| # TODO
|
1150
|
+
expected_line %|- "bread",|
|
1147
1151
|
plain_line %| ]|
|
1148
1152
|
},
|
1149
1153
|
)
|
@@ -1232,7 +1236,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
1232
1236
|
plain_line %| "milk",|
|
1233
1237
|
actual_line %|+ "toast",|
|
1234
1238
|
actual_line %|+ "eggs",|
|
1235
|
-
expected_line %|- "bread"|
|
1239
|
+
# expected_line %|- "bread"| # TODO
|
1240
|
+
expected_line %|- "bread",|
|
1236
1241
|
plain_line %| ]|
|
1237
1242
|
plain_line %| }|
|
1238
1243
|
},
|
data/spec/spec_helper.rb
CHANGED
@@ -43,6 +43,7 @@ Dir.glob(File.expand_path("support/**/*.rb", __dir__)).
|
|
43
43
|
end
|
44
44
|
|
45
45
|
RSpec.configure do |config|
|
46
|
+
config.include(SuperDiff::UnitTests, type: :unit)
|
46
47
|
config.include(SuperDiff::IntegrationTests, type: :integration)
|
47
48
|
|
48
49
|
config.expect_with :rspec do |expectations|
|
@@ -5,24 +5,6 @@ require "shellwords"
|
|
5
5
|
require "timeout"
|
6
6
|
|
7
7
|
class CommandRunner
|
8
|
-
module OutputHelpers
|
9
|
-
def self.bookended(text)
|
10
|
-
divider("START") + text + "\n" + divider("END")
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.divider(title = "")
|
14
|
-
total_length = 72
|
15
|
-
start_length = 3
|
16
|
-
|
17
|
-
string = ""
|
18
|
-
string << ("-" * start_length)
|
19
|
-
string << title
|
20
|
-
string << "-" * (total_length - start_length - title.length)
|
21
|
-
string << "\n"
|
22
|
-
string
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
8
|
class CommandFailedError < StandardError
|
27
9
|
def self.create(command:, exit_status:, output:, message: nil)
|
28
10
|
allocate.tap do |error|
|
@@ -49,7 +31,11 @@ Command #{command.inspect} failed, exiting with status #{exit_status}.
|
|
49
31
|
if output
|
50
32
|
message << <<-MESSAGE
|
51
33
|
Output:
|
52
|
-
#{
|
34
|
+
#{
|
35
|
+
SuperDiff::Test::OutputHelpers.divider("START") +
|
36
|
+
output +
|
37
|
+
SuperDiff::Test::OutputHelpers.divider("END")
|
38
|
+
}
|
53
39
|
MESSAGE
|
54
40
|
end
|
55
41
|
|
@@ -83,7 +69,11 @@ Command #{formatted_command.inspect} timed out after #{timeout} seconds.
|
|
83
69
|
if output
|
84
70
|
message << <<-MESSAGE
|
85
71
|
Output:
|
86
|
-
#{
|
72
|
+
#{
|
73
|
+
SuperDiff::Test::OutputHelpers.divider("START") +
|
74
|
+
output +
|
75
|
+
SuperDiff::Test::OutputHelpers.divider("END")
|
76
|
+
}
|
87
77
|
MESSAGE
|
88
78
|
end
|
89
79
|
|
@@ -120,9 +110,9 @@ Output:
|
|
120
110
|
@env = extract_env_from(@options)
|
121
111
|
|
122
112
|
@process = ChildProcess.build(*command)
|
123
|
-
|
124
|
-
|
125
|
-
|
113
|
+
@env.each do |key, value|
|
114
|
+
@process.environment[key] = value
|
115
|
+
end
|
126
116
|
@process.io.stdout = @process.io.stderr = @writer
|
127
117
|
|
128
118
|
@wrapper = -> (block) { block.call }
|
@@ -250,9 +240,9 @@ Output:
|
|
250
240
|
|
251
241
|
debug do
|
252
242
|
"\n" +
|
253
|
-
OutputHelpers.divider("START") +
|
243
|
+
SuperDiff::Test::OutputHelpers.divider("START") +
|
254
244
|
output +
|
255
|
-
OutputHelpers.divider("END")
|
245
|
+
SuperDiff::Test::OutputHelpers.divider("END")
|
256
246
|
end
|
257
247
|
end
|
258
248
|
|