super_diff 0.13.0 → 0.14.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 +1 -1
- data/lib/super_diff/active_record/differs/active_record_relation.rb +2 -0
- data/lib/super_diff/active_record/differs.rb +3 -1
- data/lib/super_diff/active_record/inspection_tree_builders/active_record_model.rb +7 -5
- data/lib/super_diff/active_record/inspection_tree_builders/active_record_relation.rb +12 -10
- data/lib/super_diff/active_record/inspection_tree_builders.rb +4 -2
- data/lib/super_diff/active_record/monkey_patches.rb +4 -2
- data/lib/super_diff/active_record/object_inspection.rb +6 -4
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +3 -1
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +3 -1
- data/lib/super_diff/active_record/operation_tree_builders.rb +4 -2
- data/lib/super_diff/active_record/operation_tree_flatteners/active_record_relation.rb +4 -2
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +3 -1
- data/lib/super_diff/active_record/operation_trees/active_record_relation.rb +2 -0
- data/lib/super_diff/active_record/operation_trees.rb +3 -1
- data/lib/super_diff/active_record.rb +10 -8
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +2 -0
- data/lib/super_diff/active_support/differs.rb +3 -1
- data/lib/super_diff/active_support/inspection_tree_builders/hash_with_indifferent_access.rb +16 -14
- data/lib/super_diff/active_support/inspection_tree_builders/ordered_options.rb +16 -14
- data/lib/super_diff/active_support/inspection_tree_builders.rb +4 -2
- data/lib/super_diff/active_support/object_inspection.rb +6 -4
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +6 -4
- data/lib/super_diff/active_support/operation_tree_builders.rb +3 -1
- data/lib/super_diff/active_support/operation_tree_flatteners/hash_with_indifferent_access.rb +4 -2
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +3 -1
- data/lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb +2 -0
- data/lib/super_diff/active_support/operation_trees.rb +3 -1
- data/lib/super_diff/active_support.rb +8 -6
- data/lib/super_diff/basic/diff_formatters/collection.rb +18 -18
- data/lib/super_diff/basic/diff_formatters/multiline_string.rb +2 -0
- data/lib/super_diff/basic/diff_formatters.rb +4 -2
- data/lib/super_diff/basic/differs/array.rb +2 -0
- data/lib/super_diff/basic/differs/custom_object.rb +3 -1
- data/lib/super_diff/basic/differs/date_like.rb +2 -0
- data/lib/super_diff/basic/differs/default_object.rb +3 -1
- data/lib/super_diff/basic/differs/hash.rb +2 -0
- data/lib/super_diff/basic/differs/multiline_string.rb +2 -0
- data/lib/super_diff/basic/differs/time_like.rb +2 -0
- data/lib/super_diff/basic/differs.rb +11 -9
- data/lib/super_diff/basic/inspection_tree_builders/array.rb +5 -3
- data/lib/super_diff/basic/inspection_tree_builders/custom_object.rb +5 -3
- data/lib/super_diff/basic/inspection_tree_builders/data_object.rb +6 -4
- data/lib/super_diff/basic/inspection_tree_builders/date_like.rb +7 -5
- data/lib/super_diff/basic/inspection_tree_builders/default_object.rb +7 -5
- data/lib/super_diff/basic/inspection_tree_builders/hash.rb +7 -5
- data/lib/super_diff/basic/inspection_tree_builders/primitive.rb +2 -0
- data/lib/super_diff/basic/inspection_tree_builders/range_object.rb +19 -0
- data/lib/super_diff/basic/inspection_tree_builders/time_like.rb +8 -8
- data/lib/super_diff/basic/inspection_tree_builders.rb +15 -9
- data/lib/super_diff/basic/operation_tree_builders/array.rb +6 -4
- data/lib/super_diff/basic/operation_tree_builders/custom_object.rb +3 -1
- data/lib/super_diff/basic/operation_tree_builders/data_object.rb +4 -2
- data/lib/super_diff/basic/operation_tree_builders/date_like.rb +2 -0
- data/lib/super_diff/basic/operation_tree_builders/default_object.rb +32 -31
- data/lib/super_diff/basic/operation_tree_builders/hash.rb +49 -46
- data/lib/super_diff/basic/operation_tree_builders/multiline_string.rb +5 -3
- data/lib/super_diff/basic/operation_tree_builders/time_like.rb +5 -3
- data/lib/super_diff/basic/operation_tree_builders.rb +12 -10
- data/lib/super_diff/basic/operation_tree_flatteners/array.rb +4 -2
- data/lib/super_diff/basic/operation_tree_flatteners/collection.rb +11 -11
- data/lib/super_diff/basic/operation_tree_flatteners/custom_object.rb +5 -3
- data/lib/super_diff/basic/operation_tree_flatteners/default_object.rb +6 -5
- data/lib/super_diff/basic/operation_tree_flatteners/hash.rb +5 -3
- data/lib/super_diff/basic/operation_tree_flatteners/multiline_string.rb +3 -1
- data/lib/super_diff/basic/operation_tree_flatteners.rb +8 -6
- data/lib/super_diff/basic/operation_trees/array.rb +2 -0
- data/lib/super_diff/basic/operation_trees/custom_object.rb +2 -0
- data/lib/super_diff/basic/operation_trees/default_object.rb +6 -4
- data/lib/super_diff/basic/operation_trees/hash.rb +2 -0
- data/lib/super_diff/basic/operation_trees/multiline_string.rb +3 -1
- data/lib/super_diff/basic/operation_trees.rb +9 -7
- data/lib/super_diff/basic.rb +9 -6
- data/lib/super_diff/core/abstract_differ.rb +2 -0
- data/lib/super_diff/core/abstract_inspection_tree_builder.rb +2 -0
- data/lib/super_diff/core/abstract_operation_tree.rb +4 -2
- data/lib/super_diff/core/abstract_operation_tree_builder.rb +15 -18
- data/lib/super_diff/core/abstract_operation_tree_flattener.rb +5 -3
- data/lib/super_diff/core/binary_operation.rb +3 -1
- data/lib/super_diff/core/colorized_document_extensions.rb +2 -0
- data/lib/super_diff/core/configuration.rb +14 -38
- data/lib/super_diff/core/differ_dispatcher.rb +4 -2
- data/lib/super_diff/core/gem_version.rb +2 -0
- data/lib/super_diff/core/helpers.rb +13 -11
- data/lib/super_diff/core/implementation_checks.rb +6 -2
- data/lib/super_diff/core/inspection_tree.rb +38 -38
- data/lib/super_diff/core/inspection_tree_builder_dispatcher.rb +5 -5
- data/lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/as_prefix_when_rendering_to_lines.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/as_prelude_when_rendering_to_lines.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/as_single_line.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/base.rb +9 -9
- data/lib/super_diff/core/inspection_tree_nodes/inspection.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/nesting.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/only_when.rb +5 -1
- data/lib/super_diff/core/inspection_tree_nodes/text.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes/when_empty.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/when_non_empty.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/when_rendering_to_lines.rb +3 -1
- data/lib/super_diff/core/inspection_tree_nodes/when_rendering_to_string.rb +2 -0
- data/lib/super_diff/core/inspection_tree_nodes.rb +16 -14
- data/lib/super_diff/core/line.rb +9 -7
- data/lib/super_diff/core/no_differ_available_error.rb +7 -5
- data/lib/super_diff/core/no_inspection_tree_builder_available_error.rb +5 -3
- data/lib/super_diff/core/no_operation_tree_available_error.rb +4 -2
- data/lib/super_diff/core/no_operation_tree_builder_available_error.rb +7 -5
- data/lib/super_diff/core/operation_tree_builder_dispatcher.rb +3 -3
- data/lib/super_diff/core/operation_tree_finder.rb +8 -8
- data/lib/super_diff/core/prefix_for_next_inspection_tree_node.rb +2 -0
- data/lib/super_diff/core/prelude_for_next_inspection_tree_node.rb +2 -0
- data/lib/super_diff/core/recursion_guard.rb +6 -4
- data/lib/super_diff/core/tiered_lines.rb +2 -0
- data/lib/super_diff/core/tiered_lines_elider.rb +53 -54
- data/lib/super_diff/core/tiered_lines_formatter.rb +6 -4
- data/lib/super_diff/core/unary_operation.rb +2 -0
- data/lib/super_diff/core.rb +31 -29
- data/lib/super_diff/csi/bold_sequence.rb +2 -0
- data/lib/super_diff/csi/color.rb +4 -4
- data/lib/super_diff/csi/color_sequence_block.rb +3 -1
- data/lib/super_diff/csi/colorized_document.rb +7 -9
- data/lib/super_diff/csi/document.rb +15 -18
- data/lib/super_diff/csi/eight_bit_color.rb +32 -37
- data/lib/super_diff/csi/four_bit_color.rb +12 -9
- data/lib/super_diff/csi/reset_sequence.rb +2 -0
- data/lib/super_diff/csi/twenty_four_bit_color.rb +22 -21
- data/lib/super_diff/csi/uncolorized_document.rb +2 -0
- data/lib/super_diff/csi.rb +12 -10
- data/lib/super_diff/differs.rb +6 -4
- data/lib/super_diff/equality_matchers/array.rb +18 -16
- data/lib/super_diff/equality_matchers/base.rb +6 -4
- data/lib/super_diff/equality_matchers/default.rb +5 -3
- data/lib/super_diff/equality_matchers/defaults.rb +2 -0
- data/lib/super_diff/equality_matchers/hash.rb +18 -16
- data/lib/super_diff/equality_matchers/main.rb +3 -1
- data/lib/super_diff/equality_matchers/multiline_string.rb +18 -16
- data/lib/super_diff/equality_matchers/primitive.rb +15 -13
- data/lib/super_diff/equality_matchers/singleline_string.rb +16 -14
- data/lib/super_diff/equality_matchers.rb +11 -9
- data/lib/super_diff/errors.rb +4 -2
- data/lib/super_diff/object_inspection.rb +17 -15
- data/lib/super_diff/operation_tree_builders.rb +6 -4
- data/lib/super_diff/operation_tree_flatteners.rb +6 -4
- data/lib/super_diff/operation_trees.rb +6 -4
- data/lib/super_diff/operations.rb +4 -2
- data/lib/super_diff/rails.rb +4 -2
- data/lib/super_diff/rspec/augmented_matcher.rb +3 -1
- data/lib/super_diff/rspec/differ.rb +16 -7
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +2 -0
- data/lib/super_diff/rspec/differs/collection_including.rb +2 -0
- data/lib/super_diff/rspec/differs/hash_including.rb +2 -0
- data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -0
- data/lib/super_diff/rspec/differs.rb +6 -4
- data/lib/super_diff/rspec/inspection_tree_builders/collection_containing_exactly.rb +12 -10
- data/lib/super_diff/rspec/inspection_tree_builders/collection_including.rb +10 -8
- data/lib/super_diff/rspec/inspection_tree_builders/double.rb +20 -18
- data/lib/super_diff/rspec/inspection_tree_builders/generic_describable_matcher.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/hash_including.rb +10 -8
- data/lib/super_diff/rspec/inspection_tree_builders/instance_of.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/kind_of.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/object_having_attributes.rb +12 -10
- data/lib/super_diff/rspec/inspection_tree_builders/primitive.rb +2 -0
- data/lib/super_diff/rspec/inspection_tree_builders/value_within.rb +6 -4
- data/lib/super_diff/rspec/inspection_tree_builders.rb +12 -10
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +12 -12
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +19 -17
- data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +3 -1
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +7 -5
- data/lib/super_diff/rspec/matcher_text_builders/match.rb +6 -4
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +5 -3
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +20 -18
- data/lib/super_diff/rspec/matcher_text_builders.rb +9 -7
- data/lib/super_diff/rspec/matcher_text_template.rb +34 -39
- data/lib/super_diff/rspec/object_inspection.rb +7 -5
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +4 -4
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +2 -0
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +2 -0
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +2 -0
- data/lib/super_diff/rspec/operation_tree_builders.rb +6 -4
- data/lib/super_diff/rspec-rails.rb +4 -2
- data/lib/super_diff/rspec.rb +15 -13
- data/lib/super_diff/version.rb +3 -1
- data/lib/super_diff.rb +24 -26
- data/super_diff.gemspec +20 -19
- metadata +6 -185
- data/spec/examples.txt +0 -450
- data/spec/integration/rails/active_record_spec.rb +0 -21
- data/spec/integration/rails/active_support_spec.rb +0 -19
- data/spec/integration/rails/engines_spec.rb +0 -25
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +0 -21
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +0 -58
- data/spec/integration/rspec/be_matcher_spec.rb +0 -605
- data/spec/integration/rspec/be_nil_matcher_spec.rb +0 -57
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +0 -615
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +0 -62
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +0 -377
- data/spec/integration/rspec/eq_matcher_spec.rb +0 -1066
- data/spec/integration/rspec/generic_describable_matchers_spec.rb +0 -177
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +0 -443
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +0 -478
- data/spec/integration/rspec/include_matcher_spec.rb +0 -452
- data/spec/integration/rspec/magic_metadata_spec.rb +0 -51
- data/spec/integration/rspec/match_array_matcher_spec.rb +0 -424
- data/spec/integration/rspec/match_matcher_spec.rb +0 -1359
- data/spec/integration/rspec/raise_error_matcher_spec.rb +0 -1488
- data/spec/integration/rspec/respond_to_matcher_spec.rb +0 -999
- data/spec/integration/rspec/third_party_matcher_spec.rb +0 -245
- data/spec/integration/rspec/unhandled_errors_spec.rb +0 -150
- data/spec/spec_helper.rb +0 -91
- data/spec/support/colorizer.rb +0 -9
- data/spec/support/command_runner.rb +0 -253
- data/spec/support/helpers.rb +0 -21
- data/spec/support/integration/helpers.rb +0 -124
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +0 -104
- data/spec/support/integration/matchers.rb +0 -177
- data/spec/support/integration/test_programs/base.rb +0 -143
- data/spec/support/integration/test_programs/plain.rb +0 -19
- data/spec/support/integration/test_programs/rspec_active_record.rb +0 -20
- data/spec/support/integration/test_programs/rspec_active_support.rb +0 -20
- data/spec/support/integration/test_programs/rspec_rails.rb +0 -20
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +0 -20
- data/spec/support/models/a.rb +0 -11
- data/spec/support/models/active_record/person.rb +0 -28
- data/spec/support/models/active_record/query.rb +0 -15
- data/spec/support/models/active_record/shipping_address.rb +0 -24
- data/spec/support/models/customer.rb +0 -22
- data/spec/support/models/empty_class.rb +0 -6
- data/spec/support/models/item.rb +0 -10
- data/spec/support/models/order.rb +0 -9
- data/spec/support/models/person.rb +0 -20
- data/spec/support/models/player.rb +0 -30
- data/spec/support/models/point.rb +0 -7
- data/spec/support/models/shipping_address.rb +0 -25
- data/spec/support/shared_examples/active_record.rb +0 -428
- data/spec/support/shared_examples/active_support.rb +0 -188
- data/spec/support/shared_examples/elided_diffs.rb +0 -938
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +0 -749
- data/spec/support/shared_examples/key.rb +0 -123
- data/spec/support/unit/helpers.rb +0 -24
- data/spec/support/unit/matchers/be_deprecated_in_favor_of.rb +0 -39
- data/spec/support/unit/matchers/match_output.rb +0 -40
- data/spec/unit/active_record/object_inspection_spec.rb +0 -289
- data/spec/unit/active_support/object_inspection_spec.rb +0 -170
- data/spec/unit/basic/inspection_tree_builders/data_object_spec.rb +0 -146
- data/spec/unit/basic/operation_tree_builders/data_object_spec.rb +0 -82
- data/spec/unit/basic/operation_tree_flatteners/array_spec.rb +0 -637
- data/spec/unit/basic/operation_tree_flatteners/custom_object_spec.rb +0 -685
- data/spec/unit/basic/operation_tree_flatteners/default_object_spec.rb +0 -685
- data/spec/unit/basic/operation_tree_flatteners/hash_spec.rb +0 -671
- data/spec/unit/basic/operation_tree_flatteners/multiline_string_spec.rb +0 -131
- data/spec/unit/core/configuration_no_rspec_spec.rb +0 -58
- data/spec/unit/core/configuration_spec.rb +0 -176
- data/spec/unit/core/helpers_spec.rb +0 -68
- data/spec/unit/core/tiered_lines_elider_spec.rb +0 -6328
- data/spec/unit/core/tiered_lines_formatter_spec.rb +0 -131
- data/spec/unit/deprecations_spec.rb +0 -176
- data/spec/unit/equality_matchers/main_spec.rb +0 -1842
- data/spec/unit/rspec/matchers/be_compared_to_spec.rb +0 -23
- data/spec/unit/rspec/matchers/be_falsey_spec.rb +0 -9
- data/spec/unit/rspec/matchers/be_nil_spec.rb +0 -9
- data/spec/unit/rspec/matchers/be_predicate_spec.rb +0 -31
- data/spec/unit/rspec/matchers/be_spec.rb +0 -17
- data/spec/unit/rspec/matchers/be_truthy_spec.rb +0 -9
- data/spec/unit/rspec/matchers/contain_exactly_spec.rb +0 -11
- data/spec/unit/rspec/matchers/eq_spec.rb +0 -9
- data/spec/unit/rspec/matchers/have_attributes_spec.rb +0 -11
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +0 -21
- data/spec/unit/rspec/matchers/include_spec.rb +0 -21
- data/spec/unit/rspec/matchers/match_array_spec.rb +0 -11
- data/spec/unit/rspec/matchers/match_spec.rb +0 -9
- data/spec/unit/rspec/matchers/raise_error_spec.rb +0 -77
- data/spec/unit/rspec/matchers/respond_to_spec.rb +0 -85
- data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +0 -91
- data/spec/unit/rspec/object_inspection_spec.rb +0 -471
- data/spec/unit/super_diff_spec.rb +0 -2115
@@ -1,428 +0,0 @@
|
|
1
|
-
shared_examples_for "integration with ActiveRecord" do
|
2
|
-
describe "and RSpec's #eq matcher" do
|
3
|
-
context "when comparing two instances of the same ActiveRecord model" do
|
4
|
-
it "produces the correct output" do
|
5
|
-
as_both_colored_and_uncolored do |color_enabled|
|
6
|
-
snippet = <<~TEST.strip
|
7
|
-
actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
8
|
-
line_1: "456 Ponderosa Ct.",
|
9
|
-
city: "Oakland",
|
10
|
-
state: "CA",
|
11
|
-
zip: "91234",
|
12
|
-
)
|
13
|
-
expected = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
14
|
-
line_1: "123 Main St.",
|
15
|
-
city: "Hill Valley",
|
16
|
-
state: "CA",
|
17
|
-
zip: "90382",
|
18
|
-
)
|
19
|
-
expect(actual).to eq(expected)
|
20
|
-
TEST
|
21
|
-
program = make_program(snippet, color_enabled: color_enabled)
|
22
|
-
|
23
|
-
expected_output =
|
24
|
-
build_expected_output(
|
25
|
-
color_enabled: color_enabled,
|
26
|
-
snippet: "expect(actual).to eq(expected)",
|
27
|
-
expectation:
|
28
|
-
proc do
|
29
|
-
line do
|
30
|
-
plain "Expected "
|
31
|
-
actual %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234">|
|
32
|
-
end
|
33
|
-
|
34
|
-
line do
|
35
|
-
plain " to eq "
|
36
|
-
expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
|
37
|
-
end
|
38
|
-
end,
|
39
|
-
diff:
|
40
|
-
proc do
|
41
|
-
plain_line " #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {"
|
42
|
-
plain_line " id: nil,"
|
43
|
-
expected_line %|- city: "Hill Valley",|
|
44
|
-
actual_line %|+ city: "Oakland",|
|
45
|
-
expected_line %|- line_1: "123 Main St.",|
|
46
|
-
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
47
|
-
plain_line %| line_2: "",|
|
48
|
-
plain_line %| state: "CA",|
|
49
|
-
expected_line %|- zip: "90382"|
|
50
|
-
actual_line %|+ zip: "91234"|
|
51
|
-
plain_line " }>"
|
52
|
-
end
|
53
|
-
)
|
54
|
-
|
55
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
56
|
-
color_enabled
|
57
|
-
)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context "when comparing instances of two different ActiveRecord models" do
|
63
|
-
it "produces the correct output" do
|
64
|
-
as_both_colored_and_uncolored do |color_enabled|
|
65
|
-
snippet = <<~TEST.strip
|
66
|
-
actual = SuperDiff::Test::Models::ActiveRecord::Person.new(
|
67
|
-
name: "Elliot",
|
68
|
-
age: 31,
|
69
|
-
)
|
70
|
-
expected = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
71
|
-
line_1: "123 Main St.",
|
72
|
-
city: "Hill Valley",
|
73
|
-
state: "CA",
|
74
|
-
zip: "90382",
|
75
|
-
)
|
76
|
-
expect(actual).to eq(expected)
|
77
|
-
TEST
|
78
|
-
program = make_program(snippet, color_enabled: color_enabled)
|
79
|
-
|
80
|
-
expected_output =
|
81
|
-
build_expected_output(
|
82
|
-
color_enabled: color_enabled,
|
83
|
-
snippet: "expect(actual).to eq(expected)",
|
84
|
-
newline_before_expectation: true,
|
85
|
-
expectation:
|
86
|
-
proc do
|
87
|
-
line do
|
88
|
-
plain "Expected "
|
89
|
-
actual %|#<SuperDiff::Test::Models::ActiveRecord::Person person_id: nil, age: 31, name: "Elliot">|
|
90
|
-
end
|
91
|
-
|
92
|
-
line do
|
93
|
-
plain " to eq "
|
94
|
-
expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
|
95
|
-
end
|
96
|
-
end
|
97
|
-
)
|
98
|
-
|
99
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
100
|
-
color_enabled
|
101
|
-
)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context "when comparing an ActiveRecord object with nothing" do
|
107
|
-
it "produces the correct output" do
|
108
|
-
as_both_colored_and_uncolored do |color_enabled|
|
109
|
-
snippet = <<~TEST.strip
|
110
|
-
actual = nil
|
111
|
-
expected = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
112
|
-
line_1: "123 Main St.",
|
113
|
-
city: "Hill Valley",
|
114
|
-
state: "CA",
|
115
|
-
zip: "90382"
|
116
|
-
)
|
117
|
-
expect(actual).to eq(expected)
|
118
|
-
TEST
|
119
|
-
program = make_program(snippet, color_enabled: color_enabled)
|
120
|
-
|
121
|
-
expected_output =
|
122
|
-
build_expected_output(
|
123
|
-
color_enabled: color_enabled,
|
124
|
-
snippet: "expect(actual).to eq(expected)",
|
125
|
-
newline_before_expectation: true,
|
126
|
-
expectation:
|
127
|
-
proc do
|
128
|
-
line do
|
129
|
-
plain "Expected "
|
130
|
-
actual "nil"
|
131
|
-
end
|
132
|
-
|
133
|
-
line do
|
134
|
-
plain " to eq "
|
135
|
-
expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
|
136
|
-
end
|
137
|
-
end
|
138
|
-
)
|
139
|
-
|
140
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
141
|
-
color_enabled
|
142
|
-
)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
context "when comparing two data structures that contain two instances of the same ActiveRecord model" do
|
148
|
-
it "produces the correct output" do
|
149
|
-
as_both_colored_and_uncolored do |color_enabled|
|
150
|
-
snippet = <<~TEST.strip
|
151
|
-
actual = {
|
152
|
-
name: "Marty McFly",
|
153
|
-
shipping_address: SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
154
|
-
line_1: "456 Ponderosa Ct.",
|
155
|
-
city: "Oakland",
|
156
|
-
state: "CA",
|
157
|
-
zip: "91234",
|
158
|
-
)
|
159
|
-
}
|
160
|
-
expected = {
|
161
|
-
name: "Marty McFly",
|
162
|
-
shipping_address: SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
163
|
-
line_1: "123 Main St.",
|
164
|
-
city: "Hill Valley",
|
165
|
-
state: "CA",
|
166
|
-
zip: "90382",
|
167
|
-
)
|
168
|
-
}
|
169
|
-
expect(actual).to eq(expected)
|
170
|
-
TEST
|
171
|
-
program = make_program(snippet, color_enabled: color_enabled)
|
172
|
-
|
173
|
-
expected_output =
|
174
|
-
build_expected_output(
|
175
|
-
color_enabled: color_enabled,
|
176
|
-
snippet: "expect(actual).to eq(expected)",
|
177
|
-
expectation:
|
178
|
-
proc do
|
179
|
-
line do
|
180
|
-
plain "Expected "
|
181
|
-
actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234"> }|
|
182
|
-
end
|
183
|
-
|
184
|
-
line do
|
185
|
-
plain " to eq "
|
186
|
-
expected %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382"> }|
|
187
|
-
end
|
188
|
-
end,
|
189
|
-
diff:
|
190
|
-
proc do
|
191
|
-
plain_line " {"
|
192
|
-
plain_line %| name: "Marty McFly",|
|
193
|
-
plain_line " shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {"
|
194
|
-
plain_line " id: nil,"
|
195
|
-
expected_line %|- city: "Hill Valley",|
|
196
|
-
actual_line %|+ city: "Oakland",|
|
197
|
-
expected_line %|- line_1: "123 Main St.",|
|
198
|
-
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
199
|
-
plain_line %| line_2: "",|
|
200
|
-
plain_line %| state: "CA",|
|
201
|
-
expected_line %|- zip: "90382"|
|
202
|
-
actual_line %|+ zip: "91234"|
|
203
|
-
plain_line " }>"
|
204
|
-
plain_line " }"
|
205
|
-
end
|
206
|
-
)
|
207
|
-
|
208
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
209
|
-
color_enabled
|
210
|
-
)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
context "when comparing two data structures that contain instances of two different ActiveRecord models" do
|
216
|
-
it "produces the correct output" do
|
217
|
-
as_both_colored_and_uncolored do |color_enabled|
|
218
|
-
snippet = <<~TEST.strip
|
219
|
-
actual = {
|
220
|
-
name: "Marty McFly",
|
221
|
-
shipping_address: SuperDiff::Test::Models::ActiveRecord::Person.new(
|
222
|
-
name: "Elliot",
|
223
|
-
age: 31,
|
224
|
-
)
|
225
|
-
}
|
226
|
-
expected = {
|
227
|
-
name: "Marty McFly",
|
228
|
-
shipping_address: SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
229
|
-
line_1: "123 Main St.",
|
230
|
-
city: "Hill Valley",
|
231
|
-
state: "CA",
|
232
|
-
zip: "90382",
|
233
|
-
)
|
234
|
-
}
|
235
|
-
expect(actual).to eq(expected)
|
236
|
-
TEST
|
237
|
-
program = make_program(snippet, color_enabled: color_enabled)
|
238
|
-
|
239
|
-
expected_output =
|
240
|
-
build_expected_output(
|
241
|
-
color_enabled: color_enabled,
|
242
|
-
snippet: "expect(actual).to eq(expected)",
|
243
|
-
expectation:
|
244
|
-
proc do
|
245
|
-
line do
|
246
|
-
plain "Expected "
|
247
|
-
actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::Person person_id: nil, age: 31, name: "Elliot"> }|
|
248
|
-
end
|
249
|
-
|
250
|
-
line do
|
251
|
-
plain " to eq "
|
252
|
-
expected %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382"> }|
|
253
|
-
end
|
254
|
-
end,
|
255
|
-
diff:
|
256
|
-
proc do
|
257
|
-
plain_line " {"
|
258
|
-
plain_line %| name: "Marty McFly",|
|
259
|
-
expected_line "- shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {"
|
260
|
-
expected_line "- id: nil,"
|
261
|
-
expected_line %|- city: "Hill Valley",|
|
262
|
-
expected_line %|- line_1: "123 Main St.",|
|
263
|
-
expected_line %|- line_2: "",|
|
264
|
-
expected_line %|- state: "CA",|
|
265
|
-
expected_line %|- zip: "90382"|
|
266
|
-
expected_line "- }>"
|
267
|
-
actual_line "+ shipping_address: #<SuperDiff::Test::Models::ActiveRecord::Person {"
|
268
|
-
actual_line "+ person_id: nil,"
|
269
|
-
actual_line "+ age: 31,"
|
270
|
-
actual_line %|+ name: "Elliot"|
|
271
|
-
actual_line "+ }>"
|
272
|
-
plain_line " }"
|
273
|
-
end
|
274
|
-
)
|
275
|
-
|
276
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
277
|
-
color_enabled
|
278
|
-
)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
context "when comparing an ActiveRecord::Relation object with an array" do
|
284
|
-
it "produces the correct output" do
|
285
|
-
as_both_colored_and_uncolored do |color_enabled|
|
286
|
-
snippet = <<~TEST.strip
|
287
|
-
SuperDiff::Test::Models::ActiveRecord::ShippingAddress.delete_all
|
288
|
-
shipping_addresses = [
|
289
|
-
SuperDiff::Test::Models::ActiveRecord::ShippingAddress.create!(
|
290
|
-
line_1: "123 Main St.",
|
291
|
-
city: "Hill Valley",
|
292
|
-
state: "CA",
|
293
|
-
zip: "90382",
|
294
|
-
),
|
295
|
-
SuperDiff::Test::Models::ActiveRecord::ShippingAddress.create!(
|
296
|
-
line_1: "456 Ponderosa Ct.",
|
297
|
-
city: "Oakland",
|
298
|
-
state: "CA",
|
299
|
-
zip: "91234",
|
300
|
-
)
|
301
|
-
]
|
302
|
-
actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.all
|
303
|
-
expected = [shipping_addresses.first]
|
304
|
-
expect(actual).to eq(expected)
|
305
|
-
TEST
|
306
|
-
program = make_program(snippet, color_enabled: color_enabled)
|
307
|
-
|
308
|
-
expected_output =
|
309
|
-
build_expected_output(
|
310
|
-
color_enabled: color_enabled,
|
311
|
-
snippet: "expect(actual).to eq(expected)",
|
312
|
-
expectation:
|
313
|
-
proc do
|
314
|
-
line do
|
315
|
-
plain "Expected "
|
316
|
-
actual %|#<ActiveRecord::Relation [#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 1, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">, #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 2, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234">]>|
|
317
|
-
end
|
318
|
-
|
319
|
-
line do
|
320
|
-
plain " to eq "
|
321
|
-
expected %|[#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 1, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">]|
|
322
|
-
end
|
323
|
-
end,
|
324
|
-
diff:
|
325
|
-
proc do
|
326
|
-
plain_line " #<ActiveRecord::Relation ["
|
327
|
-
plain_line " #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {"
|
328
|
-
plain_line " id: 1,"
|
329
|
-
plain_line %| city: "Hill Valley",|
|
330
|
-
plain_line %| line_1: "123 Main St.",|
|
331
|
-
plain_line %| line_2: "",|
|
332
|
-
plain_line %| state: "CA",|
|
333
|
-
plain_line %| zip: "90382"|
|
334
|
-
plain_line " }>,"
|
335
|
-
actual_line "+ #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {"
|
336
|
-
actual_line "+ id: 2,"
|
337
|
-
actual_line %|+ city: "Oakland",|
|
338
|
-
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
339
|
-
actual_line %|+ line_2: "",|
|
340
|
-
actual_line %|+ state: "CA",|
|
341
|
-
actual_line %|+ zip: "91234"|
|
342
|
-
actual_line "+ }>"
|
343
|
-
plain_line " ]>"
|
344
|
-
end
|
345
|
-
)
|
346
|
-
|
347
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
348
|
-
color_enabled
|
349
|
-
)
|
350
|
-
end
|
351
|
-
end
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
|
-
describe "and RSpec's #match matcher" do
|
356
|
-
context "when the expected value includes an ActiveRecord object" do
|
357
|
-
it "produces the correct output" do
|
358
|
-
as_both_colored_and_uncolored do |color_enabled|
|
359
|
-
snippet = <<~TEST.strip
|
360
|
-
SuperDiff::Test::Models::ActiveRecord::Person.create!(
|
361
|
-
name: "Murphy",
|
362
|
-
age: 20
|
363
|
-
)
|
364
|
-
|
365
|
-
actual = [
|
366
|
-
SuperDiff::Test::Models::ActiveRecord::Query.new(
|
367
|
-
results: SuperDiff::Test::Models::ActiveRecord::Person.all
|
368
|
-
)
|
369
|
-
]
|
370
|
-
|
371
|
-
expected = [
|
372
|
-
an_object_having_attributes(
|
373
|
-
results: [
|
374
|
-
an_object_having_attributes(name: "John", age: 19)
|
375
|
-
]
|
376
|
-
)
|
377
|
-
]
|
378
|
-
|
379
|
-
expect(actual).to match(expected)
|
380
|
-
TEST
|
381
|
-
|
382
|
-
program = make_program(snippet, color_enabled: color_enabled)
|
383
|
-
|
384
|
-
expected_output =
|
385
|
-
build_expected_output(
|
386
|
-
color_enabled: color_enabled,
|
387
|
-
snippet: "expect(actual).to match(expected)",
|
388
|
-
newline_before_expectation: true,
|
389
|
-
expectation:
|
390
|
-
proc do
|
391
|
-
line do
|
392
|
-
plain "Expected "
|
393
|
-
actual %|[#<SuperDiff::Test::Models::ActiveRecord::Query @results=#<ActiveRecord::Relation [#<SuperDiff::Test::Models::ActiveRecord::Person person_id: 1, age: 20, name: "Murphy">]>>]|
|
394
|
-
end
|
395
|
-
|
396
|
-
line do
|
397
|
-
plain "to match "
|
398
|
-
expected %|[#<an object having attributes (results: [#<an object having attributes (name: "John", age: 19)>])>]|
|
399
|
-
end
|
400
|
-
end,
|
401
|
-
diff:
|
402
|
-
proc do
|
403
|
-
plain_line " ["
|
404
|
-
plain_line " #<SuperDiff::Test::Models::ActiveRecord::Query {"
|
405
|
-
plain_line " @results=#<ActiveRecord::Relation ["
|
406
|
-
plain_line " #<SuperDiff::Test::Models::ActiveRecord::Person {"
|
407
|
-
plain_line " person_id: 1,"
|
408
|
-
# expected_line %|- age: 19,| # TODO
|
409
|
-
expected_line "- age: 19"
|
410
|
-
actual_line "+ age: 20,"
|
411
|
-
# expected_line %|- name: "John"| # TODO
|
412
|
-
expected_line %|- name: "John",|
|
413
|
-
actual_line %|+ name: "Murphy"|
|
414
|
-
plain_line " }>"
|
415
|
-
plain_line " ]>"
|
416
|
-
plain_line " }>"
|
417
|
-
plain_line " ]"
|
418
|
-
end
|
419
|
-
)
|
420
|
-
|
421
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
422
|
-
color_enabled
|
423
|
-
).removing_object_ids
|
424
|
-
end
|
425
|
-
end
|
426
|
-
end
|
427
|
-
end
|
428
|
-
end
|
@@ -1,188 +0,0 @@
|
|
1
|
-
shared_examples_for "integration with ActiveSupport" do
|
2
|
-
context "when comparing two different Time and ActiveSupport::TimeWithZone instances",
|
3
|
-
active_record: true do
|
4
|
-
it "produces the correct failure message when used in the positive" do
|
5
|
-
as_both_colored_and_uncolored do |color_enabled|
|
6
|
-
snippet = <<~RUBY
|
7
|
-
actual = Time.utc(2011, 12, 13, 14, 15, 16)
|
8
|
-
expected = Time.utc(2011, 12, 13, 15, 15, 16).in_time_zone("Europe/Stockholm")
|
9
|
-
expect(actual).to eq(expected)
|
10
|
-
RUBY
|
11
|
-
program =
|
12
|
-
make_rspec_rails_test_program(snippet, color_enabled: color_enabled)
|
13
|
-
|
14
|
-
expected_output =
|
15
|
-
build_expected_output(
|
16
|
-
color_enabled: color_enabled,
|
17
|
-
snippet: "expect(actual).to eq(expected)",
|
18
|
-
expectation:
|
19
|
-
proc do
|
20
|
-
line do
|
21
|
-
plain "Expected "
|
22
|
-
actual "#<Time 2011-12-13 14:15:16 +00:00 (UTC)>"
|
23
|
-
end
|
24
|
-
|
25
|
-
line do
|
26
|
-
plain " to eq "
|
27
|
-
expected "#<ActiveSupport::TimeWithZone 2011-12-13 16:15:16 +01:00 (CET)>"
|
28
|
-
end
|
29
|
-
end,
|
30
|
-
diff:
|
31
|
-
proc do
|
32
|
-
plain_line " #<Time {"
|
33
|
-
plain_line " year: 2011,"
|
34
|
-
plain_line " month: 12,"
|
35
|
-
plain_line " day: 13,"
|
36
|
-
expected_line "- hour: 16,"
|
37
|
-
actual_line "+ hour: 14,"
|
38
|
-
plain_line " min: 15,"
|
39
|
-
plain_line " sec: 16,"
|
40
|
-
plain_line " subsec: 0,"
|
41
|
-
expected_line %|- zone: \"CET\",|
|
42
|
-
actual_line %|+ zone: \"UTC\",|
|
43
|
-
expected_line "- utc_offset: 3600,"
|
44
|
-
actual_line "+ utc_offset: 0,"
|
45
|
-
plain_line " utc: #<Time {"
|
46
|
-
plain_line " year: 2011,"
|
47
|
-
plain_line " month: 12,"
|
48
|
-
plain_line " day: 13,"
|
49
|
-
expected_line "- hour: 15,"
|
50
|
-
actual_line "+ hour: 14,"
|
51
|
-
plain_line " min: 15,"
|
52
|
-
plain_line " sec: 16,"
|
53
|
-
plain_line " subsec: 0,"
|
54
|
-
plain_line %| zone: "UTC",|
|
55
|
-
plain_line " utc_offset: 0"
|
56
|
-
plain_line " }>"
|
57
|
-
plain_line " }>"
|
58
|
-
end
|
59
|
-
)
|
60
|
-
|
61
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
62
|
-
color_enabled
|
63
|
-
)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "when comparing OrderedOptions and Hash instances",
|
69
|
-
active_record: true do
|
70
|
-
it "produces the correct failure message when used in the positive" do
|
71
|
-
as_both_colored_and_uncolored do |color_enabled|
|
72
|
-
snippet = <<~RUBY
|
73
|
-
actual = {beep: :bip}
|
74
|
-
expected = ::ActiveSupport::OrderedOptions[beep: :boop]
|
75
|
-
expect(actual).to eq(expected)
|
76
|
-
RUBY
|
77
|
-
program =
|
78
|
-
make_rspec_rails_test_program(snippet, color_enabled: color_enabled)
|
79
|
-
|
80
|
-
expected_output =
|
81
|
-
build_expected_output(
|
82
|
-
color_enabled: color_enabled,
|
83
|
-
snippet: "expect(actual).to eq(expected)",
|
84
|
-
expectation:
|
85
|
-
proc do
|
86
|
-
line do
|
87
|
-
plain "Expected "
|
88
|
-
actual "{ beep: :bip }"
|
89
|
-
plain " to eq "
|
90
|
-
expected "#<OrderedOptions { beep: :boop }>"
|
91
|
-
plain "."
|
92
|
-
end
|
93
|
-
end,
|
94
|
-
diff:
|
95
|
-
proc do
|
96
|
-
plain_line " {"
|
97
|
-
expected_line "- beep: :boop"
|
98
|
-
actual_line "+ beep: :bip"
|
99
|
-
plain_line " }"
|
100
|
-
end
|
101
|
-
)
|
102
|
-
|
103
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
104
|
-
color_enabled
|
105
|
-
)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context "when comparing Date instance and date-like DateTime instance for same day",
|
111
|
-
active_record: true do
|
112
|
-
it "produces the correct failure message when used in the positive" do
|
113
|
-
as_both_colored_and_uncolored do |color_enabled|
|
114
|
-
snippet = <<~RUBY
|
115
|
-
actual = Date.new(2023, 10, 14)
|
116
|
-
expected = DateTime.new(2023, 10, 14, 18, 22, 26)
|
117
|
-
expect(actual).to eq(expected)
|
118
|
-
RUBY
|
119
|
-
program =
|
120
|
-
make_rspec_rails_test_program(snippet, color_enabled: color_enabled)
|
121
|
-
|
122
|
-
expected_output =
|
123
|
-
build_expected_output(
|
124
|
-
color_enabled: color_enabled,
|
125
|
-
snippet: "expect(actual).to eq(expected)",
|
126
|
-
expectation:
|
127
|
-
proc do
|
128
|
-
line do
|
129
|
-
plain "Expected "
|
130
|
-
actual "#<Date 2023-10-14>"
|
131
|
-
plain " to eq "
|
132
|
-
expected "#<DateTime 2023-10-14 18:22:26 +00:00 (+00:00)>"
|
133
|
-
plain "."
|
134
|
-
end
|
135
|
-
end
|
136
|
-
)
|
137
|
-
|
138
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
139
|
-
color_enabled
|
140
|
-
)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "when comparing Date instance and date-like DateTime instance for another day",
|
146
|
-
active_record: true do
|
147
|
-
it "produces the diff for date like objects comparison" do
|
148
|
-
as_both_colored_and_uncolored do |color_enabled|
|
149
|
-
snippet = <<~RUBY
|
150
|
-
actual = Date.new(2023, 10, 14)
|
151
|
-
expected = DateTime.new(2023, 10, 31, 18, 22, 26)
|
152
|
-
expect(actual).to eq(expected)
|
153
|
-
RUBY
|
154
|
-
program =
|
155
|
-
make_rspec_rails_test_program(snippet, color_enabled: color_enabled)
|
156
|
-
|
157
|
-
expected_output =
|
158
|
-
build_expected_output(
|
159
|
-
color_enabled: color_enabled,
|
160
|
-
snippet: "expect(actual).to eq(expected)",
|
161
|
-
expectation:
|
162
|
-
proc do
|
163
|
-
line do
|
164
|
-
plain "Expected "
|
165
|
-
actual "#<Date 2023-10-14>"
|
166
|
-
plain " to eq "
|
167
|
-
expected "#<DateTime 2023-10-31 18:22:26 +00:00 (+00:00)>"
|
168
|
-
plain "."
|
169
|
-
end
|
170
|
-
end,
|
171
|
-
diff:
|
172
|
-
proc do
|
173
|
-
plain_line " #<Date {"
|
174
|
-
plain_line " year: 2023,"
|
175
|
-
plain_line " month: 10,"
|
176
|
-
expected_line "- day: 31"
|
177
|
-
actual_line "+ day: 14"
|
178
|
-
plain_line " }>"
|
179
|
-
end
|
180
|
-
)
|
181
|
-
|
182
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
183
|
-
color_enabled
|
184
|
-
)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|