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,452 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "Integration with RSpec's #include matcher",
|
4
|
-
type: :integration do
|
5
|
-
context "when used against an array" do
|
6
|
-
context "that is small" do
|
7
|
-
it "produces the correct failure message when used in the positive" do
|
8
|
-
as_both_colored_and_uncolored do |color_enabled|
|
9
|
-
snippet = <<~TEST.strip
|
10
|
-
actual = ["Marty", "Jennifer", "Doc"]
|
11
|
-
expected = ["Marty", "Einie"]
|
12
|
-
expect(actual).to include(*expected)
|
13
|
-
TEST
|
14
|
-
program =
|
15
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
16
|
-
|
17
|
-
expected_output =
|
18
|
-
build_expected_output(
|
19
|
-
color_enabled: color_enabled,
|
20
|
-
snippet: "expect(actual).to include(*expected)",
|
21
|
-
expectation:
|
22
|
-
proc do
|
23
|
-
line do
|
24
|
-
plain "Expected "
|
25
|
-
actual %|["Marty", "Jennifer", "Doc"]|
|
26
|
-
plain " to include "
|
27
|
-
expected %|"Einie"|
|
28
|
-
plain "."
|
29
|
-
end
|
30
|
-
end,
|
31
|
-
diff:
|
32
|
-
proc do
|
33
|
-
plain_line " ["
|
34
|
-
plain_line %| "Marty",|
|
35
|
-
plain_line %| "Jennifer",|
|
36
|
-
# plain_line %| "Doc",| # FIXME
|
37
|
-
plain_line %| "Doc"|
|
38
|
-
expected_line %|- "Einie"|
|
39
|
-
plain_line " ]"
|
40
|
-
end
|
41
|
-
)
|
42
|
-
|
43
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
44
|
-
color_enabled
|
45
|
-
)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
it "produces the correct failure message when used in the negative" do
|
50
|
-
as_both_colored_and_uncolored do |color_enabled|
|
51
|
-
snippet = <<~TEST.strip
|
52
|
-
values = ["Marty", "Einie"]
|
53
|
-
expect(values).not_to include(*values)
|
54
|
-
TEST
|
55
|
-
program =
|
56
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
57
|
-
|
58
|
-
expected_output =
|
59
|
-
build_expected_output(
|
60
|
-
color_enabled: color_enabled,
|
61
|
-
snippet: "expect(values).not_to include(*values)",
|
62
|
-
expectation:
|
63
|
-
proc do
|
64
|
-
line do
|
65
|
-
plain "Expected "
|
66
|
-
actual %|["Marty", "Einie"]|
|
67
|
-
plain " not to include "
|
68
|
-
expected %|"Marty" and "Einie"|
|
69
|
-
plain "."
|
70
|
-
end
|
71
|
-
end
|
72
|
-
)
|
73
|
-
|
74
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
75
|
-
color_enabled
|
76
|
-
)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "that is large" do
|
82
|
-
it "produces the correct failure message when used in the positive" do
|
83
|
-
as_both_colored_and_uncolored do |color_enabled|
|
84
|
-
snippet = <<~TEST.strip
|
85
|
-
actual = [
|
86
|
-
"Marty McFly",
|
87
|
-
"Doc Brown",
|
88
|
-
"Einie",
|
89
|
-
"Lorraine McFly"
|
90
|
-
]
|
91
|
-
expected = [
|
92
|
-
"Marty McFly",
|
93
|
-
"Doc Brown",
|
94
|
-
"Einie",
|
95
|
-
"Biff Tannen",
|
96
|
-
"George McFly",
|
97
|
-
"Lorraine McFly"
|
98
|
-
]
|
99
|
-
expect(actual).to include(*expected)
|
100
|
-
TEST
|
101
|
-
program =
|
102
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
103
|
-
|
104
|
-
expected_output =
|
105
|
-
build_expected_output(
|
106
|
-
color_enabled: color_enabled,
|
107
|
-
snippet: "expect(actual).to include(*expected)",
|
108
|
-
expectation:
|
109
|
-
proc do
|
110
|
-
line do
|
111
|
-
plain " Expected "
|
112
|
-
actual %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
|
113
|
-
end
|
114
|
-
|
115
|
-
line do
|
116
|
-
plain "to include "
|
117
|
-
expected %|"Biff Tannen" and "George McFly"|
|
118
|
-
end
|
119
|
-
end,
|
120
|
-
diff:
|
121
|
-
proc do
|
122
|
-
plain_line " ["
|
123
|
-
plain_line %| "Marty McFly",|
|
124
|
-
plain_line %| "Doc Brown",|
|
125
|
-
plain_line %| "Einie",|
|
126
|
-
# plain_line %| "Lorraine McFly",| # FIXME
|
127
|
-
plain_line %| "Lorraine McFly"|
|
128
|
-
expected_line %|- "Biff Tannen",|
|
129
|
-
expected_line %|- "George McFly"|
|
130
|
-
plain_line " ]"
|
131
|
-
end
|
132
|
-
)
|
133
|
-
|
134
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
135
|
-
color_enabled
|
136
|
-
)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
it "produces the correct failure message when used in the negative" do
|
141
|
-
as_both_colored_and_uncolored do |color_enabled|
|
142
|
-
snippet = <<~TEST.strip
|
143
|
-
actual = [
|
144
|
-
"Marty McFly",
|
145
|
-
"Doc Brown",
|
146
|
-
"Einie",
|
147
|
-
"Biff Tannen",
|
148
|
-
"George McFly",
|
149
|
-
"Lorraine McFly"
|
150
|
-
]
|
151
|
-
expected = [
|
152
|
-
"Marty McFly",
|
153
|
-
"Doc Brown",
|
154
|
-
"Einie",
|
155
|
-
"Lorraine McFly"
|
156
|
-
]
|
157
|
-
expect(actual).not_to include(*expected)
|
158
|
-
TEST
|
159
|
-
program =
|
160
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
161
|
-
|
162
|
-
expected_output =
|
163
|
-
build_expected_output(
|
164
|
-
color_enabled: color_enabled,
|
165
|
-
snippet: "expect(actual).not_to include(*expected)",
|
166
|
-
newline_before_expectation: true,
|
167
|
-
expectation:
|
168
|
-
proc do
|
169
|
-
line do
|
170
|
-
plain " Expected "
|
171
|
-
actual %|["Marty McFly", "Doc Brown", "Einie", "Biff Tannen", "George McFly", "Lorraine McFly"]|
|
172
|
-
end
|
173
|
-
|
174
|
-
line do
|
175
|
-
plain "not to include "
|
176
|
-
expected %|"Marty McFly", "Doc Brown", "Einie", and "Lorraine McFly"|
|
177
|
-
end
|
178
|
-
end
|
179
|
-
)
|
180
|
-
|
181
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
182
|
-
color_enabled
|
183
|
-
)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
context "when used against a hash" do
|
190
|
-
context "that is small" do
|
191
|
-
it "produces the correct failure message when used in the positive" do
|
192
|
-
as_both_colored_and_uncolored do |color_enabled|
|
193
|
-
snippet = <<~TEST.strip
|
194
|
-
actual = { city: "Burbank", zip: "90210" }
|
195
|
-
expected = { city: "Hill Valley", state: "CA" }
|
196
|
-
expect(actual).to include(expected)
|
197
|
-
TEST
|
198
|
-
program =
|
199
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
200
|
-
|
201
|
-
expected_output =
|
202
|
-
build_expected_output(
|
203
|
-
color_enabled: color_enabled,
|
204
|
-
snippet: "expect(actual).to include(expected)",
|
205
|
-
expectation:
|
206
|
-
proc do
|
207
|
-
line do
|
208
|
-
plain "Expected "
|
209
|
-
actual %|{ city: "Burbank", zip: "90210" }|
|
210
|
-
plain " to include "
|
211
|
-
expected %|(city: "Hill Valley", state: "CA")|
|
212
|
-
plain "."
|
213
|
-
end
|
214
|
-
end,
|
215
|
-
diff:
|
216
|
-
proc do
|
217
|
-
plain_line " {"
|
218
|
-
expected_line %|- city: "Hill Valley",|
|
219
|
-
actual_line %|+ city: "Burbank",|
|
220
|
-
# FIXME
|
221
|
-
# expected_line %|- state: "CA",|
|
222
|
-
expected_line %|- state: "CA"|
|
223
|
-
plain_line %| zip: "90210"|
|
224
|
-
plain_line " }"
|
225
|
-
end
|
226
|
-
)
|
227
|
-
|
228
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
229
|
-
color_enabled
|
230
|
-
)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
it "produces the correct failure message when used in the negative" do
|
235
|
-
as_both_colored_and_uncolored do |color_enabled|
|
236
|
-
snippet = <<~TEST.strip
|
237
|
-
actual = { city: "Burbank", zip: "90210" }
|
238
|
-
expected = { city: "Burbank" }
|
239
|
-
expect(actual).not_to include(expected)
|
240
|
-
TEST
|
241
|
-
program =
|
242
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
243
|
-
|
244
|
-
expected_output =
|
245
|
-
build_expected_output(
|
246
|
-
color_enabled: color_enabled,
|
247
|
-
snippet: "expect(actual).not_to include(expected)",
|
248
|
-
expectation:
|
249
|
-
proc do
|
250
|
-
line do
|
251
|
-
plain "Expected "
|
252
|
-
actual %|{ city: "Burbank", zip: "90210" }|
|
253
|
-
plain " not to include "
|
254
|
-
expected %|(city: "Burbank")|
|
255
|
-
plain "."
|
256
|
-
end
|
257
|
-
end
|
258
|
-
)
|
259
|
-
|
260
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
261
|
-
color_enabled
|
262
|
-
)
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
it "produces the correct failure message when fuzzy matching" do
|
267
|
-
as_both_colored_and_uncolored do |color_enabled|
|
268
|
-
snippet = <<~TEST.strip
|
269
|
-
actual = { number: 42, city: "Burbank", zip: "90210" }
|
270
|
-
expected = { number: a_kind_of(Numeric), city: /burb/i, state: "CA" }
|
271
|
-
expect(actual).to include(expected)
|
272
|
-
TEST
|
273
|
-
program =
|
274
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
275
|
-
|
276
|
-
expected_output =
|
277
|
-
build_expected_output(
|
278
|
-
color_enabled: color_enabled,
|
279
|
-
snippet: "expect(actual).to include(expected)",
|
280
|
-
expectation:
|
281
|
-
proc do
|
282
|
-
line do
|
283
|
-
plain "Expected "
|
284
|
-
actual %|{ number: 42, city: "Burbank", zip: "90210" }|
|
285
|
-
plain " to include "
|
286
|
-
expected %|(state: "CA")|
|
287
|
-
plain "."
|
288
|
-
end
|
289
|
-
end,
|
290
|
-
diff:
|
291
|
-
proc do
|
292
|
-
plain_line " {"
|
293
|
-
plain_line " number: 42,"
|
294
|
-
plain_line %| city: "Burbank",|
|
295
|
-
plain_line %| zip: "90210"|
|
296
|
-
expected_line %|- state: "CA"|
|
297
|
-
plain_line " }"
|
298
|
-
end
|
299
|
-
)
|
300
|
-
|
301
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
302
|
-
color_enabled
|
303
|
-
)
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
context "that is large" do
|
309
|
-
it "produces the correct failure message when used in the positive" do
|
310
|
-
as_both_colored_and_uncolored do |color_enabled|
|
311
|
-
snippet = <<~TEST.strip
|
312
|
-
actual = {
|
313
|
-
city: "Burbank",
|
314
|
-
state: "CA",
|
315
|
-
zip: "90210"
|
316
|
-
}
|
317
|
-
expected = {
|
318
|
-
city: "Hill Valley",
|
319
|
-
zip: "90382"
|
320
|
-
}
|
321
|
-
expect(actual).to include(expected)
|
322
|
-
TEST
|
323
|
-
program =
|
324
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
325
|
-
|
326
|
-
expected_output =
|
327
|
-
build_expected_output(
|
328
|
-
color_enabled: color_enabled,
|
329
|
-
snippet: "expect(actual).to include(expected)",
|
330
|
-
expectation:
|
331
|
-
proc do
|
332
|
-
line do
|
333
|
-
plain " Expected "
|
334
|
-
actual %|{ city: "Burbank", state: "CA", zip: "90210" }|
|
335
|
-
end
|
336
|
-
|
337
|
-
line do
|
338
|
-
plain "to include "
|
339
|
-
expected %|(city: "Hill Valley", zip: "90382")|
|
340
|
-
end
|
341
|
-
end,
|
342
|
-
diff:
|
343
|
-
proc do
|
344
|
-
plain_line " {"
|
345
|
-
expected_line %|- city: "Hill Valley",|
|
346
|
-
actual_line %|+ city: "Burbank",|
|
347
|
-
plain_line %| state: "CA",|
|
348
|
-
expected_line %|- zip: "90382"|
|
349
|
-
actual_line %|+ zip: "90210"|
|
350
|
-
plain_line " }"
|
351
|
-
end
|
352
|
-
)
|
353
|
-
|
354
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
355
|
-
color_enabled
|
356
|
-
)
|
357
|
-
end
|
358
|
-
end
|
359
|
-
|
360
|
-
it "produces the correct failure message when used in the negative" do
|
361
|
-
as_both_colored_and_uncolored do |color_enabled|
|
362
|
-
snippet = <<~TEST.strip
|
363
|
-
actual = { city: "Hill Valley", state: "CA", zip: "90210" }
|
364
|
-
expected = { city: "Hill Valley", state: "CA" }
|
365
|
-
expect(actual).not_to include(expected)
|
366
|
-
TEST
|
367
|
-
program =
|
368
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
369
|
-
|
370
|
-
expected_output =
|
371
|
-
build_expected_output(
|
372
|
-
color_enabled: color_enabled,
|
373
|
-
snippet: "expect(actual).not_to include(expected)",
|
374
|
-
newline_before_expectation: true,
|
375
|
-
expectation:
|
376
|
-
proc do
|
377
|
-
line do
|
378
|
-
plain " Expected "
|
379
|
-
actual %|{ city: "Hill Valley", state: "CA", zip: "90210" }|
|
380
|
-
end
|
381
|
-
|
382
|
-
line do
|
383
|
-
plain "not to include "
|
384
|
-
expected %|(city: "Hill Valley", state: "CA")|
|
385
|
-
end
|
386
|
-
end
|
387
|
-
)
|
388
|
-
|
389
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
390
|
-
color_enabled
|
391
|
-
)
|
392
|
-
end
|
393
|
-
end
|
394
|
-
|
395
|
-
it "produces the correct failure message when fuzzy matching" do
|
396
|
-
as_both_colored_and_uncolored do |color_enabled|
|
397
|
-
snippet = <<~TEST.strip
|
398
|
-
actual = {
|
399
|
-
number: 42,
|
400
|
-
street: "Yoshie Circles",
|
401
|
-
city: "Burbank",
|
402
|
-
state: "CA",
|
403
|
-
zip: "90210"
|
404
|
-
}
|
405
|
-
expected = {
|
406
|
-
number: a_kind_of(Numeric),
|
407
|
-
street: "Yoshie Circles",
|
408
|
-
city: /burb/i,
|
409
|
-
zip: "90382"
|
410
|
-
}
|
411
|
-
expect(actual).to include(expected)
|
412
|
-
TEST
|
413
|
-
program =
|
414
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
415
|
-
|
416
|
-
expected_output =
|
417
|
-
build_expected_output(
|
418
|
-
color_enabled: color_enabled,
|
419
|
-
snippet: "expect(actual).to include(expected)",
|
420
|
-
expectation:
|
421
|
-
proc do
|
422
|
-
line do
|
423
|
-
plain " Expected "
|
424
|
-
actual %|{ number: 42, street: "Yoshie Circles", city: "Burbank", state: "CA", zip: "90210" }|
|
425
|
-
end
|
426
|
-
|
427
|
-
line do
|
428
|
-
plain "to include "
|
429
|
-
expected %|(zip: "90382")|
|
430
|
-
end
|
431
|
-
end,
|
432
|
-
diff:
|
433
|
-
proc do
|
434
|
-
plain_line " {"
|
435
|
-
plain_line " number: 42,"
|
436
|
-
plain_line %| street: "Yoshie Circles",|
|
437
|
-
plain_line %| city: "Burbank",|
|
438
|
-
plain_line %| state: "CA",|
|
439
|
-
expected_line %|- zip: "90382"|
|
440
|
-
actual_line %|+ zip: "90210"|
|
441
|
-
plain_line " }"
|
442
|
-
end
|
443
|
-
)
|
444
|
-
|
445
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
446
|
-
color_enabled
|
447
|
-
)
|
448
|
-
end
|
449
|
-
end
|
450
|
-
end
|
451
|
-
end
|
452
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "Integration with RSpec's magic metadata", type: :integration do
|
4
|
-
it "includes extra_failure_lines in failure messages" do
|
5
|
-
as_both_colored_and_uncolored do |color_enabled|
|
6
|
-
snippet = <<~TEST.strip
|
7
|
-
RSpec.describe "test" do
|
8
|
-
it { expect(true).to be(false) }
|
9
|
-
|
10
|
-
after do
|
11
|
-
RSpec.current_example.metadata[:extra_failure_lines] = "foo\nbar"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
TEST
|
15
|
-
program =
|
16
|
-
make_plain_test_program(
|
17
|
-
snippet,
|
18
|
-
color_enabled: color_enabled,
|
19
|
-
preserve_as_whole_file: true
|
20
|
-
)
|
21
|
-
|
22
|
-
expected_output =
|
23
|
-
build_expected_output(
|
24
|
-
color_enabled: color_enabled,
|
25
|
-
test_name: "test is expected to equal false",
|
26
|
-
snippet: "it { expect(true).to be(false) }",
|
27
|
-
expectation:
|
28
|
-
proc do
|
29
|
-
line do
|
30
|
-
plain "Expected "
|
31
|
-
actual "true"
|
32
|
-
plain " to equal "
|
33
|
-
expected "false"
|
34
|
-
plain "."
|
35
|
-
end
|
36
|
-
end,
|
37
|
-
extra_failure_lines:
|
38
|
-
proc do
|
39
|
-
indent by: 5 do
|
40
|
-
line "foo"
|
41
|
-
line "bar"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
)
|
45
|
-
|
46
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
47
|
-
color_enabled
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|