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,615 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "Integration with RSpec's #be_<predicate> matcher",
|
4
|
-
type: :integration do
|
5
|
-
# rubocop:disable Metrics/BlockLength
|
6
|
-
%w[be be_a be_an].each do |prefix|
|
7
|
-
# rubocop:enable Metrics/BlockLength
|
8
|
-
context "using #{prefix}_<predicate>" do
|
9
|
-
context "when the predicate method doesn't exist on the object" do
|
10
|
-
context "when the inspected version of the actual value is short" do
|
11
|
-
it "produces the correct failure message" do
|
12
|
-
as_both_colored_and_uncolored do |color_enabled|
|
13
|
-
snippet = %|expect(:foo).to #{prefix}_strong|
|
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: snippet,
|
21
|
-
expectation:
|
22
|
-
proc do
|
23
|
-
line do
|
24
|
-
plain "Expected "
|
25
|
-
actual ":foo"
|
26
|
-
plain " to respond to "
|
27
|
-
expected "strong?"
|
28
|
-
plain " or "
|
29
|
-
expected "strongs?"
|
30
|
-
plain "."
|
31
|
-
end
|
32
|
-
end
|
33
|
-
)
|
34
|
-
|
35
|
-
expect(program).to produce_output_when_run(
|
36
|
-
expected_output
|
37
|
-
).in_color(color_enabled)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when the inspected version of the actual value is long" do
|
43
|
-
it "produces the correct failure message" do
|
44
|
-
as_both_colored_and_uncolored do |color_enabled|
|
45
|
-
snippet = <<~TEST.strip
|
46
|
-
hash = { foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz", aaaaaa: "bbbbbb" }
|
47
|
-
expect(hash).to #{prefix}_strong
|
48
|
-
TEST
|
49
|
-
program =
|
50
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
51
|
-
|
52
|
-
expected_output =
|
53
|
-
build_expected_output(
|
54
|
-
color_enabled: color_enabled,
|
55
|
-
snippet: %|expect(hash).to #{prefix}_strong|,
|
56
|
-
newline_before_expectation: true,
|
57
|
-
expectation:
|
58
|
-
proc do
|
59
|
-
line do
|
60
|
-
plain " Expected "
|
61
|
-
actual %|{ foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz", aaaaaa: "bbbbbb" }|
|
62
|
-
end
|
63
|
-
|
64
|
-
line do
|
65
|
-
plain "to respond to "
|
66
|
-
expected "strong?"
|
67
|
-
plain " or "
|
68
|
-
expected "strongs?"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
)
|
72
|
-
|
73
|
-
expect(program).to produce_output_when_run(
|
74
|
-
expected_output
|
75
|
-
).in_color(color_enabled)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "when the predicate method exists on the object" do
|
82
|
-
context "but is private" do
|
83
|
-
context "when the inspected version of the actual value is short" do
|
84
|
-
it "produces the correct failure message" do
|
85
|
-
as_both_colored_and_uncolored do |color_enabled|
|
86
|
-
snippet = <<~TEST.strip
|
87
|
-
class Foo
|
88
|
-
private def strong?; end
|
89
|
-
end
|
90
|
-
|
91
|
-
expect(Foo.new).to #{prefix}_strong
|
92
|
-
TEST
|
93
|
-
program =
|
94
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
95
|
-
|
96
|
-
expected_output =
|
97
|
-
build_expected_output(
|
98
|
-
color_enabled: color_enabled,
|
99
|
-
snippet: %|expect(Foo.new).to #{prefix}_strong|,
|
100
|
-
expectation:
|
101
|
-
proc do
|
102
|
-
line do
|
103
|
-
plain "Expected "
|
104
|
-
actual "#<Foo>"
|
105
|
-
plain " to have a public method "
|
106
|
-
expected "strong?"
|
107
|
-
plain " or "
|
108
|
-
expected "strongs?"
|
109
|
-
plain "."
|
110
|
-
end
|
111
|
-
end
|
112
|
-
)
|
113
|
-
|
114
|
-
expect(program).to produce_output_when_run(
|
115
|
-
expected_output
|
116
|
-
).in_color(color_enabled).removing_object_ids
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context "when the inspected version of the actual value is long" do
|
122
|
-
it "produces the correct failure message" do
|
123
|
-
as_both_colored_and_uncolored do |color_enabled|
|
124
|
-
snippet = <<~TEST.strip
|
125
|
-
hash = { foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz" }
|
126
|
-
|
127
|
-
class << hash
|
128
|
-
private def strong?; end
|
129
|
-
end
|
130
|
-
|
131
|
-
expect(hash).to #{prefix}_strong
|
132
|
-
TEST
|
133
|
-
program =
|
134
|
-
make_plain_test_program(snippet, color_enabled: color_enabled)
|
135
|
-
|
136
|
-
expected_output =
|
137
|
-
build_expected_output(
|
138
|
-
color_enabled: color_enabled,
|
139
|
-
snippet: %|expect(hash).to #{prefix}_strong|,
|
140
|
-
newline_before_expectation: true,
|
141
|
-
expectation:
|
142
|
-
proc do
|
143
|
-
line do
|
144
|
-
plain " Expected "
|
145
|
-
actual %|{ foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz" }|
|
146
|
-
end
|
147
|
-
|
148
|
-
line do
|
149
|
-
plain "to have a public method "
|
150
|
-
expected "strong?"
|
151
|
-
plain " or "
|
152
|
-
expected "strongs?"
|
153
|
-
end
|
154
|
-
end
|
155
|
-
)
|
156
|
-
|
157
|
-
expect(program).to produce_output_when_run(
|
158
|
-
expected_output
|
159
|
-
).in_color(color_enabled).removing_object_ids
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
context "and is public" do
|
166
|
-
context "and returns false" do
|
167
|
-
context "but is called #true?" do
|
168
|
-
context "when the inspected version of the actual value is short" do
|
169
|
-
it "produces the correct failure message" do
|
170
|
-
as_both_colored_and_uncolored do |color_enabled|
|
171
|
-
snippet = <<~TEST.strip
|
172
|
-
class Foo
|
173
|
-
def true?; false; end
|
174
|
-
end
|
175
|
-
|
176
|
-
expect(Foo.new).to #{prefix}_true
|
177
|
-
TEST
|
178
|
-
program =
|
179
|
-
make_plain_test_program(
|
180
|
-
snippet,
|
181
|
-
color_enabled: color_enabled
|
182
|
-
)
|
183
|
-
|
184
|
-
expected_output =
|
185
|
-
build_expected_output(
|
186
|
-
color_enabled: color_enabled,
|
187
|
-
snippet: %|expect(Foo.new).to #{prefix}_true|,
|
188
|
-
newline_before_expectation: true,
|
189
|
-
expectation:
|
190
|
-
proc do
|
191
|
-
line do
|
192
|
-
plain "Expected "
|
193
|
-
actual "#<Foo>"
|
194
|
-
plain " to return a truthy result for "
|
195
|
-
expected "true?"
|
196
|
-
plain " or "
|
197
|
-
expected "trues?"
|
198
|
-
plain "."
|
199
|
-
end
|
200
|
-
|
201
|
-
newline
|
202
|
-
|
203
|
-
line do
|
204
|
-
plain "(Perhaps you want to use "
|
205
|
-
blue "be(true)"
|
206
|
-
plain " or "
|
207
|
-
blue "be_truthy"
|
208
|
-
plain " instead?)"
|
209
|
-
end
|
210
|
-
end
|
211
|
-
)
|
212
|
-
|
213
|
-
expect(program).to produce_output_when_run(
|
214
|
-
expected_output
|
215
|
-
).in_color(color_enabled).removing_object_ids
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
context "when the inspected version of the actual value is long" do
|
221
|
-
it "produces the correct failure message" do
|
222
|
-
as_both_colored_and_uncolored do |color_enabled|
|
223
|
-
snippet = <<~TEST.strip
|
224
|
-
hash = {
|
225
|
-
foo: "bar",
|
226
|
-
baz: "qux",
|
227
|
-
blargh: "foz",
|
228
|
-
fizz: "buzz"
|
229
|
-
}
|
230
|
-
|
231
|
-
class << hash
|
232
|
-
def true?; false; end
|
233
|
-
end
|
234
|
-
|
235
|
-
expect(hash).to #{prefix}_true
|
236
|
-
TEST
|
237
|
-
program =
|
238
|
-
make_plain_test_program(
|
239
|
-
snippet,
|
240
|
-
color_enabled: color_enabled
|
241
|
-
)
|
242
|
-
|
243
|
-
expected_output =
|
244
|
-
build_expected_output(
|
245
|
-
color_enabled: color_enabled,
|
246
|
-
snippet: %|expect(hash).to #{prefix}_true|,
|
247
|
-
newline_before_expectation: true,
|
248
|
-
expectation:
|
249
|
-
proc do
|
250
|
-
line do
|
251
|
-
plain " Expected "
|
252
|
-
actual %|{ foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz" }|
|
253
|
-
end
|
254
|
-
|
255
|
-
line do
|
256
|
-
plain "to return a truthy result for "
|
257
|
-
expected "true?"
|
258
|
-
plain " or "
|
259
|
-
expected "trues?"
|
260
|
-
end
|
261
|
-
|
262
|
-
newline
|
263
|
-
|
264
|
-
line do
|
265
|
-
plain "(Perhaps you want to use "
|
266
|
-
blue "be(true)"
|
267
|
-
plain " or "
|
268
|
-
blue "be_truthy"
|
269
|
-
plain " instead?)"
|
270
|
-
end
|
271
|
-
end
|
272
|
-
)
|
273
|
-
|
274
|
-
expect(program).to produce_output_when_run(
|
275
|
-
expected_output
|
276
|
-
).in_color(color_enabled).removing_object_ids
|
277
|
-
end
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
context "but is called #false?" do
|
283
|
-
it "produces the correct failure message" do
|
284
|
-
as_both_colored_and_uncolored do |color_enabled|
|
285
|
-
snippet = <<~TEST.strip
|
286
|
-
class X
|
287
|
-
def false?; false; end
|
288
|
-
end
|
289
|
-
|
290
|
-
expect(X.new).to #{prefix}_false
|
291
|
-
TEST
|
292
|
-
program =
|
293
|
-
make_plain_test_program(
|
294
|
-
snippet,
|
295
|
-
color_enabled: color_enabled
|
296
|
-
)
|
297
|
-
|
298
|
-
expected_output =
|
299
|
-
build_expected_output(
|
300
|
-
color_enabled: color_enabled,
|
301
|
-
snippet: %|expect(X.new).to #{prefix}_false|,
|
302
|
-
newline_before_expectation: true,
|
303
|
-
expectation:
|
304
|
-
proc do
|
305
|
-
line do
|
306
|
-
plain "Expected "
|
307
|
-
actual "#<X>"
|
308
|
-
plain " to return a truthy result for "
|
309
|
-
expected "false?"
|
310
|
-
plain " or "
|
311
|
-
expected "falses?"
|
312
|
-
plain "."
|
313
|
-
end
|
314
|
-
end
|
315
|
-
)
|
316
|
-
|
317
|
-
expect(program).to produce_output_when_run(
|
318
|
-
expected_output
|
319
|
-
).in_color(color_enabled).removing_object_ids
|
320
|
-
end
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
context "and is called neither #true? nor #false?" do
|
325
|
-
context "and is singular" do
|
326
|
-
context "when the inspected version of the actual value is short" do
|
327
|
-
it "produces the correct failure message" do
|
328
|
-
as_both_colored_and_uncolored do |color_enabled|
|
329
|
-
snippet = <<~TEST.strip
|
330
|
-
class X
|
331
|
-
def y?; false; end
|
332
|
-
end
|
333
|
-
|
334
|
-
expect(X.new).to #{prefix}_y
|
335
|
-
TEST
|
336
|
-
program =
|
337
|
-
make_plain_test_program(
|
338
|
-
snippet,
|
339
|
-
color_enabled: color_enabled
|
340
|
-
)
|
341
|
-
|
342
|
-
expected_output =
|
343
|
-
build_expected_output(
|
344
|
-
color_enabled: color_enabled,
|
345
|
-
snippet: %|expect(X.new).to #{prefix}_y|,
|
346
|
-
expectation:
|
347
|
-
proc do
|
348
|
-
line do
|
349
|
-
plain "Expected "
|
350
|
-
actual "#<X>"
|
351
|
-
plain " to return a truthy result for "
|
352
|
-
expected "y?"
|
353
|
-
plain " or "
|
354
|
-
expected "ys?"
|
355
|
-
plain "."
|
356
|
-
end
|
357
|
-
end
|
358
|
-
)
|
359
|
-
|
360
|
-
expect(program).to produce_output_when_run(
|
361
|
-
expected_output
|
362
|
-
).in_color(color_enabled).removing_object_ids
|
363
|
-
end
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
context "when the inspected version of the actual value is long" do
|
368
|
-
it "produces the correct failure message" do
|
369
|
-
as_both_colored_and_uncolored do |color_enabled|
|
370
|
-
snippet = <<~TEST.strip
|
371
|
-
hash = {
|
372
|
-
foo: "bar",
|
373
|
-
baz: "qux",
|
374
|
-
blargh: "foz",
|
375
|
-
fizz: "buzz",
|
376
|
-
aaaaaa: "bbbbbb"
|
377
|
-
}
|
378
|
-
|
379
|
-
class << hash
|
380
|
-
def y?; false; end
|
381
|
-
end
|
382
|
-
|
383
|
-
expect(hash).to #{prefix}_y
|
384
|
-
TEST
|
385
|
-
program =
|
386
|
-
make_plain_test_program(
|
387
|
-
snippet,
|
388
|
-
color_enabled: color_enabled
|
389
|
-
)
|
390
|
-
|
391
|
-
expected_output =
|
392
|
-
build_expected_output(
|
393
|
-
color_enabled: color_enabled,
|
394
|
-
snippet: %|expect(hash).to #{prefix}_y|,
|
395
|
-
newline_before_expectation: true,
|
396
|
-
expectation:
|
397
|
-
proc do
|
398
|
-
line do
|
399
|
-
plain " Expected "
|
400
|
-
actual %|{ foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz", aaaaaa: "bbbbbb" }|
|
401
|
-
end
|
402
|
-
|
403
|
-
line do
|
404
|
-
plain "to return a truthy result for "
|
405
|
-
expected "y?"
|
406
|
-
plain " or "
|
407
|
-
expected "ys?"
|
408
|
-
end
|
409
|
-
end
|
410
|
-
)
|
411
|
-
|
412
|
-
expect(program).to produce_output_when_run(
|
413
|
-
expected_output
|
414
|
-
).in_color(color_enabled).removing_object_ids
|
415
|
-
end
|
416
|
-
end
|
417
|
-
end
|
418
|
-
end
|
419
|
-
|
420
|
-
context "and is plural" do
|
421
|
-
context "when the inspected version of the actual value is short" do
|
422
|
-
it "produces the correct failure message" do
|
423
|
-
as_both_colored_and_uncolored do |color_enabled|
|
424
|
-
snippet = <<~TEST.strip
|
425
|
-
class X
|
426
|
-
def ys?; false; end
|
427
|
-
end
|
428
|
-
|
429
|
-
expect(X.new).to #{prefix}_y
|
430
|
-
TEST
|
431
|
-
program =
|
432
|
-
make_plain_test_program(
|
433
|
-
snippet,
|
434
|
-
color_enabled: color_enabled
|
435
|
-
)
|
436
|
-
|
437
|
-
expected_output =
|
438
|
-
build_expected_output(
|
439
|
-
color_enabled: color_enabled,
|
440
|
-
snippet: %|expect(X.new).to #{prefix}_y|,
|
441
|
-
expectation:
|
442
|
-
proc do
|
443
|
-
line do
|
444
|
-
plain "Expected "
|
445
|
-
actual "#<X>"
|
446
|
-
plain " to return a truthy result for "
|
447
|
-
expected "y?"
|
448
|
-
plain " or "
|
449
|
-
expected "ys?"
|
450
|
-
plain "."
|
451
|
-
end
|
452
|
-
end
|
453
|
-
)
|
454
|
-
|
455
|
-
expect(program).to produce_output_when_run(
|
456
|
-
expected_output
|
457
|
-
).in_color(color_enabled).removing_object_ids
|
458
|
-
end
|
459
|
-
end
|
460
|
-
end
|
461
|
-
|
462
|
-
context "when the inspected version of the actual value is long" do
|
463
|
-
it "produces the correct failure message" do
|
464
|
-
as_both_colored_and_uncolored do |color_enabled|
|
465
|
-
snippet = <<~TEST.strip
|
466
|
-
hash = {
|
467
|
-
foo: "bar",
|
468
|
-
baz: "qux",
|
469
|
-
blargh: "foz",
|
470
|
-
fizz: "buzz",
|
471
|
-
aaaaaa: "bbbbbb"
|
472
|
-
}
|
473
|
-
|
474
|
-
class << hash
|
475
|
-
def ys?; false; end
|
476
|
-
end
|
477
|
-
|
478
|
-
expect(hash).to #{prefix}_y
|
479
|
-
TEST
|
480
|
-
program =
|
481
|
-
make_plain_test_program(
|
482
|
-
snippet,
|
483
|
-
color_enabled: color_enabled
|
484
|
-
)
|
485
|
-
|
486
|
-
expected_output =
|
487
|
-
build_expected_output(
|
488
|
-
color_enabled: color_enabled,
|
489
|
-
snippet: %|expect(hash).to #{prefix}_y|,
|
490
|
-
newline_before_expectation: true,
|
491
|
-
expectation:
|
492
|
-
proc do
|
493
|
-
line do
|
494
|
-
plain " Expected "
|
495
|
-
actual %|{ foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz", aaaaaa: "bbbbbb" }|
|
496
|
-
end
|
497
|
-
|
498
|
-
line do
|
499
|
-
plain "to return a truthy result for "
|
500
|
-
expected "y?"
|
501
|
-
plain " or "
|
502
|
-
expected "ys?"
|
503
|
-
end
|
504
|
-
end
|
505
|
-
)
|
506
|
-
|
507
|
-
expect(program).to produce_output_when_run(
|
508
|
-
expected_output
|
509
|
-
).in_color(color_enabled).removing_object_ids
|
510
|
-
end
|
511
|
-
end
|
512
|
-
end
|
513
|
-
end
|
514
|
-
end
|
515
|
-
end
|
516
|
-
|
517
|
-
context "and returns true" do
|
518
|
-
context "when the inspected version of the actual value is short" do
|
519
|
-
it "produces the correct failure message when used in the negative" do
|
520
|
-
as_both_colored_and_uncolored do |color_enabled|
|
521
|
-
snippet = <<~TEST.strip
|
522
|
-
class Foo
|
523
|
-
def strong?; true; end
|
524
|
-
end
|
525
|
-
|
526
|
-
expect(Foo.new).not_to #{prefix}_strong
|
527
|
-
TEST
|
528
|
-
program =
|
529
|
-
make_plain_test_program(
|
530
|
-
snippet,
|
531
|
-
color_enabled: color_enabled
|
532
|
-
)
|
533
|
-
|
534
|
-
expected_output =
|
535
|
-
build_expected_output(
|
536
|
-
color_enabled: color_enabled,
|
537
|
-
snippet: %|expect(Foo.new).not_to #{prefix}_strong|,
|
538
|
-
expectation:
|
539
|
-
proc do
|
540
|
-
line do
|
541
|
-
plain "Expected "
|
542
|
-
actual "#<Foo>"
|
543
|
-
plain " not to return a truthy result for "
|
544
|
-
expected "strong?"
|
545
|
-
plain " or "
|
546
|
-
expected "strongs?"
|
547
|
-
plain "."
|
548
|
-
end
|
549
|
-
end
|
550
|
-
)
|
551
|
-
|
552
|
-
expect(program).to produce_output_when_run(
|
553
|
-
expected_output
|
554
|
-
).in_color(color_enabled).removing_object_ids
|
555
|
-
end
|
556
|
-
end
|
557
|
-
end
|
558
|
-
|
559
|
-
context "when the inspected version of the actual value is long" do
|
560
|
-
it "produces the correct failure message when used in the negative" do
|
561
|
-
as_both_colored_and_uncolored do |color_enabled|
|
562
|
-
snippet = <<~TEST.strip
|
563
|
-
hash = {
|
564
|
-
foo: "bar",
|
565
|
-
baz: "qux",
|
566
|
-
blargh: "foz",
|
567
|
-
fizz: "buzz",
|
568
|
-
aaaaaa: "bbbbbb"
|
569
|
-
}
|
570
|
-
|
571
|
-
class << hash
|
572
|
-
def ys?; true; end
|
573
|
-
end
|
574
|
-
|
575
|
-
expect(hash).not_to #{prefix}_y
|
576
|
-
TEST
|
577
|
-
program =
|
578
|
-
make_plain_test_program(
|
579
|
-
snippet,
|
580
|
-
color_enabled: color_enabled
|
581
|
-
)
|
582
|
-
|
583
|
-
expected_output =
|
584
|
-
build_expected_output(
|
585
|
-
color_enabled: color_enabled,
|
586
|
-
snippet: %|expect(hash).not_to #{prefix}_y|,
|
587
|
-
newline_before_expectation: true,
|
588
|
-
expectation:
|
589
|
-
proc do
|
590
|
-
line do
|
591
|
-
plain " Expected "
|
592
|
-
actual %|{ foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz", aaaaaa: "bbbbbb" }|
|
593
|
-
end
|
594
|
-
|
595
|
-
line do
|
596
|
-
plain "not to return a truthy result for "
|
597
|
-
expected "y?"
|
598
|
-
plain " or "
|
599
|
-
expected "ys?"
|
600
|
-
end
|
601
|
-
end
|
602
|
-
)
|
603
|
-
|
604
|
-
expect(program).to produce_output_when_run(
|
605
|
-
expected_output
|
606
|
-
).in_color(color_enabled).removing_object_ids
|
607
|
-
end
|
608
|
-
end
|
609
|
-
end
|
610
|
-
end
|
611
|
-
end
|
612
|
-
end
|
613
|
-
end
|
614
|
-
end
|
615
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "Integration with RSpec's #be_truthy matcher",
|
4
|
-
type: :integration do
|
5
|
-
it "produces the correct failure message when used in the positive" do
|
6
|
-
as_both_colored_and_uncolored do |color_enabled|
|
7
|
-
program =
|
8
|
-
make_plain_test_program(<<~TEST.strip, color_enabled: color_enabled)
|
9
|
-
expect(nil).to be_truthy
|
10
|
-
TEST
|
11
|
-
|
12
|
-
expected_output =
|
13
|
-
build_expected_output(
|
14
|
-
color_enabled: color_enabled,
|
15
|
-
snippet: "expect(nil).to be_truthy",
|
16
|
-
expectation:
|
17
|
-
proc do
|
18
|
-
line do
|
19
|
-
plain "Expected "
|
20
|
-
actual "nil"
|
21
|
-
plain " to be "
|
22
|
-
expected "truthy"
|
23
|
-
plain "."
|
24
|
-
end
|
25
|
-
end
|
26
|
-
)
|
27
|
-
|
28
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
29
|
-
color_enabled
|
30
|
-
)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "produces the correct failure message when used in the negative" do
|
35
|
-
as_both_colored_and_uncolored do |color_enabled|
|
36
|
-
program =
|
37
|
-
make_plain_test_program(<<~TEST.strip, color_enabled: color_enabled)
|
38
|
-
expect(true).not_to be_truthy
|
39
|
-
TEST
|
40
|
-
|
41
|
-
expected_output =
|
42
|
-
build_expected_output(
|
43
|
-
color_enabled: color_enabled,
|
44
|
-
snippet: "expect(true).not_to be_truthy",
|
45
|
-
expectation:
|
46
|
-
proc do
|
47
|
-
line do
|
48
|
-
plain "Expected "
|
49
|
-
actual "true"
|
50
|
-
plain " not to be "
|
51
|
-
expected "truthy"
|
52
|
-
plain "."
|
53
|
-
end
|
54
|
-
end
|
55
|
-
)
|
56
|
-
|
57
|
-
expect(program).to produce_output_when_run(expected_output).in_color(
|
58
|
-
color_enabled
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|