super_diff 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +65 -26
- data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/differs.rb +1 -1
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +5 -13
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +1 -3
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/object_inspection.rb +1 -1
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_record/operation_trees.rb +1 -1
- data/lib/super_diff/active_record.rb +7 -15
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/differs.rb +1 -1
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +3 -9
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/object_inspection.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_support/operation_trees.rb +1 -1
- data/lib/super_diff/active_support.rb +6 -11
- data/lib/super_diff/colorized_document_extensions.rb +2 -4
- data/lib/super_diff/configuration.rb +14 -8
- data/lib/super_diff/csi/color.rb +4 -4
- data/lib/super_diff/csi/colorized_document.rb +12 -16
- data/lib/super_diff/csi/document.rb +8 -19
- data/lib/super_diff/csi/eight_bit_color.rb +19 -19
- data/lib/super_diff/csi/four_bit_color.rb +82 -31
- data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
- data/lib/super_diff/csi/uncolorized_document.rb +2 -6
- data/lib/super_diff/csi.rb +10 -14
- data/lib/super_diff/diff_formatters/collection.rb +35 -41
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/defaults.rb +1 -1
- data/lib/super_diff/differs/main.rb +2 -13
- data/lib/super_diff/equality_matchers/array.rb +10 -12
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +2 -4
- data/lib/super_diff/equality_matchers/defaults.rb +1 -1
- data/lib/super_diff/equality_matchers/hash.rb +10 -12
- data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
- data/lib/super_diff/equality_matchers/primitive.rb +10 -12
- data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
- data/lib/super_diff/equality_matchers.rb +1 -1
- data/lib/super_diff/errors.rb +3 -3
- data/lib/super_diff/gem_version.rb +3 -3
- data/lib/super_diff/helpers.rb +10 -10
- data/lib/super_diff/implementation_checks.rb +2 -2
- data/lib/super_diff/line.rb +3 -3
- data/lib/super_diff/object_inspection/inspection_tree.rb +46 -60
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +2 -6
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +3 -9
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +5 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +4 -12
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +6 -23
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +8 -20
- data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
- data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
- data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
- data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
- data/lib/super_diff/object_inspection/nodes.rb +7 -7
- data/lib/super_diff/object_inspection.rb +3 -3
- data/lib/super_diff/operation_tree_builders/array.rb +12 -11
- data/lib/super_diff/operation_tree_builders/base.rb +17 -15
- data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
- data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
- data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
- data/lib/super_diff/operation_tree_builders/main.rb +4 -11
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
- data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
- data/lib/super_diff/operation_tree_builders.rb +1 -1
- data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
- data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
- data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
- data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
- data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
- data/lib/super_diff/operation_tree_flatteners.rb +3 -3
- data/lib/super_diff/operation_trees/base.rb +3 -5
- data/lib/super_diff/operation_trees/default_object.rb +1 -3
- data/lib/super_diff/operations/binary_operation.rb +2 -2
- data/lib/super_diff/operations/unary_operation.rb +1 -1
- data/lib/super_diff/rails.rb +2 -1
- data/lib/super_diff/recursion_guard.rb +5 -4
- data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
- data/lib/super_diff/rspec/differ.rb +6 -13
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
- data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
- data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
- data/lib/super_diff/rspec/differs.rb +3 -3
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -5
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
- data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
- data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
- data/lib/super_diff/rspec/monkey_patches.rb +122 -116
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +11 -16
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +2 -1
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/rspec/object_inspection.rb +1 -1
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
- data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
- data/lib/super_diff/rspec.rb +11 -13
- data/lib/super_diff/tiered_lines_elider.rb +87 -115
- data/lib/super_diff/tiered_lines_formatter.rb +5 -9
- data/lib/super_diff/version.rb +1 -1
- data/lib/super_diff.rb +4 -9
- data/spec/examples.txt +493 -485
- data/spec/integration/rails/active_record_spec.rb +3 -1
- data/spec/integration/rails/engines_spec.rb +20 -0
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
- data/spec/integration/rspec/be_matcher_spec.rb +360 -320
- data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +242 -239
- data/spec/integration/rspec/eq_matcher_spec.rb +595 -557
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +294 -286
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
- data/spec/integration/rspec/include_matcher_spec.rb +317 -215
- data/spec/integration/rspec/match_array_matcher_spec.rb +276 -273
- data/spec/integration/rspec/match_matcher_spec.rb +847 -834
- data/spec/integration/rspec/raise_error_matcher_spec.rb +468 -453
- data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
- data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
- data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
- data/spec/spec_helper.rb +17 -20
- data/spec/support/command_runner.rb +34 -57
- data/spec/support/integration/helpers.rb +35 -28
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
- data/spec/support/integration/test_programs/base.rb +12 -17
- data/spec/support/integration/test_programs/plain.rb +6 -0
- data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
- data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +30 -0
- data/spec/support/models/active_record/person.rb +6 -4
- data/spec/support/models/active_record/shipping_address.rb +9 -10
- data/spec/support/models/customer.rb +2 -4
- data/spec/support/models/player.rb +3 -6
- data/spec/support/models/shipping_address.rb +4 -13
- data/spec/support/shared_examples/active_record.rb +232 -214
- data/spec/support/shared_examples/active_support.rb +53 -51
- data/spec/support/shared_examples/elided_diffs.rb +405 -381
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +424 -388
- data/spec/support/shared_examples/key.rb +123 -0
- data/spec/support/unit/helpers.rb +1 -3
- data/spec/support/unit/matchers/match_output.rb +12 -13
- data/spec/unit/active_record/object_inspection_spec.rb +222 -206
- data/spec/unit/equality_matchers/main_spec.rb +1049 -984
- data/spec/unit/helpers_spec.rb +14 -21
- data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
- data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
- data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
- data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
- data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
- data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
- data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
- data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
- data/spec/unit/rspec/matchers/include_spec.rb +2 -2
- data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
- data/spec/unit/rspec/matchers/raise_error_spec.rb +5 -5
- data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
- data/spec/unit/rspec/object_inspection_spec.rb +349 -324
- data/spec/unit/super_diff_spec.rb +1542 -1449
- data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
- data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
- data/super_diff.gemspec +13 -12
- metadata +73 -73
- data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -1,77 +1,78 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
RSpec.describe "Integration with RSpec's #be_<predicate> matcher",
|
3
|
+
RSpec.describe "Integration with RSpec's #be_<predicate> matcher",
|
4
|
+
type: :integration do
|
4
5
|
# rubocop:disable Metrics/BlockLength
|
5
|
-
[
|
6
|
-
|
6
|
+
%w[be be_a be_an].each do |prefix|
|
7
|
+
# rubocop:enable Metrics/BlockLength
|
7
8
|
context "using #{prefix}_<predicate>" do
|
8
9
|
context "when the predicate method doesn't exist on the object" do
|
9
|
-
context "when the inspected version of the actual
|
10
|
+
context "when the inspected version of the actual value is short" do
|
10
11
|
it "produces the correct failure message" do
|
11
12
|
as_both_colored_and_uncolored do |color_enabled|
|
12
13
|
snippet = %|expect(:foo).to #{prefix}_strong|
|
13
|
-
program =
|
14
|
-
snippet,
|
15
|
-
color_enabled: color_enabled,
|
16
|
-
)
|
17
|
-
|
18
|
-
expected_output = build_expected_output(
|
19
|
-
color_enabled: color_enabled,
|
20
|
-
snippet: snippet,
|
21
|
-
expectation: proc {
|
22
|
-
line do
|
23
|
-
plain %|Expected |
|
24
|
-
actual %|:foo|
|
25
|
-
plain %| to respond to |
|
26
|
-
expected %|strong?|
|
27
|
-
plain %| or |
|
28
|
-
expected %|strongs?|
|
29
|
-
plain %|.|
|
30
|
-
end
|
31
|
-
},
|
32
|
-
)
|
14
|
+
program =
|
15
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
33
16
|
|
34
|
-
|
35
|
-
|
36
|
-
|
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)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
|
-
context "when the inspected version of the actual
|
42
|
+
context "when the inspected version of the actual value is long" do
|
42
43
|
it "produces the correct failure message" do
|
43
44
|
as_both_colored_and_uncolored do |color_enabled|
|
44
45
|
snippet = <<~TEST.strip
|
45
46
|
hash = { foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz", aaaaaa: "bbbbbb" }
|
46
47
|
expect(hash).to #{prefix}_strong
|
47
48
|
TEST
|
48
|
-
program =
|
49
|
-
snippet,
|
50
|
-
color_enabled: color_enabled,
|
51
|
-
)
|
52
|
-
|
53
|
-
expected_output = build_expected_output(
|
54
|
-
color_enabled: color_enabled,
|
55
|
-
snippet: %|expect(hash).to #{prefix}_strong|,
|
56
|
-
newline_before_expectation: true,
|
57
|
-
expectation: proc {
|
58
|
-
line do
|
59
|
-
plain %| Expected |
|
60
|
-
actual %|{ foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz", aaaaaa: "bbbbbb" }|
|
61
|
-
end
|
49
|
+
program =
|
50
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
62
51
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
71
63
|
|
72
|
-
|
73
|
-
|
74
|
-
|
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)
|
75
76
|
end
|
76
77
|
end
|
77
78
|
end
|
@@ -79,7 +80,7 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
79
80
|
|
80
81
|
context "when the predicate method exists on the object" do
|
81
82
|
context "but is private" do
|
82
|
-
context "when the inspected version of the actual
|
83
|
+
context "when the inspected version of the actual value is short" do
|
83
84
|
it "produces the correct failure message" do
|
84
85
|
as_both_colored_and_uncolored do |color_enabled|
|
85
86
|
snippet = <<~TEST.strip
|
@@ -89,36 +90,35 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
89
90
|
|
90
91
|
expect(Foo.new).to #{prefix}_strong
|
91
92
|
TEST
|
92
|
-
program =
|
93
|
-
snippet,
|
94
|
-
color_enabled: color_enabled,
|
95
|
-
)
|
93
|
+
program =
|
94
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
96
95
|
|
97
|
-
expected_output =
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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
|
+
)
|
112
113
|
|
113
|
-
expect(program).
|
114
|
-
|
115
|
-
|
116
|
-
removing_object_ids
|
114
|
+
expect(program).to produce_output_when_run(
|
115
|
+
expected_output
|
116
|
+
).in_color(color_enabled).removing_object_ids
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
context "when the inspected version of the actual
|
121
|
+
context "when the inspected version of the actual value is long" do
|
122
122
|
it "produces the correct failure message" do
|
123
123
|
as_both_colored_and_uncolored do |color_enabled|
|
124
124
|
snippet = <<~TEST.strip
|
@@ -130,34 +130,33 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
130
130
|
|
131
131
|
expect(hash).to #{prefix}_strong
|
132
132
|
TEST
|
133
|
-
program =
|
134
|
-
snippet,
|
135
|
-
color_enabled: color_enabled,
|
136
|
-
)
|
133
|
+
program =
|
134
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
137
135
|
|
138
|
-
expected_output =
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
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
147
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
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
156
|
|
157
|
-
expect(program).
|
158
|
-
|
159
|
-
|
160
|
-
removing_object_ids
|
157
|
+
expect(program).to produce_output_when_run(
|
158
|
+
expected_output
|
159
|
+
).in_color(color_enabled).removing_object_ids
|
161
160
|
end
|
162
161
|
end
|
163
162
|
end
|
@@ -166,7 +165,7 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
166
165
|
context "and is public" do
|
167
166
|
context "and returns false" do
|
168
167
|
context "but is called #true?" do
|
169
|
-
context "when the inspected version of the actual
|
168
|
+
context "when the inspected version of the actual value is short" do
|
170
169
|
it "produces the correct failure message" do
|
171
170
|
as_both_colored_and_uncolored do |color_enabled|
|
172
171
|
snippet = <<~TEST.strip
|
@@ -176,47 +175,49 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
176
175
|
|
177
176
|
expect(Foo.new).to #{prefix}_true
|
178
177
|
TEST
|
179
|
-
program =
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
expected_output = build_expected_output(
|
185
|
-
color_enabled: color_enabled,
|
186
|
-
snippet: %|expect(Foo.new).to #{prefix}_true|,
|
187
|
-
newline_before_expectation: true,
|
188
|
-
expectation: proc {
|
189
|
-
line do
|
190
|
-
plain %|Expected |
|
191
|
-
actual %|#<Foo>|
|
192
|
-
plain %| to return a truthy result for |
|
193
|
-
expected %|true?|
|
194
|
-
plain %| or |
|
195
|
-
expected %|trues?|
|
196
|
-
plain %|.|
|
197
|
-
end
|
198
|
-
|
199
|
-
newline
|
178
|
+
program =
|
179
|
+
make_plain_test_program(
|
180
|
+
snippet,
|
181
|
+
color_enabled: color_enabled
|
182
|
+
)
|
200
183
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
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
|
+
)
|
210
212
|
|
211
|
-
expect(program).
|
212
|
-
|
213
|
-
|
214
|
-
removing_object_ids
|
213
|
+
expect(program).to produce_output_when_run(
|
214
|
+
expected_output
|
215
|
+
).in_color(color_enabled).removing_object_ids
|
215
216
|
end
|
216
217
|
end
|
217
218
|
end
|
218
219
|
|
219
|
-
context "when the inspected version of the actual
|
220
|
+
context "when the inspected version of the actual value is long" do
|
220
221
|
it "produces the correct failure message" do
|
221
222
|
as_both_colored_and_uncolored do |color_enabled|
|
222
223
|
snippet = <<~TEST.strip
|
@@ -233,44 +234,46 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
233
234
|
|
234
235
|
expect(hash).to #{prefix}_true
|
235
236
|
TEST
|
236
|
-
program =
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
expected_output = build_expected_output(
|
242
|
-
color_enabled: color_enabled,
|
243
|
-
snippet: %|expect(hash).to #{prefix}_true|,
|
244
|
-
newline_before_expectation: true,
|
245
|
-
expectation: proc {
|
246
|
-
line do
|
247
|
-
plain %| Expected |
|
248
|
-
actual %|{ foo: "bar", baz: "qux", blargh: "foz", fizz: "buzz" }|
|
249
|
-
end
|
250
|
-
|
251
|
-
line do
|
252
|
-
plain %|to return a truthy result for |
|
253
|
-
expected %|true?|
|
254
|
-
plain %| or |
|
255
|
-
expected %|trues?|
|
256
|
-
end
|
257
|
-
|
258
|
-
newline
|
237
|
+
program =
|
238
|
+
make_plain_test_program(
|
239
|
+
snippet,
|
240
|
+
color_enabled: color_enabled
|
241
|
+
)
|
259
242
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
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
|
+
)
|
269
273
|
|
270
|
-
expect(program).
|
271
|
-
|
272
|
-
|
273
|
-
removing_object_ids
|
274
|
+
expect(program).to produce_output_when_run(
|
275
|
+
expected_output
|
276
|
+
).in_color(color_enabled).removing_object_ids
|
274
277
|
end
|
275
278
|
end
|
276
279
|
end
|
@@ -286,39 +289,41 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
286
289
|
|
287
290
|
expect(X.new).to #{prefix}_false
|
288
291
|
TEST
|
289
|
-
program =
|
290
|
-
|
291
|
-
|
292
|
-
|
292
|
+
program =
|
293
|
+
make_plain_test_program(
|
294
|
+
snippet,
|
295
|
+
color_enabled: color_enabled
|
296
|
+
)
|
293
297
|
|
294
|
-
expected_output =
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
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
|
+
)
|
310
316
|
|
311
|
-
expect(program).
|
312
|
-
|
313
|
-
|
314
|
-
removing_object_ids
|
317
|
+
expect(program).to produce_output_when_run(
|
318
|
+
expected_output
|
319
|
+
).in_color(color_enabled).removing_object_ids
|
315
320
|
end
|
316
321
|
end
|
317
322
|
end
|
318
323
|
|
319
324
|
context "and is called neither #true? nor #false?" do
|
320
325
|
context "and is singular" do
|
321
|
-
context "when the inspected version of the actual
|
326
|
+
context "when the inspected version of the actual value is short" do
|
322
327
|
it "produces the correct failure message" do
|
323
328
|
as_both_colored_and_uncolored do |color_enabled|
|
324
329
|
snippet = <<~TEST.strip
|
@@ -328,36 +333,38 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
328
333
|
|
329
334
|
expect(X.new).to #{prefix}_y
|
330
335
|
TEST
|
331
|
-
program =
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
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
|
356
363
|
end
|
357
364
|
end
|
358
365
|
end
|
359
366
|
|
360
|
-
context "when the inspected version of the actual
|
367
|
+
context "when the inspected version of the actual value is long" do
|
361
368
|
it "produces the correct failure message" do
|
362
369
|
as_both_colored_and_uncolored do |color_enabled|
|
363
370
|
snippet = <<~TEST.strip
|
@@ -375,41 +382,43 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
375
382
|
|
376
383
|
expect(hash).to #{prefix}_y
|
377
384
|
TEST
|
378
|
-
program =
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
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
|
406
415
|
end
|
407
416
|
end
|
408
417
|
end
|
409
418
|
end
|
410
419
|
|
411
420
|
context "and is plural" do
|
412
|
-
context "when the inspected version of the actual
|
421
|
+
context "when the inspected version of the actual value is short" do
|
413
422
|
it "produces the correct failure message" do
|
414
423
|
as_both_colored_and_uncolored do |color_enabled|
|
415
424
|
snippet = <<~TEST.strip
|
@@ -419,36 +428,38 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
419
428
|
|
420
429
|
expect(X.new).to #{prefix}_y
|
421
430
|
TEST
|
422
|
-
program =
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
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
|
447
458
|
end
|
448
459
|
end
|
449
460
|
end
|
450
461
|
|
451
|
-
context "when the inspected version of the actual
|
462
|
+
context "when the inspected version of the actual value is long" do
|
452
463
|
it "produces the correct failure message" do
|
453
464
|
as_both_colored_and_uncolored do |color_enabled|
|
454
465
|
snippet = <<~TEST.strip
|
@@ -466,34 +477,36 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
466
477
|
|
467
478
|
expect(hash).to #{prefix}_y
|
468
479
|
TEST
|
469
|
-
program =
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
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
|
497
510
|
end
|
498
511
|
end
|
499
512
|
end
|
@@ -502,7 +515,7 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
502
515
|
end
|
503
516
|
|
504
517
|
context "and returns true" do
|
505
|
-
context "when the inspected version of the actual
|
518
|
+
context "when the inspected version of the actual value is short" do
|
506
519
|
it "produces the correct failure message when used in the negative" do
|
507
520
|
as_both_colored_and_uncolored do |color_enabled|
|
508
521
|
snippet = <<~TEST.strip
|
@@ -512,36 +525,38 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
512
525
|
|
513
526
|
expect(Foo.new).not_to #{prefix}_strong
|
514
527
|
TEST
|
515
|
-
program =
|
516
|
-
|
517
|
-
|
518
|
-
|
528
|
+
program =
|
529
|
+
make_plain_test_program(
|
530
|
+
snippet,
|
531
|
+
color_enabled: color_enabled
|
532
|
+
)
|
519
533
|
|
520
|
-
expected_output =
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
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
|
+
)
|
535
551
|
|
536
|
-
expect(program).
|
537
|
-
|
538
|
-
|
539
|
-
removing_object_ids
|
552
|
+
expect(program).to produce_output_when_run(
|
553
|
+
expected_output
|
554
|
+
).in_color(color_enabled).removing_object_ids
|
540
555
|
end
|
541
556
|
end
|
542
557
|
end
|
543
558
|
|
544
|
-
context "when the inspected version of the actual
|
559
|
+
context "when the inspected version of the actual value is long" do
|
545
560
|
it "produces the correct failure message when used in the negative" do
|
546
561
|
as_both_colored_and_uncolored do |color_enabled|
|
547
562
|
snippet = <<~TEST.strip
|
@@ -559,34 +574,36 @@ RSpec.describe "Integration with RSpec's #be_<predicate> matcher", type: :integr
|
|
559
574
|
|
560
575
|
expect(hash).not_to #{prefix}_y
|
561
576
|
TEST
|
562
|
-
program =
|
563
|
-
|
564
|
-
|
565
|
-
|
577
|
+
program =
|
578
|
+
make_plain_test_program(
|
579
|
+
snippet,
|
580
|
+
color_enabled: color_enabled
|
581
|
+
)
|
566
582
|
|
567
|
-
expected_output =
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
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
|
576
594
|
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
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
|
+
)
|
585
603
|
|
586
|
-
expect(program).
|
587
|
-
|
588
|
-
|
589
|
-
removing_object_ids
|
604
|
+
expect(program).to produce_output_when_run(
|
605
|
+
expected_output
|
606
|
+
).in_color(color_enabled).removing_object_ids
|
590
607
|
end
|
591
608
|
end
|
592
609
|
end
|