super_diff 0.8.0 → 0.10.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 +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 +11 -7
- 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 +5 -9
- data/spec/examples.txt +493 -407
- 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 +27 -20
- 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 +70 -68
@@ -1,69 +1,70 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
RSpec.describe "Integration with RSpec's #have_<predicate> matcher",
|
3
|
+
RSpec.describe "Integration with RSpec's #have_<predicate> matcher",
|
4
|
+
type: :integration do
|
4
5
|
context "when the predicate method doesn't exist on the object" do
|
5
6
|
context "when the predicate method doesn't exist on the object" do
|
6
7
|
it "produces the correct failure message" do
|
7
8
|
as_both_colored_and_uncolored do |color_enabled|
|
8
|
-
snippet =
|
9
|
-
program =
|
10
|
-
snippet,
|
11
|
-
color_enabled: color_enabled,
|
12
|
-
)
|
9
|
+
snippet = "expect(:words).to have_power"
|
10
|
+
program =
|
11
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
13
12
|
|
14
|
-
expected_output =
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
13
|
+
expected_output =
|
14
|
+
build_expected_output(
|
15
|
+
color_enabled: color_enabled,
|
16
|
+
snippet: snippet,
|
17
|
+
expectation:
|
18
|
+
proc do
|
19
|
+
line do
|
20
|
+
plain "Expected "
|
21
|
+
actual ":words"
|
22
|
+
plain " to respond to "
|
23
|
+
expected "has_power?"
|
24
|
+
plain "."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
)
|
27
28
|
|
28
|
-
expect(program).
|
29
|
-
|
30
|
-
|
29
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
30
|
+
color_enabled
|
31
|
+
)
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
context "when the inspected version of the actual
|
36
|
+
context "when the inspected version of the actual value is long" do
|
36
37
|
it "produces the correct failure message" do
|
37
38
|
as_both_colored_and_uncolored do |color_enabled|
|
38
39
|
snippet = <<~TEST.strip
|
39
40
|
hash = { a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }
|
40
41
|
expect(hash).to have_mapping
|
41
42
|
TEST
|
42
|
-
program =
|
43
|
-
snippet,
|
44
|
-
color_enabled: color_enabled,
|
45
|
-
)
|
43
|
+
program =
|
44
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
46
45
|
|
47
|
-
expected_output =
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
expected_output =
|
47
|
+
build_expected_output(
|
48
|
+
color_enabled: color_enabled,
|
49
|
+
snippet: "expect(hash).to have_mapping",
|
50
|
+
newline_before_expectation: true,
|
51
|
+
expectation:
|
52
|
+
proc do
|
53
|
+
line do
|
54
|
+
plain " Expected "
|
55
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
line do
|
59
|
+
plain "to respond to "
|
60
|
+
expected "has_mapping?"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
)
|
63
64
|
|
64
|
-
expect(program).
|
65
|
-
|
66
|
-
|
65
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
66
|
+
color_enabled
|
67
|
+
)
|
67
68
|
end
|
68
69
|
end
|
69
70
|
end
|
@@ -71,7 +72,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
71
72
|
|
72
73
|
context "when the predicate method exists on the object" do
|
73
74
|
context "but is private" do
|
74
|
-
context "when the inspected version of the actual
|
75
|
+
context "when the inspected version of the actual value is short" do
|
75
76
|
it "produces the correct failure message" do
|
76
77
|
as_both_colored_and_uncolored do |color_enabled|
|
77
78
|
snippet = <<~TEST.strip
|
@@ -81,34 +82,33 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
81
82
|
|
82
83
|
expect(Robot.new).to have_arms
|
83
84
|
TEST
|
84
|
-
program =
|
85
|
-
snippet,
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
85
|
+
program =
|
86
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
87
|
+
|
88
|
+
expected_output =
|
89
|
+
build_expected_output(
|
90
|
+
color_enabled: color_enabled,
|
91
|
+
snippet: "expect(Robot.new).to have_arms",
|
92
|
+
expectation:
|
93
|
+
proc do
|
94
|
+
line do
|
95
|
+
plain "Expected "
|
96
|
+
actual "#<Robot>"
|
97
|
+
plain " to have a public method "
|
98
|
+
expected "has_arms?"
|
99
|
+
plain "."
|
100
|
+
end
|
101
|
+
end
|
102
|
+
)
|
102
103
|
|
103
|
-
expect(program).
|
104
|
-
|
105
|
-
|
106
|
-
removing_object_ids
|
104
|
+
expect(program).to produce_output_when_run(
|
105
|
+
expected_output
|
106
|
+
).in_color(color_enabled).removing_object_ids
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
context "when the inspected version of the actual
|
111
|
+
context "when the inspected version of the actual value is long" do
|
112
112
|
it "produces the correct failure message" do
|
113
113
|
as_both_colored_and_uncolored do |color_enabled|
|
114
114
|
snippet = <<~TEST.strip
|
@@ -120,32 +120,31 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
120
120
|
|
121
121
|
expect(hash).to have_mapping
|
122
122
|
TEST
|
123
|
-
program =
|
124
|
-
snippet,
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
123
|
+
program =
|
124
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
125
|
+
|
126
|
+
expected_output =
|
127
|
+
build_expected_output(
|
128
|
+
color_enabled: color_enabled,
|
129
|
+
snippet: "expect(hash).to have_mapping",
|
130
|
+
newline_before_expectation: true,
|
131
|
+
expectation:
|
132
|
+
proc do
|
133
|
+
line do
|
134
|
+
plain " Expected "
|
135
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
136
|
+
end
|
137
137
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
138
|
+
line do
|
139
|
+
plain "to have a public method "
|
140
|
+
expected "has_mapping?"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
)
|
144
144
|
|
145
|
-
expect(program).
|
146
|
-
|
147
|
-
|
148
|
-
removing_object_ids
|
145
|
+
expect(program).to produce_output_when_run(
|
146
|
+
expected_output
|
147
|
+
).in_color(color_enabled).removing_object_ids
|
149
148
|
end
|
150
149
|
end
|
151
150
|
end
|
@@ -154,7 +153,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
154
153
|
context "and is public" do
|
155
154
|
context "and returns false" do
|
156
155
|
context "and takes arguments" do
|
157
|
-
context "when the inspected version of the actual
|
156
|
+
context "when the inspected version of the actual value is short" do
|
158
157
|
it "produces the correct failure message" do
|
159
158
|
as_both_colored_and_uncolored do |color_enabled|
|
160
159
|
snippet = <<~TEST.strip
|
@@ -164,34 +163,33 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
164
163
|
|
165
164
|
expect(Drink.new).to have_ingredients(:vodka)
|
166
165
|
TEST
|
167
|
-
program =
|
168
|
-
snippet,
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
expect(program).
|
187
|
-
|
188
|
-
|
189
|
-
removing_object_ids
|
166
|
+
program =
|
167
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
168
|
+
|
169
|
+
expected_output =
|
170
|
+
build_expected_output(
|
171
|
+
color_enabled: color_enabled,
|
172
|
+
snippet: "expect(Drink.new).to have_ingredients(:vodka)",
|
173
|
+
expectation:
|
174
|
+
proc do
|
175
|
+
line do
|
176
|
+
plain "Expected "
|
177
|
+
actual "#<Drink>"
|
178
|
+
plain " to return a truthy result for "
|
179
|
+
expected "has_ingredients?(:vodka)"
|
180
|
+
plain "."
|
181
|
+
end
|
182
|
+
end
|
183
|
+
)
|
184
|
+
|
185
|
+
expect(program).to produce_output_when_run(
|
186
|
+
expected_output
|
187
|
+
).in_color(color_enabled).removing_object_ids
|
190
188
|
end
|
191
189
|
end
|
192
190
|
end
|
193
191
|
|
194
|
-
context "when the inspected version of the actual
|
192
|
+
context "when the inspected version of the actual value is long" do
|
195
193
|
it "produces the correct failure message" do
|
196
194
|
as_both_colored_and_uncolored do |color_enabled|
|
197
195
|
snippet = <<~TEST.strip
|
@@ -203,39 +201,39 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
203
201
|
|
204
202
|
expect(hash).to have_contents("keys", "upon", "keys")
|
205
203
|
TEST
|
206
|
-
program =
|
207
|
-
snippet,
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
204
|
+
program =
|
205
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
206
|
+
|
207
|
+
expected_output =
|
208
|
+
build_expected_output(
|
209
|
+
color_enabled: color_enabled,
|
210
|
+
snippet:
|
211
|
+
%|expect(hash).to have_contents("keys", "upon", "keys")|,
|
212
|
+
newline_before_expectation: true,
|
213
|
+
expectation:
|
214
|
+
proc do
|
215
|
+
line do
|
216
|
+
plain " Expected "
|
217
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
218
|
+
end
|
219
|
+
|
220
|
+
line do
|
221
|
+
plain "to return a truthy result for "
|
222
|
+
expected %|has_contents?("keys", "upon", "keys")|
|
223
|
+
end
|
224
|
+
end
|
225
|
+
)
|
226
|
+
|
227
|
+
expect(program).to produce_output_when_run(
|
228
|
+
expected_output
|
229
|
+
).in_color(color_enabled).removing_object_ids
|
232
230
|
end
|
233
231
|
end
|
234
232
|
end
|
235
233
|
end
|
236
234
|
|
237
235
|
context "and takes no arguments" do
|
238
|
-
context "when the inspected version of the actual
|
236
|
+
context "when the inspected version of the actual value is short" do
|
239
237
|
it "produces the correct failure message" do
|
240
238
|
as_both_colored_and_uncolored do |color_enabled|
|
241
239
|
snippet = <<~TEST.strip
|
@@ -245,34 +243,33 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
245
243
|
|
246
244
|
expect(Robot.new).to have_arms
|
247
245
|
TEST
|
248
|
-
program =
|
249
|
-
snippet,
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
expect(program).
|
268
|
-
|
269
|
-
|
270
|
-
removing_object_ids
|
246
|
+
program =
|
247
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
248
|
+
|
249
|
+
expected_output =
|
250
|
+
build_expected_output(
|
251
|
+
color_enabled: color_enabled,
|
252
|
+
snippet: "expect(Robot.new).to have_arms",
|
253
|
+
expectation:
|
254
|
+
proc do
|
255
|
+
line do
|
256
|
+
plain "Expected "
|
257
|
+
actual "#<Robot>"
|
258
|
+
plain " to return a truthy result for "
|
259
|
+
expected "has_arms?"
|
260
|
+
plain "."
|
261
|
+
end
|
262
|
+
end
|
263
|
+
)
|
264
|
+
|
265
|
+
expect(program).to produce_output_when_run(
|
266
|
+
expected_output
|
267
|
+
).in_color(color_enabled).removing_object_ids
|
271
268
|
end
|
272
269
|
end
|
273
270
|
end
|
274
271
|
|
275
|
-
context "when the inspected version of the actual
|
272
|
+
context "when the inspected version of the actual value is long" do
|
276
273
|
it "produces the correct failure message" do
|
277
274
|
as_both_colored_and_uncolored do |color_enabled|
|
278
275
|
snippet = <<~TEST.strip
|
@@ -284,32 +281,31 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
284
281
|
|
285
282
|
expect(hash).to have_mapping
|
286
283
|
TEST
|
287
|
-
program =
|
288
|
-
snippet,
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
expect(program).
|
310
|
-
|
311
|
-
|
312
|
-
removing_object_ids
|
284
|
+
program =
|
285
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
286
|
+
|
287
|
+
expected_output =
|
288
|
+
build_expected_output(
|
289
|
+
color_enabled: color_enabled,
|
290
|
+
snippet: "expect(hash).to have_mapping",
|
291
|
+
newline_before_expectation: true,
|
292
|
+
expectation:
|
293
|
+
proc do
|
294
|
+
line do
|
295
|
+
plain " Expected "
|
296
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
297
|
+
end
|
298
|
+
|
299
|
+
line do
|
300
|
+
plain "to return a truthy result for "
|
301
|
+
expected "has_mapping?"
|
302
|
+
end
|
303
|
+
end
|
304
|
+
)
|
305
|
+
|
306
|
+
expect(program).to produce_output_when_run(
|
307
|
+
expected_output
|
308
|
+
).in_color(color_enabled).removing_object_ids
|
313
309
|
end
|
314
310
|
end
|
315
311
|
end
|
@@ -318,7 +314,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
318
314
|
|
319
315
|
context "and returns true" do
|
320
316
|
context "and takes arguments" do
|
321
|
-
context "when the inspected version of the actual
|
317
|
+
context "when the inspected version of the actual value is short" do
|
322
318
|
it "produces the correct failure message" do
|
323
319
|
as_both_colored_and_uncolored do |color_enabled|
|
324
320
|
snippet = <<~TEST.strip
|
@@ -328,34 +324,34 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
328
324
|
|
329
325
|
expect(Drink.new).not_to have_ingredients(:vodka)
|
330
326
|
TEST
|
331
|
-
program =
|
332
|
-
snippet,
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
327
|
+
program =
|
328
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
329
|
+
|
330
|
+
expected_output =
|
331
|
+
build_expected_output(
|
332
|
+
color_enabled: color_enabled,
|
333
|
+
snippet:
|
334
|
+
"expect(Drink.new).not_to have_ingredients(:vodka)",
|
335
|
+
expectation:
|
336
|
+
proc do
|
337
|
+
line do
|
338
|
+
plain "Expected "
|
339
|
+
actual "#<Drink>"
|
340
|
+
plain " not to return a truthy result for "
|
341
|
+
expected "has_ingredients?(:vodka)"
|
342
|
+
plain "."
|
343
|
+
end
|
344
|
+
end
|
345
|
+
)
|
346
|
+
|
347
|
+
expect(program).to produce_output_when_run(
|
348
|
+
expected_output
|
349
|
+
).in_color(color_enabled).removing_object_ids
|
354
350
|
end
|
355
351
|
end
|
356
352
|
end
|
357
353
|
|
358
|
-
context "when the inspected version of the actual
|
354
|
+
context "when the inspected version of the actual value is long" do
|
359
355
|
it "produces the correct failure message" do
|
360
356
|
as_both_colored_and_uncolored do |color_enabled|
|
361
357
|
snippet = <<~TEST.strip
|
@@ -367,39 +363,39 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
367
363
|
|
368
364
|
expect(hash).not_to have_contents("keys", "upon", "keys")
|
369
365
|
TEST
|
370
|
-
program =
|
371
|
-
snippet,
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
366
|
+
program =
|
367
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
368
|
+
|
369
|
+
expected_output =
|
370
|
+
build_expected_output(
|
371
|
+
color_enabled: color_enabled,
|
372
|
+
snippet:
|
373
|
+
%|expect(hash).not_to have_contents("keys", "upon", "keys")|,
|
374
|
+
newline_before_expectation: true,
|
375
|
+
expectation:
|
376
|
+
proc do
|
377
|
+
line do
|
378
|
+
plain " Expected "
|
379
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
380
|
+
end
|
381
|
+
|
382
|
+
line do
|
383
|
+
plain "not to return a truthy result for "
|
384
|
+
expected %|has_contents?("keys", "upon", "keys")|
|
385
|
+
end
|
386
|
+
end
|
387
|
+
)
|
388
|
+
|
389
|
+
expect(program).to produce_output_when_run(
|
390
|
+
expected_output
|
391
|
+
).in_color(color_enabled).removing_object_ids
|
396
392
|
end
|
397
393
|
end
|
398
394
|
end
|
399
395
|
end
|
400
396
|
|
401
397
|
context "and takes no arguments" do
|
402
|
-
context "when the inspected version of the actual
|
398
|
+
context "when the inspected version of the actual value is short" do
|
403
399
|
it "produces the correct failure message when used in the negative" do
|
404
400
|
as_both_colored_and_uncolored do |color_enabled|
|
405
401
|
snippet = <<~TEST.strip
|
@@ -409,34 +405,33 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
409
405
|
|
410
406
|
expect(Robot.new).not_to have_arms
|
411
407
|
TEST
|
412
|
-
program =
|
413
|
-
snippet,
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
expect(program).
|
432
|
-
|
433
|
-
|
434
|
-
removing_object_ids
|
408
|
+
program =
|
409
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
410
|
+
|
411
|
+
expected_output =
|
412
|
+
build_expected_output(
|
413
|
+
color_enabled: color_enabled,
|
414
|
+
snippet: "expect(Robot.new).not_to have_arms",
|
415
|
+
expectation:
|
416
|
+
proc do
|
417
|
+
line do
|
418
|
+
plain "Expected "
|
419
|
+
actual "#<Robot>"
|
420
|
+
plain " not to return a truthy result for "
|
421
|
+
expected "has_arms?"
|
422
|
+
plain "."
|
423
|
+
end
|
424
|
+
end
|
425
|
+
)
|
426
|
+
|
427
|
+
expect(program).to produce_output_when_run(
|
428
|
+
expected_output
|
429
|
+
).in_color(color_enabled).removing_object_ids
|
435
430
|
end
|
436
431
|
end
|
437
432
|
end
|
438
433
|
|
439
|
-
context "when the inspected version of the actual
|
434
|
+
context "when the inspected version of the actual value is long" do
|
440
435
|
it "produces the correct failure message when used in the negative" do
|
441
436
|
as_both_colored_and_uncolored do |color_enabled|
|
442
437
|
snippet = <<~TEST.strip
|
@@ -448,32 +443,31 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
448
443
|
|
449
444
|
expect(hash).not_to have_mapping
|
450
445
|
TEST
|
451
|
-
program =
|
452
|
-
snippet,
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
expect(program).
|
474
|
-
|
475
|
-
|
476
|
-
removing_object_ids
|
446
|
+
program =
|
447
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
448
|
+
|
449
|
+
expected_output =
|
450
|
+
build_expected_output(
|
451
|
+
color_enabled: color_enabled,
|
452
|
+
snippet: "expect(hash).not_to have_mapping",
|
453
|
+
newline_before_expectation: true,
|
454
|
+
expectation:
|
455
|
+
proc do
|
456
|
+
line do
|
457
|
+
plain " Expected "
|
458
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
459
|
+
end
|
460
|
+
|
461
|
+
line do
|
462
|
+
plain "not to return a truthy result for "
|
463
|
+
expected "has_mapping?"
|
464
|
+
end
|
465
|
+
end
|
466
|
+
)
|
467
|
+
|
468
|
+
expect(program).to produce_output_when_run(
|
469
|
+
expected_output
|
470
|
+
).in_color(color_enabled).removing_object_ids
|
477
471
|
end
|
478
472
|
end
|
479
473
|
end
|