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