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
@@ -9,26 +9,27 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
9
9
  snippet = <<~TEST.strip
10
10
  expect(:anything).to fail_with_indented_multiline_failure_message
11
11
  TEST
12
- program = make_plain_test_program(
13
- snippet,
14
- color_enabled: color_enabled,
15
- )
12
+ program =
13
+ make_plain_test_program(snippet, color_enabled: color_enabled)
16
14
 
17
- expected_output = build_expected_output(
18
- color_enabled: color_enabled,
19
- snippet: %|expect(:anything).to fail_with_indented_multiline_failure_message|,
20
- newline_before_expectation: true,
21
- expectation: proc {
22
- red_line "This is a message that spans multiple lines."
23
- red_line "Here is the next line."
24
- plain_line " This part is indented, for whatever reason. It just kinda keeps"
25
- plain_line " going until we finish saying whatever it is we want to say."
26
- },
27
- )
15
+ expected_output =
16
+ build_expected_output(
17
+ color_enabled: color_enabled,
18
+ snippet:
19
+ "expect(:anything).to fail_with_indented_multiline_failure_message",
20
+ newline_before_expectation: true,
21
+ expectation:
22
+ proc do
23
+ red_line "This is a message that spans multiple lines."
24
+ red_line "Here is the next line."
25
+ plain_line " This part is indented, for whatever reason. It just kinda keeps"
26
+ plain_line " going until we finish saying whatever it is we want to say."
27
+ end
28
+ )
28
29
 
29
- expect(program).
30
- to produce_output_when_run(expected_output).
31
- in_color(color_enabled)
30
+ expect(program).to produce_output_when_run(
31
+ expected_output
32
+ ).in_color(color_enabled)
32
33
  end
33
34
  end
34
35
  end
@@ -40,25 +41,26 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
40
41
  snippet = <<~TEST.strip
41
42
  expect(:anything).to fail_with_paragraphed_failure_message
42
43
  TEST
43
- program = make_plain_test_program(
44
- snippet,
45
- color_enabled: color_enabled,
46
- )
47
-
48
- expected_output = build_expected_output(
49
- color_enabled: color_enabled,
50
- snippet: %|expect(:anything).to fail_with_paragraphed_failure_message|,
51
- newline_before_expectation: true,
52
- expectation: proc {
53
- red_line "This is a message that spans multiple paragraphs."
54
- newline
55
- plain_line "Here is the next paragraph."
56
- },
57
- )
58
-
59
- expect(program).
60
- to produce_output_when_run(expected_output).
61
- in_color(color_enabled)
44
+ program =
45
+ make_plain_test_program(snippet, color_enabled: color_enabled)
46
+
47
+ expected_output =
48
+ build_expected_output(
49
+ color_enabled: color_enabled,
50
+ snippet:
51
+ "expect(:anything).to fail_with_paragraphed_failure_message",
52
+ newline_before_expectation: true,
53
+ expectation:
54
+ proc do
55
+ red_line "This is a message that spans multiple paragraphs."
56
+ newline
57
+ plain_line "Here is the next paragraph."
58
+ end
59
+ )
60
+
61
+ expect(program).to produce_output_when_run(
62
+ expected_output
63
+ ).in_color(color_enabled)
62
64
  end
63
65
  end
64
66
  end
@@ -69,24 +71,25 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
69
71
  snippet = <<~TEST.strip
70
72
  expect(:anything).to fail_with_non_indented_multiline_failure_message
71
73
  TEST
72
- program = make_plain_test_program(
73
- snippet,
74
- color_enabled: color_enabled,
75
- )
76
-
77
- expected_output = build_expected_output(
78
- color_enabled: color_enabled,
79
- snippet: %|expect(:anything).to fail_with_non_indented_multiline_failure_message|,
80
- newline_before_expectation: true,
81
- expectation: proc {
82
- red_line "This is a message that spans multiple lines."
83
- red_line "Here is the next line."
84
- },
85
- )
86
-
87
- expect(program).
88
- to produce_output_when_run(expected_output).
89
- in_color(color_enabled)
74
+ program =
75
+ make_plain_test_program(snippet, color_enabled: color_enabled)
76
+
77
+ expected_output =
78
+ build_expected_output(
79
+ color_enabled: color_enabled,
80
+ snippet:
81
+ "expect(:anything).to fail_with_non_indented_multiline_failure_message",
82
+ newline_before_expectation: true,
83
+ expectation:
84
+ proc do
85
+ red_line "This is a message that spans multiple lines."
86
+ red_line "Here is the next line."
87
+ end
88
+ )
89
+
90
+ expect(program).to produce_output_when_run(
91
+ expected_output
92
+ ).in_color(color_enabled)
90
93
  end
91
94
  end
92
95
  end
@@ -99,22 +102,21 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
99
102
  snippet = <<~TEST.strip
100
103
  expect(:anything).to fail_with_singleline_failure_message
101
104
  TEST
102
- program = make_plain_test_program(
103
- snippet,
104
- color_enabled: color_enabled,
105
- )
105
+ program =
106
+ make_plain_test_program(snippet, color_enabled: color_enabled)
106
107
 
107
- expected_output = build_expected_output(
108
- color_enabled: color_enabled,
109
- snippet: %|expect(:anything).to fail_with_singleline_failure_message|,
110
- expectation: proc {
111
- red_line "This is a message that spans only one line."
112
- }
113
- )
108
+ expected_output =
109
+ build_expected_output(
110
+ color_enabled: color_enabled,
111
+ snippet:
112
+ "expect(:anything).to fail_with_singleline_failure_message",
113
+ expectation:
114
+ proc { red_line "This is a message that spans only one line." }
115
+ )
114
116
 
115
- expect(program).
116
- to produce_output_when_run(expected_output).
117
- in_color(color_enabled)
117
+ expect(program).to produce_output_when_run(expected_output).in_color(
118
+ color_enabled
119
+ )
118
120
  end
119
121
  end
120
122
  end
@@ -128,26 +130,27 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
128
130
  snippet = <<~TEST.strip
129
131
  expect(:anything).not_to pass_with_indented_multiline_failure_message
130
132
  TEST
131
- program = make_plain_test_program(
132
- snippet,
133
- color_enabled: color_enabled,
134
- )
133
+ program =
134
+ make_plain_test_program(snippet, color_enabled: color_enabled)
135
135
 
136
- expected_output = build_expected_output(
137
- color_enabled: color_enabled,
138
- snippet: %|expect(:anything).not_to pass_with_indented_multiline_failure_message|,
139
- newline_before_expectation: true,
140
- expectation: proc {
141
- red_line "This is a message that spans multiple lines."
142
- red_line "Here is the next line."
143
- plain_line " This part is indented, for whatever reason. It just kinda keeps"
144
- plain_line " going until we finish saying whatever it is we want to say."
145
- },
146
- )
136
+ expected_output =
137
+ build_expected_output(
138
+ color_enabled: color_enabled,
139
+ snippet:
140
+ "expect(:anything).not_to pass_with_indented_multiline_failure_message",
141
+ newline_before_expectation: true,
142
+ expectation:
143
+ proc do
144
+ red_line "This is a message that spans multiple lines."
145
+ red_line "Here is the next line."
146
+ plain_line " This part is indented, for whatever reason. It just kinda keeps"
147
+ plain_line " going until we finish saying whatever it is we want to say."
148
+ end
149
+ )
147
150
 
148
- expect(program).
149
- to produce_output_when_run(expected_output).
150
- in_color(color_enabled)
151
+ expect(program).to produce_output_when_run(
152
+ expected_output
153
+ ).in_color(color_enabled)
151
154
  end
152
155
  end
153
156
  end
@@ -159,25 +162,26 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
159
162
  snippet = <<~TEST.strip
160
163
  expect(:anything).not_to pass_with_paragraphed_failure_message
161
164
  TEST
162
- program = make_plain_test_program(
163
- snippet,
164
- color_enabled: color_enabled,
165
- )
166
-
167
- expected_output = build_expected_output(
168
- color_enabled: color_enabled,
169
- snippet: %|expect(:anything).not_to pass_with_paragraphed_failure_message|,
170
- newline_before_expectation: true,
171
- expectation: proc {
172
- red_line "This is a message that spans multiple paragraphs."
173
- newline
174
- plain_line "Here is the next paragraph."
175
- },
176
- )
177
-
178
- expect(program).
179
- to produce_output_when_run(expected_output).
180
- in_color(color_enabled)
165
+ program =
166
+ make_plain_test_program(snippet, color_enabled: color_enabled)
167
+
168
+ expected_output =
169
+ build_expected_output(
170
+ color_enabled: color_enabled,
171
+ snippet:
172
+ "expect(:anything).not_to pass_with_paragraphed_failure_message",
173
+ newline_before_expectation: true,
174
+ expectation:
175
+ proc do
176
+ red_line "This is a message that spans multiple paragraphs."
177
+ newline
178
+ plain_line "Here is the next paragraph."
179
+ end
180
+ )
181
+
182
+ expect(program).to produce_output_when_run(
183
+ expected_output
184
+ ).in_color(color_enabled)
181
185
  end
182
186
  end
183
187
  end
@@ -188,24 +192,25 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
188
192
  snippet = <<~TEST.strip
189
193
  expect(:anything).not_to pass_with_non_indented_multiline_failure_message
190
194
  TEST
191
- program = make_plain_test_program(
192
- snippet,
193
- color_enabled: color_enabled,
194
- )
195
-
196
- expected_output = build_expected_output(
197
- color_enabled: color_enabled,
198
- snippet: %|expect(:anything).not_to pass_with_non_indented_multiline_failure_message|,
199
- newline_before_expectation: true,
200
- expectation: proc {
201
- red_line "This is a message that spans multiple lines."
202
- red_line "Here is the next line."
203
- }
204
- )
205
-
206
- expect(program).
207
- to produce_output_when_run(expected_output).
208
- in_color(color_enabled)
195
+ program =
196
+ make_plain_test_program(snippet, color_enabled: color_enabled)
197
+
198
+ expected_output =
199
+ build_expected_output(
200
+ color_enabled: color_enabled,
201
+ snippet:
202
+ "expect(:anything).not_to pass_with_non_indented_multiline_failure_message",
203
+ newline_before_expectation: true,
204
+ expectation:
205
+ proc do
206
+ red_line "This is a message that spans multiple lines."
207
+ red_line "Here is the next line."
208
+ end
209
+ )
210
+
211
+ expect(program).to produce_output_when_run(
212
+ expected_output
213
+ ).in_color(color_enabled)
209
214
  end
210
215
  end
211
216
  end
@@ -218,22 +223,21 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
218
223
  snippet = <<~TEST.strip
219
224
  expect(:anything).not_to pass_with_singleline_failure_message
220
225
  TEST
221
- program = make_plain_test_program(
222
- snippet,
223
- color_enabled: color_enabled,
224
- )
226
+ program =
227
+ make_plain_test_program(snippet, color_enabled: color_enabled)
225
228
 
226
- expected_output = build_expected_output(
227
- color_enabled: color_enabled,
228
- snippet: %|expect(:anything).not_to pass_with_singleline_failure_message|,
229
- expectation: proc {
230
- red_line "This is a message that spans only one line."
231
- },
232
- )
229
+ expected_output =
230
+ build_expected_output(
231
+ color_enabled: color_enabled,
232
+ snippet:
233
+ "expect(:anything).not_to pass_with_singleline_failure_message",
234
+ expectation:
235
+ proc { red_line "This is a message that spans only one line." }
236
+ )
233
237
 
234
- expect(program).
235
- to produce_output_when_run(expected_output).
236
- in_color(color_enabled)
238
+ expect(program).to produce_output_when_run(expected_output).in_color(
239
+ color_enabled
240
+ )
237
241
  end
238
242
  end
239
243
  end
@@ -1,6 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
- RSpec.describe "Integration with RSpec and unhandled errors", type: :integration do
3
+ RSpec.describe "Integration with RSpec and unhandled errors",
4
+ type: :integration do
4
5
  context "when a random exception occurs" do
5
6
  context "and the message spans multiple lines" do
6
7
  it "highlights the first line in red, and then leaves the rest of the message alone" do
@@ -8,29 +9,29 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
8
9
  snippet = <<~TEST.strip
9
10
  raise "Some kind of error or whatever\\n\\nThis is another line"
10
11
  TEST
11
- program = make_plain_test_program(
12
- snippet,
13
- color_enabled: color_enabled,
12
+ program =
13
+ make_plain_test_program(snippet, color_enabled: color_enabled)
14
+
15
+ expected_output =
16
+ build_expected_output(
17
+ color_enabled: color_enabled,
18
+ snippet: snippet,
19
+ newline_before_expectation: true,
20
+ indentation: 5,
21
+ expectation:
22
+ proc do
23
+ red_line "RuntimeError:"
24
+ indent by: 2 do
25
+ red_line "Some kind of error or whatever"
26
+ newline
27
+ plain_line "This is another line"
28
+ end
29
+ end
30
+ )
31
+
32
+ expect(program).to produce_output_when_run(expected_output).in_color(
33
+ color_enabled
14
34
  )
15
-
16
- expected_output = build_expected_output(
17
- color_enabled: color_enabled,
18
- snippet: snippet,
19
- newline_before_expectation: true,
20
- indentation: 5,
21
- expectation: proc {
22
- red_line "RuntimeError:"
23
- indent by: 2 do
24
- red_line "Some kind of error or whatever"
25
- newline
26
- plain_line "This is another line"
27
- end
28
- },
29
- )
30
-
31
- expect(program).
32
- to produce_output_when_run(expected_output).
33
- in_color(color_enabled)
34
35
  end
35
36
  end
36
37
  end
@@ -41,27 +42,27 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
41
42
  snippet = <<~TEST.strip
42
43
  raise "Some kind of error or whatever"
43
44
  TEST
44
- program = make_plain_test_program(
45
- snippet,
46
- color_enabled: color_enabled,
45
+ program =
46
+ make_plain_test_program(snippet, color_enabled: color_enabled)
47
+
48
+ expected_output =
49
+ build_expected_output(
50
+ color_enabled: color_enabled,
51
+ snippet: snippet,
52
+ newline_before_expectation: true,
53
+ indentation: 5,
54
+ expectation:
55
+ proc do
56
+ red_line "RuntimeError:"
57
+ indent by: 2 do
58
+ red_line "Some kind of error or whatever"
59
+ end
60
+ end
61
+ )
62
+
63
+ expect(program).to produce_output_when_run(expected_output).in_color(
64
+ color_enabled
47
65
  )
48
-
49
- expected_output = build_expected_output(
50
- color_enabled: color_enabled,
51
- snippet: snippet,
52
- newline_before_expectation: true,
53
- indentation: 5,
54
- expectation: proc {
55
- red_line "RuntimeError:"
56
- indent by: 2 do
57
- red_line "Some kind of error or whatever"
58
- end
59
- },
60
- )
61
-
62
- expect(program).
63
- to produce_output_when_run(expected_output).
64
- in_color(color_enabled)
65
66
  end
66
67
  end
67
68
  end
@@ -85,61 +86,64 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
85
86
  end
86
87
  CODE
87
88
 
88
- program = make_plain_test_program(
89
- code,
90
- color_enabled: color_enabled,
91
- preserve_as_whole_file: true,
92
- )
89
+ program =
90
+ make_plain_test_program(
91
+ code,
92
+ color_enabled: color_enabled,
93
+ preserve_as_whole_file: true
94
+ )
93
95
 
94
- expected_output1 = colored(color_enabled: color_enabled) do
95
- indent by: 5 do
96
- line do
97
- plain "1.1) "
98
- bold "Failure/Error: "
99
- plain snippet
100
- end
96
+ expected_output1 =
97
+ colored(color_enabled: color_enabled) do
98
+ indent by: 5 do
99
+ line do
100
+ plain "1.1) "
101
+ bold "Failure/Error: "
102
+ plain snippet
103
+ end
101
104
 
102
- newline
105
+ newline
103
106
 
104
- indent by: 5 do
105
- red_line "RuntimeError:"
106
- indent by: 2 do
107
- red_line "Some kind of error or whatever"
108
- newline
109
- line "This is another line"
107
+ indent by: 5 do
108
+ red_line "RuntimeError:"
109
+ indent by: 2 do
110
+ red_line "Some kind of error or whatever"
111
+ newline
112
+ line "This is another line"
113
+ end
110
114
  end
111
115
  end
112
116
  end
113
- end
114
117
 
115
- expected_output2 = colored(color_enabled: color_enabled) do
116
- indent by: 5 do
117
- line do
118
- plain "1.2) "
119
- bold "Failure/Error: "
120
- plain snippet
121
- end
118
+ expected_output2 =
119
+ colored(color_enabled: color_enabled) do
120
+ indent by: 5 do
121
+ line do
122
+ plain "1.2) "
123
+ bold "Failure/Error: "
124
+ plain snippet
125
+ end
122
126
 
123
- newline
127
+ newline
124
128
 
125
- indent by: 5 do
126
- red_line "RuntimeError:"
127
- indent by: 2 do
128
- red_line "Some kind of error or whatever"
129
- newline
130
- line "This is another line"
129
+ indent by: 5 do
130
+ red_line "RuntimeError:"
131
+ indent by: 2 do
132
+ red_line "Some kind of error or whatever"
133
+ newline
134
+ line "This is another line"
135
+ end
131
136
  end
132
137
  end
133
138
  end
134
- end
135
139
 
136
- expect(program).
137
- to produce_output_when_run(expected_output1).
138
- in_color(color_enabled)
140
+ expect(program).to produce_output_when_run(expected_output1).in_color(
141
+ color_enabled
142
+ )
139
143
 
140
- expect(program).
141
- to produce_output_when_run(expected_output2).
142
- in_color(color_enabled)
144
+ expect(program).to produce_output_when_run(expected_output2).in_color(
145
+ color_enabled
146
+ )
143
147
  end
144
148
  end
145
149
  end
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,15 @@
1
1
  require "pp"
2
2
 
3
- begin
4
- require "pry-byebug"
5
- rescue LoadError
6
- end
3
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.2")
4
+ begin
5
+ require "pry-byebug"
6
+ rescue LoadError
7
+ end
7
8
 
8
- begin
9
- require "pry-nav"
10
- rescue LoadError
9
+ begin
10
+ require "pry-nav"
11
+ rescue LoadError
12
+ end
11
13
  end
12
14
 
13
15
  require "climate_control"
@@ -27,20 +29,19 @@ begin
27
29
 
28
30
  ActiveRecord::Base.establish_connection(
29
31
  adapter: "sqlite3",
30
- database: ":memory:",
32
+ database: ":memory:"
31
33
  )
32
34
  rescue LoadError
33
35
  active_record_available = false
34
36
  end
35
37
 
36
- Dir.glob(File.expand_path("support/**/*.rb", __dir__)).
37
- sort.
38
- reject do |file|
38
+ Dir
39
+ .glob(File.expand_path("support/**/*.rb", __dir__))
40
+ .sort
41
+ .reject do |file|
39
42
  file.include?("/models/active_record/") && !active_record_available
40
- end.
41
- each do |file|
42
- require file
43
43
  end
44
+ .each { |file| require file }
44
45
 
45
46
  RSpec.configure do |config|
46
47
  config.include(SuperDiff::UnitTests, type: :unit)
@@ -61,18 +62,14 @@ RSpec.configure do |config|
61
62
  config.disable_monkey_patching!
62
63
  config.warnings = true
63
64
 
64
- if !["true", "1"].include?(ENV["CI"])
65
- config.default_formatter = "documentation"
66
- end
65
+ config.default_formatter = "documentation" if !%w[true 1].include?(ENV["CI"])
67
66
 
68
67
  config.filter_run_excluding active_record: true unless active_record_available
69
68
 
70
69
  config.order = :random
71
70
  Kernel.srand config.seed
72
71
 
73
- if ENV["CI"] == "true"
74
- config.color_mode = :on
75
- end
72
+ config.color_mode = :on if ENV["CI"] == "true"
76
73
  end
77
74
 
78
75
  require "warnings_logger"