super_diff 0.12.1 → 0.15.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 (272) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -19
  3. data/lib/super_diff/active_record/differs/active_record_relation.rb +2 -0
  4. data/lib/super_diff/active_record/differs.rb +3 -1
  5. data/lib/super_diff/active_record/inspection_tree_builders/active_record_model.rb +7 -5
  6. data/lib/super_diff/active_record/inspection_tree_builders/active_record_relation.rb +12 -10
  7. data/lib/super_diff/active_record/inspection_tree_builders.rb +4 -2
  8. data/lib/super_diff/active_record/monkey_patches.rb +4 -2
  9. data/lib/super_diff/active_record/object_inspection.rb +6 -4
  10. data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +3 -1
  11. data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +3 -1
  12. data/lib/super_diff/active_record/operation_tree_builders.rb +4 -2
  13. data/lib/super_diff/active_record/operation_tree_flatteners/active_record_relation.rb +4 -2
  14. data/lib/super_diff/active_record/operation_tree_flatteners.rb +3 -1
  15. data/lib/super_diff/active_record/operation_trees/active_record_relation.rb +2 -0
  16. data/lib/super_diff/active_record/operation_trees.rb +3 -1
  17. data/lib/super_diff/active_record.rb +10 -8
  18. data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +2 -0
  19. data/lib/super_diff/active_support/differs.rb +3 -1
  20. data/lib/super_diff/active_support/inspection_tree_builders/hash_with_indifferent_access.rb +16 -14
  21. data/lib/super_diff/active_support/inspection_tree_builders/ordered_options.rb +16 -14
  22. data/lib/super_diff/active_support/inspection_tree_builders.rb +4 -2
  23. data/lib/super_diff/active_support/object_inspection.rb +6 -4
  24. data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +6 -4
  25. data/lib/super_diff/active_support/operation_tree_builders.rb +3 -1
  26. data/lib/super_diff/active_support/operation_tree_flatteners/hash_with_indifferent_access.rb +4 -2
  27. data/lib/super_diff/active_support/operation_tree_flatteners.rb +3 -1
  28. data/lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb +2 -0
  29. data/lib/super_diff/active_support/operation_trees.rb +3 -1
  30. data/lib/super_diff/active_support.rb +8 -6
  31. data/lib/super_diff/basic/diff_formatters/collection.rb +18 -18
  32. data/lib/super_diff/basic/diff_formatters/multiline_string.rb +2 -0
  33. data/lib/super_diff/basic/diff_formatters.rb +4 -2
  34. data/lib/super_diff/basic/differs/array.rb +2 -0
  35. data/lib/super_diff/basic/differs/custom_object.rb +3 -1
  36. data/lib/super_diff/basic/differs/date_like.rb +2 -0
  37. data/lib/super_diff/basic/differs/default_object.rb +3 -1
  38. data/lib/super_diff/basic/differs/hash.rb +2 -0
  39. data/lib/super_diff/basic/differs/multiline_string.rb +2 -0
  40. data/lib/super_diff/basic/differs/time_like.rb +2 -0
  41. data/lib/super_diff/basic/differs.rb +11 -9
  42. data/lib/super_diff/basic/inspection_tree_builders/array.rb +5 -3
  43. data/lib/super_diff/basic/inspection_tree_builders/custom_object.rb +5 -3
  44. data/lib/super_diff/basic/inspection_tree_builders/data_object.rb +42 -0
  45. data/lib/super_diff/basic/inspection_tree_builders/date_like.rb +7 -5
  46. data/lib/super_diff/basic/inspection_tree_builders/default_object.rb +7 -5
  47. data/lib/super_diff/basic/inspection_tree_builders/hash.rb +7 -5
  48. data/lib/super_diff/basic/inspection_tree_builders/primitive.rb +3 -1
  49. data/lib/super_diff/basic/inspection_tree_builders/range_object.rb +19 -0
  50. data/lib/super_diff/basic/inspection_tree_builders/time_like.rb +8 -8
  51. data/lib/super_diff/basic/inspection_tree_builders.rb +18 -8
  52. data/lib/super_diff/basic/operation_tree_builders/array.rb +6 -4
  53. data/lib/super_diff/basic/operation_tree_builders/custom_object.rb +3 -1
  54. data/lib/super_diff/basic/operation_tree_builders/data_object.rb +20 -0
  55. data/lib/super_diff/basic/operation_tree_builders/date_like.rb +2 -0
  56. data/lib/super_diff/basic/operation_tree_builders/default_object.rb +32 -31
  57. data/lib/super_diff/basic/operation_tree_builders/hash.rb +49 -46
  58. data/lib/super_diff/basic/operation_tree_builders/multiline_string.rb +5 -3
  59. data/lib/super_diff/basic/operation_tree_builders/time_like.rb +5 -3
  60. data/lib/super_diff/basic/operation_tree_builders.rb +15 -9
  61. data/lib/super_diff/basic/operation_tree_flatteners/array.rb +4 -2
  62. data/lib/super_diff/basic/operation_tree_flatteners/collection.rb +11 -11
  63. data/lib/super_diff/basic/operation_tree_flatteners/custom_object.rb +5 -3
  64. data/lib/super_diff/basic/operation_tree_flatteners/default_object.rb +6 -5
  65. data/lib/super_diff/basic/operation_tree_flatteners/hash.rb +5 -3
  66. data/lib/super_diff/basic/operation_tree_flatteners/multiline_string.rb +3 -1
  67. data/lib/super_diff/basic/operation_tree_flatteners.rb +8 -6
  68. data/lib/super_diff/basic/operation_trees/array.rb +2 -0
  69. data/lib/super_diff/basic/operation_trees/custom_object.rb +2 -0
  70. data/lib/super_diff/basic/operation_trees/default_object.rb +6 -4
  71. data/lib/super_diff/basic/operation_trees/hash.rb +2 -0
  72. data/lib/super_diff/basic/operation_trees/multiline_string.rb +3 -1
  73. data/lib/super_diff/basic/operation_trees.rb +9 -7
  74. data/lib/super_diff/basic.rb +12 -7
  75. data/lib/super_diff/core/abstract_differ.rb +2 -0
  76. data/lib/super_diff/core/abstract_inspection_tree_builder.rb +2 -0
  77. data/lib/super_diff/core/abstract_operation_tree.rb +4 -2
  78. data/lib/super_diff/core/abstract_operation_tree_builder.rb +15 -18
  79. data/lib/super_diff/core/abstract_operation_tree_flattener.rb +5 -3
  80. data/lib/super_diff/core/binary_operation.rb +3 -1
  81. data/lib/super_diff/core/colorized_document_extensions.rb +2 -0
  82. data/lib/super_diff/core/configuration.rb +23 -43
  83. data/lib/super_diff/core/differ_dispatcher.rb +4 -2
  84. data/lib/super_diff/core/gem_version.rb +2 -0
  85. data/lib/super_diff/core/helpers.rb +14 -12
  86. data/lib/super_diff/core/implementation_checks.rb +6 -2
  87. data/lib/super_diff/core/inspection_tree.rb +38 -38
  88. data/lib/super_diff/core/inspection_tree_builder_dispatcher.rb +5 -5
  89. data/lib/super_diff/core/inspection_tree_nodes/as_lines_when_rendering_to_lines.rb +3 -1
  90. data/lib/super_diff/core/inspection_tree_nodes/as_prefix_when_rendering_to_lines.rb +2 -0
  91. data/lib/super_diff/core/inspection_tree_nodes/as_prelude_when_rendering_to_lines.rb +2 -0
  92. data/lib/super_diff/core/inspection_tree_nodes/as_single_line.rb +2 -0
  93. data/lib/super_diff/core/inspection_tree_nodes/base.rb +9 -9
  94. data/lib/super_diff/core/inspection_tree_nodes/inspection.rb +2 -0
  95. data/lib/super_diff/core/inspection_tree_nodes/nesting.rb +2 -0
  96. data/lib/super_diff/core/inspection_tree_nodes/only_when.rb +5 -1
  97. data/lib/super_diff/core/inspection_tree_nodes/text.rb +2 -0
  98. data/lib/super_diff/core/inspection_tree_nodes/when_empty.rb +3 -1
  99. data/lib/super_diff/core/inspection_tree_nodes/when_non_empty.rb +3 -1
  100. data/lib/super_diff/core/inspection_tree_nodes/when_rendering_to_lines.rb +3 -1
  101. data/lib/super_diff/core/inspection_tree_nodes/when_rendering_to_string.rb +2 -0
  102. data/lib/super_diff/core/inspection_tree_nodes.rb +16 -14
  103. data/lib/super_diff/core/line.rb +9 -7
  104. data/lib/super_diff/core/no_differ_available_error.rb +7 -5
  105. data/lib/super_diff/core/no_inspection_tree_builder_available_error.rb +5 -3
  106. data/lib/super_diff/core/no_operation_tree_available_error.rb +4 -2
  107. data/lib/super_diff/core/no_operation_tree_builder_available_error.rb +7 -5
  108. data/lib/super_diff/core/operation_tree_builder_dispatcher.rb +3 -3
  109. data/lib/super_diff/core/operation_tree_finder.rb +8 -8
  110. data/lib/super_diff/core/prefix_for_next_inspection_tree_node.rb +2 -0
  111. data/lib/super_diff/core/prelude_for_next_inspection_tree_node.rb +2 -0
  112. data/lib/super_diff/core/recursion_guard.rb +6 -4
  113. data/lib/super_diff/core/tiered_lines.rb +2 -0
  114. data/lib/super_diff/core/tiered_lines_elider.rb +53 -54
  115. data/lib/super_diff/core/tiered_lines_formatter.rb +6 -4
  116. data/lib/super_diff/core/unary_operation.rb +2 -0
  117. data/lib/super_diff/core.rb +31 -29
  118. data/lib/super_diff/csi/bold_sequence.rb +2 -0
  119. data/lib/super_diff/csi/color.rb +4 -4
  120. data/lib/super_diff/csi/color_sequence_block.rb +3 -1
  121. data/lib/super_diff/csi/colorized_document.rb +7 -9
  122. data/lib/super_diff/csi/document.rb +15 -18
  123. data/lib/super_diff/csi/eight_bit_color.rb +32 -37
  124. data/lib/super_diff/csi/four_bit_color.rb +12 -9
  125. data/lib/super_diff/csi/reset_sequence.rb +2 -0
  126. data/lib/super_diff/csi/twenty_four_bit_color.rb +22 -21
  127. data/lib/super_diff/csi/uncolorized_document.rb +2 -0
  128. data/lib/super_diff/csi.rb +12 -42
  129. data/lib/super_diff/differs.rb +6 -4
  130. data/lib/super_diff/equality_matchers/array.rb +18 -16
  131. data/lib/super_diff/equality_matchers/base.rb +6 -4
  132. data/lib/super_diff/equality_matchers/default.rb +5 -3
  133. data/lib/super_diff/equality_matchers/defaults.rb +3 -1
  134. data/lib/super_diff/equality_matchers/hash.rb +18 -16
  135. data/lib/super_diff/equality_matchers/main.rb +3 -1
  136. data/lib/super_diff/equality_matchers/multiline_string.rb +18 -16
  137. data/lib/super_diff/equality_matchers/primitive.rb +15 -13
  138. data/lib/super_diff/equality_matchers/singleline_string.rb +16 -14
  139. data/lib/super_diff/equality_matchers.rb +11 -9
  140. data/lib/super_diff/errors.rb +4 -2
  141. data/lib/super_diff/object_inspection.rb +17 -15
  142. data/lib/super_diff/operation_tree_builders.rb +6 -4
  143. data/lib/super_diff/operation_tree_flatteners.rb +6 -4
  144. data/lib/super_diff/operation_trees.rb +6 -4
  145. data/lib/super_diff/operations.rb +4 -2
  146. data/lib/super_diff/rails.rb +4 -2
  147. data/lib/super_diff/rspec/augmented_matcher.rb +3 -1
  148. data/lib/super_diff/rspec/differ.rb +16 -7
  149. data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +2 -0
  150. data/lib/super_diff/rspec/differs/collection_including.rb +2 -0
  151. data/lib/super_diff/rspec/differs/hash_including.rb +2 -0
  152. data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -0
  153. data/lib/super_diff/rspec/differs.rb +6 -4
  154. data/lib/super_diff/rspec/inspection_tree_builders/collection_containing_exactly.rb +12 -10
  155. data/lib/super_diff/rspec/inspection_tree_builders/collection_including.rb +10 -8
  156. data/lib/super_diff/rspec/inspection_tree_builders/double.rb +20 -18
  157. data/lib/super_diff/rspec/inspection_tree_builders/generic_describable_matcher.rb +2 -0
  158. data/lib/super_diff/rspec/inspection_tree_builders/hash_including.rb +10 -8
  159. data/lib/super_diff/rspec/inspection_tree_builders/instance_of.rb +2 -0
  160. data/lib/super_diff/rspec/inspection_tree_builders/kind_of.rb +2 -0
  161. data/lib/super_diff/rspec/inspection_tree_builders/object_having_attributes.rb +12 -10
  162. data/lib/super_diff/rspec/inspection_tree_builders/primitive.rb +2 -0
  163. data/lib/super_diff/rspec/inspection_tree_builders/value_within.rb +6 -4
  164. data/lib/super_diff/rspec/inspection_tree_builders.rb +12 -10
  165. data/lib/super_diff/rspec/matcher_text_builders/base.rb +12 -12
  166. data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +19 -17
  167. data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +3 -1
  168. data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +7 -5
  169. data/lib/super_diff/rspec/matcher_text_builders/match.rb +6 -4
  170. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +5 -3
  171. data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +20 -18
  172. data/lib/super_diff/rspec/matcher_text_builders.rb +9 -7
  173. data/lib/super_diff/rspec/matcher_text_template.rb +34 -39
  174. data/lib/super_diff/rspec/monkey_patches.rb +129 -56
  175. data/lib/super_diff/rspec/object_inspection.rb +7 -5
  176. data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +4 -4
  177. data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +2 -0
  178. data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +2 -0
  179. data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +2 -0
  180. data/lib/super_diff/rspec/operation_tree_builders.rb +6 -4
  181. data/lib/super_diff/rspec-rails.rb +4 -2
  182. data/lib/super_diff/rspec.rb +27 -14
  183. data/lib/super_diff/version.rb +3 -1
  184. data/lib/super_diff.rb +24 -27
  185. data/super_diff.gemspec +20 -18
  186. metadata +15 -182
  187. data/spec/examples.txt +0 -704
  188. data/spec/integration/rails/active_record_spec.rb +0 -21
  189. data/spec/integration/rails/active_support_spec.rb +0 -19
  190. data/spec/integration/rails/engines_spec.rb +0 -25
  191. data/spec/integration/rails/hash_with_indifferent_access_spec.rb +0 -21
  192. data/spec/integration/rspec/be_falsey_matcher_spec.rb +0 -58
  193. data/spec/integration/rspec/be_matcher_spec.rb +0 -605
  194. data/spec/integration/rspec/be_nil_matcher_spec.rb +0 -57
  195. data/spec/integration/rspec/be_predicate_matcher_spec.rb +0 -615
  196. data/spec/integration/rspec/be_truthy_matcher_spec.rb +0 -62
  197. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +0 -377
  198. data/spec/integration/rspec/eq_matcher_spec.rb +0 -1066
  199. data/spec/integration/rspec/generic_describable_matchers_spec.rb +0 -177
  200. data/spec/integration/rspec/have_attributes_matcher_spec.rb +0 -443
  201. data/spec/integration/rspec/have_predicate_matcher_spec.rb +0 -478
  202. data/spec/integration/rspec/include_matcher_spec.rb +0 -452
  203. data/spec/integration/rspec/magic_metadata_spec.rb +0 -51
  204. data/spec/integration/rspec/match_array_matcher_spec.rb +0 -424
  205. data/spec/integration/rspec/match_matcher_spec.rb +0 -1359
  206. data/spec/integration/rspec/raise_error_matcher_spec.rb +0 -1488
  207. data/spec/integration/rspec/respond_to_matcher_spec.rb +0 -999
  208. data/spec/integration/rspec/third_party_matcher_spec.rb +0 -245
  209. data/spec/integration/rspec/unhandled_errors_spec.rb +0 -150
  210. data/spec/internal/log/test.log +0 -0
  211. data/spec/spec_helper.rb +0 -90
  212. data/spec/support/colorizer.rb +0 -9
  213. data/spec/support/command_runner.rb +0 -253
  214. data/spec/support/helpers.rb +0 -21
  215. data/spec/support/integration/helpers.rb +0 -124
  216. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +0 -104
  217. data/spec/support/integration/matchers.rb +0 -177
  218. data/spec/support/integration/test_programs/base.rb +0 -143
  219. data/spec/support/integration/test_programs/plain.rb +0 -19
  220. data/spec/support/integration/test_programs/rspec_active_record.rb +0 -20
  221. data/spec/support/integration/test_programs/rspec_active_support.rb +0 -20
  222. data/spec/support/integration/test_programs/rspec_rails.rb +0 -20
  223. data/spec/support/integration/test_programs/rspec_rails_engine.rb +0 -20
  224. data/spec/support/models/a.rb +0 -11
  225. data/spec/support/models/active_record/person.rb +0 -28
  226. data/spec/support/models/active_record/query.rb +0 -15
  227. data/spec/support/models/active_record/shipping_address.rb +0 -24
  228. data/spec/support/models/customer.rb +0 -22
  229. data/spec/support/models/empty_class.rb +0 -6
  230. data/spec/support/models/item.rb +0 -10
  231. data/spec/support/models/order.rb +0 -9
  232. data/spec/support/models/person.rb +0 -20
  233. data/spec/support/models/player.rb +0 -30
  234. data/spec/support/models/shipping_address.rb +0 -25
  235. data/spec/support/shared_examples/active_record.rb +0 -428
  236. data/spec/support/shared_examples/active_support.rb +0 -188
  237. data/spec/support/shared_examples/elided_diffs.rb +0 -938
  238. data/spec/support/shared_examples/hash_with_indifferent_access.rb +0 -749
  239. data/spec/support/shared_examples/key.rb +0 -123
  240. data/spec/support/unit/helpers.rb +0 -24
  241. data/spec/support/unit/matchers/be_deprecated_in_favor_of.rb +0 -39
  242. data/spec/support/unit/matchers/match_output.rb +0 -40
  243. data/spec/unit/active_record/object_inspection_spec.rb +0 -289
  244. data/spec/unit/active_support/object_inspection_spec.rb +0 -170
  245. data/spec/unit/basic/operation_tree_flatteners/array_spec.rb +0 -637
  246. data/spec/unit/basic/operation_tree_flatteners/custom_object_spec.rb +0 -685
  247. data/spec/unit/basic/operation_tree_flatteners/default_object_spec.rb +0 -685
  248. data/spec/unit/basic/operation_tree_flatteners/hash_spec.rb +0 -671
  249. data/spec/unit/basic/operation_tree_flatteners/multiline_string_spec.rb +0 -131
  250. data/spec/unit/core/helpers_spec.rb +0 -68
  251. data/spec/unit/core/tiered_lines_elider_spec.rb +0 -6328
  252. data/spec/unit/core/tiered_lines_formatter_spec.rb +0 -131
  253. data/spec/unit/deprecations_spec.rb +0 -176
  254. data/spec/unit/equality_matchers/main_spec.rb +0 -1842
  255. data/spec/unit/rspec/matchers/be_compared_to_spec.rb +0 -23
  256. data/spec/unit/rspec/matchers/be_falsey_spec.rb +0 -9
  257. data/spec/unit/rspec/matchers/be_nil_spec.rb +0 -9
  258. data/spec/unit/rspec/matchers/be_predicate_spec.rb +0 -31
  259. data/spec/unit/rspec/matchers/be_spec.rb +0 -17
  260. data/spec/unit/rspec/matchers/be_truthy_spec.rb +0 -9
  261. data/spec/unit/rspec/matchers/contain_exactly_spec.rb +0 -11
  262. data/spec/unit/rspec/matchers/eq_spec.rb +0 -9
  263. data/spec/unit/rspec/matchers/have_attributes_spec.rb +0 -11
  264. data/spec/unit/rspec/matchers/have_predicate_spec.rb +0 -21
  265. data/spec/unit/rspec/matchers/include_spec.rb +0 -21
  266. data/spec/unit/rspec/matchers/match_array_spec.rb +0 -11
  267. data/spec/unit/rspec/matchers/match_spec.rb +0 -9
  268. data/spec/unit/rspec/matchers/raise_error_spec.rb +0 -77
  269. data/spec/unit/rspec/matchers/respond_to_spec.rb +0 -85
  270. data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +0 -91
  271. data/spec/unit/rspec/object_inspection_spec.rb +0 -471
  272. data/spec/unit/super_diff_spec.rb +0 -2115
@@ -1,999 +0,0 @@
1
- require "spec_helper"
2
-
3
- # TODO: Update coloring here
4
- RSpec.describe "Integration with RSpec's #respond_to matcher",
5
- type: :integration do
6
- context "without any qualifiers" do
7
- context "when a few number of methods are specified" do
8
- it "produces the correct failure message when used in the positive" do
9
- as_both_colored_and_uncolored do |color_enabled|
10
- snippet = "expect(double).to respond_to(:foo)"
11
- program =
12
- make_plain_test_program(snippet, color_enabled: color_enabled)
13
-
14
- expected_output =
15
- build_expected_output(
16
- color_enabled: color_enabled,
17
- snippet: snippet,
18
- expectation:
19
- proc do
20
- line do
21
- plain "Expected "
22
- actual "#<Double (anonymous)>"
23
- plain " to respond to "
24
- expected ":foo"
25
- plain "."
26
- end
27
- end
28
- )
29
-
30
- expect(program).to produce_output_when_run(expected_output).in_color(
31
- color_enabled
32
- )
33
- end
34
- end
35
-
36
- it "produces the correct failure message when used in the negative" do
37
- as_both_colored_and_uncolored do |color_enabled|
38
- snippet = "expect(double).not_to respond_to(:inspect)"
39
- program =
40
- make_plain_test_program(snippet, color_enabled: color_enabled)
41
-
42
- expected_output =
43
- build_expected_output(
44
- color_enabled: color_enabled,
45
- snippet: snippet,
46
- expectation:
47
- proc do
48
- line do
49
- plain "Expected "
50
- actual "#<Double (anonymous)>"
51
- plain " not to respond to "
52
- expected ":inspect"
53
- plain "."
54
- end
55
- end
56
- )
57
-
58
- expect(program).to produce_output_when_run(expected_output).in_color(
59
- color_enabled
60
- )
61
- end
62
- end
63
- end
64
-
65
- context "when a large number of methods are specified" do
66
- it "produces the correct failure message when used in the positive" do
67
- as_both_colored_and_uncolored do |color_enabled|
68
- snippet = <<~TEST.strip
69
- expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz, :qux, :fizz, :buzz, :zing)
70
- TEST
71
- program =
72
- make_plain_test_program(snippet, color_enabled: color_enabled)
73
-
74
- expected_output =
75
- build_expected_output(
76
- color_enabled: color_enabled,
77
- snippet:
78
- "expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz, :qux, :fizz, :buzz, :zing)",
79
- newline_before_expectation: true,
80
- expectation:
81
- proc do
82
- line do
83
- plain " Expected "
84
- actual "#<Double :something_really_long>"
85
- end
86
-
87
- line do
88
- plain "to respond to "
89
- expected ":foo"
90
- plain ", "
91
- expected ":bar"
92
- plain ", "
93
- expected ":baz"
94
- plain ", "
95
- expected ":qux"
96
- plain ", "
97
- expected ":fizz"
98
- plain ", "
99
- expected ":buzz"
100
- plain " and "
101
- expected ":zing"
102
- end
103
- end
104
- )
105
-
106
- expect(program).to produce_output_when_run(expected_output).in_color(
107
- color_enabled
108
- )
109
- end
110
- end
111
-
112
- it "produces the correct failure message when used in the negative" do
113
- as_both_colored_and_uncolored do |color_enabled|
114
- snippet = <<~TEST.strip
115
- class B
116
- def some_really_long_method_and_stuff; end
117
- def another_method_or_whatever; end
118
- end
119
-
120
- expect(B.new).not_to respond_to(:some_really_long_method_and_stuff, :another_method_or_whatever)
121
- TEST
122
- program =
123
- make_plain_test_program(snippet, color_enabled: color_enabled)
124
-
125
- expected_output =
126
- build_expected_output(
127
- color_enabled: color_enabled,
128
- snippet:
129
- "expect(B.new).not_to respond_to(:some_really_long_method_and_stuff, :another_method_or_whatever)",
130
- newline_before_expectation: true,
131
- expectation:
132
- proc do
133
- line do
134
- plain " Expected "
135
- actual "#<B>"
136
- end
137
-
138
- line do
139
- plain "not to respond to "
140
- expected ":some_really_long_method_and_stuff"
141
- plain " and "
142
- expected ":another_method_or_whatever"
143
- end
144
- end
145
- )
146
-
147
- expect(program).to produce_output_when_run(
148
- expected_output
149
- ).removing_object_ids.in_color(color_enabled)
150
- end
151
- end
152
- end
153
- end
154
-
155
- context "qualified with #with + #arguments" do
156
- context "when a few number of methods are specified when used in the positive" do
157
- it "produces the correct failure message" do
158
- as_both_colored_and_uncolored do |color_enabled|
159
- snippet = <<~TEST.strip
160
- expect(double).to respond_to(:foo).with(3).arguments
161
- TEST
162
- program =
163
- make_plain_test_program(snippet, color_enabled: color_enabled)
164
-
165
- expected_output =
166
- build_expected_output(
167
- color_enabled: color_enabled,
168
- snippet: "expect(double).to respond_to(:foo).with(3).arguments",
169
- expectation:
170
- proc do
171
- line do
172
- plain "Expected "
173
- actual "#<Double (anonymous)>"
174
- plain " to respond to "
175
- expected ":foo"
176
- plain " with "
177
- expected "3"
178
- plain " arguments."
179
- end
180
- end
181
- )
182
-
183
- expect(program).to produce_output_when_run(expected_output).in_color(
184
- color_enabled
185
- )
186
- end
187
- end
188
-
189
- it "produces the correct failure message when used in the negative" do
190
- as_both_colored_and_uncolored do |color_enabled|
191
- snippet = <<~TEST.strip
192
- class B
193
- def foo(bar, baz, qux); end
194
- end
195
-
196
- expect(B.new).not_to respond_to(:foo).with(3).arguments
197
- TEST
198
- program =
199
- make_plain_test_program(snippet, color_enabled: color_enabled)
200
-
201
- expected_output =
202
- build_expected_output(
203
- color_enabled: color_enabled,
204
- snippet:
205
- "expect(B.new).not_to respond_to(:foo).with(3).arguments",
206
- expectation:
207
- proc do
208
- line do
209
- plain "Expected "
210
- actual "#<B>"
211
- plain " not to respond to "
212
- expected ":foo"
213
- plain " with "
214
- expected "3"
215
- plain " arguments."
216
- end
217
- end
218
- )
219
-
220
- expect(program).to produce_output_when_run(
221
- expected_output
222
- ).removing_object_ids.in_color(color_enabled)
223
- end
224
- end
225
- end
226
-
227
- context "when a large number of methods are specified" do
228
- it "produces the correct failure message when used in the positive" do
229
- as_both_colored_and_uncolored do |color_enabled|
230
- snippet = <<~TEST.strip
231
- expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz, :fizz, :buzz).with(3).arguments
232
- TEST
233
- program =
234
- make_plain_test_program(snippet, color_enabled: color_enabled)
235
-
236
- expected_output =
237
- build_expected_output(
238
- color_enabled: color_enabled,
239
- snippet:
240
- "expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz, :fizz, :buzz).with(3).arguments",
241
- newline_before_expectation: true,
242
- expectation:
243
- proc do
244
- line do
245
- plain " Expected "
246
- actual "#<Double :something_really_long>"
247
- end
248
-
249
- line do
250
- plain "to respond to "
251
- expected ":foo"
252
- plain ", "
253
- expected ":bar"
254
- plain ", "
255
- expected ":baz"
256
- plain ", "
257
- expected ":fizz"
258
- plain " and "
259
- expected ":buzz"
260
- plain " with "
261
- expected "3"
262
- plain " arguments"
263
- end
264
- end
265
- )
266
-
267
- expect(program).to produce_output_when_run(expected_output).in_color(
268
- color_enabled
269
- )
270
- end
271
- end
272
-
273
- it "produces the correct failure message when used in the negative" do
274
- as_both_colored_and_uncolored do |color_enabled|
275
- snippet = <<~TEST.strip
276
- class B
277
- def some_really_long_method_and_stuff(foo, bar, baz); end
278
- def another_method_or_whatever(foo, bar, baz); end
279
- end
280
-
281
- expect(B.new).not_to respond_to(:some_really_long_method_and_stuff, :another_method_or_whatever).with(3).arguments
282
- TEST
283
- program =
284
- make_plain_test_program(snippet, color_enabled: color_enabled)
285
-
286
- expected_output =
287
- build_expected_output(
288
- color_enabled: color_enabled,
289
- snippet:
290
- "expect(B.new).not_to respond_to(:some_really_long_method_and_stuff, :another_method_or_whatever).with(3).arguments",
291
- newline_before_expectation: true,
292
- expectation:
293
- proc do
294
- line do
295
- plain " Expected "
296
- actual "#<B>"
297
- end
298
-
299
- line do
300
- plain "not to respond to "
301
- expected ":some_really_long_method_and_stuff"
302
- plain " and "
303
- expected ":another_method_or_whatever"
304
- plain " with "
305
- expected "3"
306
- plain " arguments"
307
- end
308
- end
309
- )
310
-
311
- expect(program).to produce_output_when_run(
312
- expected_output
313
- ).removing_object_ids.in_color(color_enabled)
314
- end
315
- end
316
- end
317
- end
318
-
319
- context "qualified with #with_keywords" do
320
- context "when a few number of methods are specified" do
321
- it "produces the correct failure message when used in the positive" do
322
- as_both_colored_and_uncolored do |color_enabled|
323
- snippet = <<~TEST.strip
324
- expect(double).to respond_to(:foo).with_keywords(:bar)
325
- TEST
326
- program =
327
- make_plain_test_program(snippet, color_enabled: color_enabled)
328
-
329
- expected_output =
330
- build_expected_output(
331
- color_enabled: color_enabled,
332
- snippet: "expect(double).to respond_to(:foo).with_keywords(:bar)",
333
- expectation:
334
- proc do
335
- line do
336
- plain "Expected "
337
- actual "#<Double (anonymous)>"
338
- plain " to respond to "
339
- expected ":foo"
340
- plain " with keyword "
341
- expected ":bar"
342
- plain "."
343
- end
344
- end
345
- )
346
-
347
- expect(program).to produce_output_when_run(expected_output).in_color(
348
- color_enabled
349
- )
350
- end
351
- end
352
-
353
- it "produces the correct failure message when used in the negative" do
354
- as_both_colored_and_uncolored do |color_enabled|
355
- snippet = <<~TEST.strip
356
- class B
357
- def foo(bar:); end
358
- end
359
-
360
- expect(B.new).not_to respond_to(:foo).with_keywords(:bar)
361
- TEST
362
- program =
363
- make_plain_test_program(snippet, color_enabled: color_enabled)
364
-
365
- expected_output =
366
- build_expected_output(
367
- color_enabled: color_enabled,
368
- snippet:
369
- "expect(B.new).not_to respond_to(:foo).with_keywords(:bar)",
370
- expectation:
371
- proc do
372
- line do
373
- plain "Expected "
374
- actual "#<B>"
375
- plain " not to respond to "
376
- expected ":foo"
377
- plain " with keyword "
378
- expected ":bar"
379
- plain "."
380
- end
381
- end
382
- )
383
-
384
- expect(program).to produce_output_when_run(
385
- expected_output
386
- ).removing_object_ids.in_color(color_enabled)
387
- end
388
- end
389
- end
390
-
391
- context "when a large number of methods are specified" do
392
- it "produces the correct failure message when used in the positive" do
393
- as_both_colored_and_uncolored do |color_enabled|
394
- snippet = <<~TEST.strip
395
- expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz, :fizz, :buzz).with_keywords(:qux, :blargh)
396
- TEST
397
- program =
398
- make_plain_test_program(snippet, color_enabled: color_enabled)
399
-
400
- expected_output =
401
- build_expected_output(
402
- color_enabled: color_enabled,
403
- snippet:
404
- "expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz, :fizz, :buzz).with_keywords(:qux, :blargh)",
405
- newline_before_expectation: true,
406
- expectation:
407
- proc do
408
- line do
409
- plain " Expected "
410
- actual "#<Double :something_really_long>"
411
- end
412
-
413
- line do
414
- plain "to respond to "
415
- expected ":foo"
416
- plain ", "
417
- expected ":bar"
418
- plain ", "
419
- expected ":baz"
420
- plain ", "
421
- expected ":fizz"
422
- plain " and "
423
- expected ":buzz"
424
- plain " with keywords "
425
- expected ":qux"
426
- plain " and "
427
- expected ":blargh"
428
- end
429
- end
430
- )
431
-
432
- expect(program).to produce_output_when_run(expected_output).in_color(
433
- color_enabled
434
- )
435
- end
436
- end
437
-
438
- it "produces the correct failure message when used in the negative" do
439
- as_both_colored_and_uncolored do |color_enabled|
440
- snippet = <<~TEST.strip
441
- class B
442
- def some_really_long_method_and_stuff(foo:, bar:); end
443
- def another_method_or_whatever(foo:, bar:); end
444
- end
445
-
446
- expect(B.new).not_to respond_to(:some_really_long_method_and_stuff, :another_method_or_whatever).with_keywords(:foo, :bar)
447
- TEST
448
- program =
449
- make_plain_test_program(snippet, color_enabled: color_enabled)
450
-
451
- expected_output =
452
- build_expected_output(
453
- color_enabled: color_enabled,
454
- snippet:
455
- "expect(B.new).not_to respond_to(:some_really_long_method_and_stuff, :another_method_or_whatever).with_keywords(:foo, :bar)",
456
- newline_before_expectation: true,
457
- expectation:
458
- proc do
459
- line do
460
- plain " Expected "
461
- actual "#<B>"
462
- end
463
-
464
- line do
465
- plain "not to respond to "
466
- expected ":some_really_long_method_and_stuff"
467
- plain " and "
468
- expected ":another_method_or_whatever"
469
- plain " with keywords "
470
- expected ":foo"
471
- plain " and "
472
- expected ":bar"
473
- end
474
- end
475
- )
476
-
477
- expect(program).to produce_output_when_run(
478
- expected_output
479
- ).removing_object_ids.in_color(color_enabled)
480
- end
481
- end
482
- end
483
- end
484
-
485
- context "qualified with #with_any_keywords" do
486
- context "when a few number of methods are specified" do
487
- it "produces the correct failure message when used in the positive" do
488
- as_both_colored_and_uncolored do |color_enabled|
489
- snippet = <<~TEST.strip
490
- expect(double).to respond_to(:foo).with_any_keywords
491
- TEST
492
- program =
493
- make_plain_test_program(snippet, color_enabled: color_enabled)
494
-
495
- expected_output =
496
- build_expected_output(
497
- color_enabled: color_enabled,
498
- snippet: "expect(double).to respond_to(:foo).with_any_keywords",
499
- expectation:
500
- proc do
501
- line do
502
- plain "Expected "
503
- actual "#<Double (anonymous)>"
504
- plain " to respond to "
505
- expected ":foo"
506
- plain " with "
507
- expected "any"
508
- plain " keywords."
509
- end
510
- end
511
- )
512
-
513
- expect(program).to produce_output_when_run(expected_output).in_color(
514
- color_enabled
515
- )
516
- end
517
- end
518
-
519
- it "produces the correct failure message when used in the negative" do
520
- as_both_colored_and_uncolored do |color_enabled|
521
- snippet = <<~TEST.strip
522
- class B
523
- def foo(**options); end
524
- end
525
-
526
- expect(B.new).not_to respond_to(:foo).with_any_keywords
527
- TEST
528
- program =
529
- make_plain_test_program(snippet, color_enabled: color_enabled)
530
-
531
- expected_output =
532
- build_expected_output(
533
- color_enabled: color_enabled,
534
- snippet:
535
- "expect(B.new).not_to respond_to(:foo).with_any_keywords",
536
- expectation:
537
- proc do
538
- line do
539
- plain "Expected "
540
- actual "#<B>"
541
- plain " not to respond to "
542
- expected ":foo"
543
- plain " with "
544
- expected "any"
545
- plain " keywords."
546
- end
547
- end
548
- )
549
-
550
- expect(program).to produce_output_when_run(
551
- expected_output
552
- ).removing_object_ids.in_color(color_enabled)
553
- end
554
- end
555
- end
556
-
557
- context "when a large number of methods are specified" do
558
- it "produces the correct failure message when used in the positive" do
559
- as_both_colored_and_uncolored do |color_enabled|
560
- snippet = <<~TEST.strip
561
- expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz, :qux, :fizz, :buzz).with_any_keywords
562
- TEST
563
- program =
564
- make_plain_test_program(snippet, color_enabled: color_enabled)
565
-
566
- expected_output =
567
- build_expected_output(
568
- color_enabled: color_enabled,
569
- snippet:
570
- "expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz, :qux, :fizz, :buzz).with_any_keywords",
571
- newline_before_expectation: true,
572
- expectation:
573
- proc do
574
- line do
575
- plain " Expected "
576
- actual "#<Double :something_really_long>"
577
- end
578
-
579
- line do
580
- plain "to respond to "
581
- expected ":foo"
582
- plain ", "
583
- expected ":bar"
584
- plain ", "
585
- expected ":baz"
586
- plain ", "
587
- expected ":qux"
588
- plain ", "
589
- expected ":fizz"
590
- plain " and "
591
- expected ":buzz"
592
- plain " with "
593
- expected "any"
594
- plain " keywords "
595
- end
596
- end
597
- )
598
-
599
- expect(program).to produce_output_when_run(expected_output).in_color(
600
- color_enabled
601
- )
602
- end
603
- end
604
-
605
- it "produces the correct failure message when used in the negative" do
606
- as_both_colored_and_uncolored do |color_enabled|
607
- snippet = <<~TEST.strip
608
- class B
609
- def some_really_long_method_and_stuff(**options); end
610
- def another_method_or_whatever(**options); end
611
- end
612
-
613
- expect(B.new).not_to respond_to(:some_really_long_method_and_stuff, :another_method_or_whatever).with_any_keywords
614
- TEST
615
- program =
616
- make_plain_test_program(snippet, color_enabled: color_enabled)
617
-
618
- expected_output =
619
- build_expected_output(
620
- color_enabled: color_enabled,
621
- snippet:
622
- "expect(B.new).not_to respond_to(:some_really_long_method_and_stuff, :another_method_or_whatever).with_any_keywords",
623
- newline_before_expectation: true,
624
- expectation:
625
- proc do
626
- line do
627
- plain " Expected "
628
- actual "#<B>"
629
- end
630
-
631
- line do
632
- plain "not to respond to "
633
- expected ":some_really_long_method_and_stuff"
634
- plain " and "
635
- expected ":another_method_or_whatever"
636
- plain " with "
637
- expected "any"
638
- plain " keywords "
639
- end
640
- end
641
- )
642
-
643
- expect(program).to produce_output_when_run(
644
- expected_output
645
- ).removing_object_ids.in_color(color_enabled)
646
- end
647
- end
648
- end
649
- end
650
-
651
- context "qualified with #with_unlimited_arguments" do
652
- context "when a few number of methods are specified" do
653
- it "produces the correct failure message when used in the positive" do
654
- as_both_colored_and_uncolored do |color_enabled|
655
- snippet = <<~TEST.strip
656
- expect(double).to respond_to(:foo).with_unlimited_arguments
657
- TEST
658
- program =
659
- make_plain_test_program(snippet, color_enabled: color_enabled)
660
-
661
- expected_output =
662
- build_expected_output(
663
- color_enabled: color_enabled,
664
- snippet:
665
- "expect(double).to respond_to(:foo).with_unlimited_arguments",
666
- expectation:
667
- proc do
668
- line do
669
- plain "Expected "
670
- actual "#<Double (anonymous)>"
671
- plain " to respond to "
672
- expected ":foo"
673
- plain " with "
674
- expected "unlimited"
675
- plain " arguments."
676
- end
677
- end
678
- )
679
-
680
- expect(program).to produce_output_when_run(expected_output).in_color(
681
- color_enabled
682
- )
683
- end
684
- end
685
-
686
- it "produces the correct failure message when used in the negative" do
687
- as_both_colored_and_uncolored do |color_enabled|
688
- snippet = <<~TEST.strip
689
- class B
690
- def foo(*args); end
691
- end
692
-
693
- expect(B.new).not_to respond_to(:foo).with_unlimited_arguments
694
- TEST
695
- program =
696
- make_plain_test_program(snippet, color_enabled: color_enabled)
697
-
698
- expected_output =
699
- build_expected_output(
700
- color_enabled: color_enabled,
701
- snippet:
702
- "expect(B.new).not_to respond_to(:foo).with_unlimited_arguments",
703
- expectation:
704
- proc do
705
- line do
706
- plain "Expected "
707
- actual "#<B>"
708
- plain " not to respond to "
709
- expected ":foo"
710
- plain " with "
711
- expected "unlimited"
712
- plain " arguments."
713
- end
714
- end
715
- )
716
-
717
- expect(program).to produce_output_when_run(
718
- expected_output
719
- ).removing_object_ids.in_color(color_enabled)
720
- end
721
- end
722
- end
723
-
724
- context "when a large number of methods are specified" do
725
- it "produces the correct failure message when used in the positive" do
726
- as_both_colored_and_uncolored do |color_enabled|
727
- snippet = <<~TEST.strip
728
- expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz).with_unlimited_arguments
729
- TEST
730
- program =
731
- make_plain_test_program(snippet, color_enabled: color_enabled)
732
-
733
- expected_output =
734
- build_expected_output(
735
- color_enabled: color_enabled,
736
- snippet:
737
- "expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz).with_unlimited_arguments",
738
- newline_before_expectation: true,
739
- expectation:
740
- proc do
741
- line do
742
- plain " Expected "
743
- actual "#<Double :something_really_long>"
744
- end
745
-
746
- line do
747
- plain "to respond to "
748
- expected ":foo"
749
- plain ", "
750
- expected ":bar"
751
- plain " and "
752
- expected ":baz"
753
- plain " with "
754
- expected "unlimited"
755
- plain " arguments"
756
- end
757
- end
758
- )
759
-
760
- expect(program).to produce_output_when_run(expected_output).in_color(
761
- color_enabled
762
- )
763
- end
764
- end
765
-
766
- it "produces the correct failure message when used in the negative" do
767
- as_both_colored_and_uncolored do |color_enabled|
768
- snippet = <<~TEST.strip
769
- class B
770
- def some_really_long_method_and_stuff(*args); end
771
- def another_method_or_whatever(*args); end
772
- end
773
-
774
- expect(B.new).not_to respond_to(:some_really_long_method_and_stuff, :another_method_or_whatever).with_unlimited_arguments
775
- TEST
776
- program =
777
- make_plain_test_program(snippet, color_enabled: color_enabled)
778
-
779
- expected_output =
780
- build_expected_output(
781
- color_enabled: color_enabled,
782
- snippet:
783
- "expect(B.new).not_to respond_to(:some_really_long_method_and_stuff, :another_method_or_whatever).with_unlimited_arguments",
784
- newline_before_expectation: true,
785
- expectation:
786
- proc do
787
- line do
788
- plain " Expected "
789
- actual "#<B>"
790
- end
791
-
792
- line do
793
- plain "not to respond to "
794
- expected ":some_really_long_method_and_stuff"
795
- plain " and "
796
- expected ":another_method_or_whatever"
797
- plain " with "
798
- expected "unlimited"
799
- plain " arguments"
800
- end
801
- end
802
- )
803
-
804
- expect(program).to produce_output_when_run(
805
- expected_output
806
- ).removing_object_ids.in_color(color_enabled)
807
- end
808
- end
809
- end
810
- end
811
-
812
- context "qualified with #with_any_keywords + #with_unlimited_arguments" do
813
- it "produces the correct failure message when used in the positive" do
814
- as_both_colored_and_uncolored do |color_enabled|
815
- snippet = <<~TEST.strip
816
- expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz).with_any_keywords.with_unlimited_arguments
817
- TEST
818
- program = make_plain_test_program(snippet, color_enabled: color_enabled)
819
-
820
- expected_output =
821
- build_expected_output(
822
- color_enabled: color_enabled,
823
- snippet:
824
- "expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz).with_any_keywords.with_unlimited_arguments",
825
- newline_before_expectation: true,
826
- expectation:
827
- proc do
828
- line do
829
- plain " Expected "
830
- actual "#<Double :something_really_long>"
831
- end
832
-
833
- line do
834
- plain "to respond to "
835
- expected ":foo"
836
- plain ", "
837
- expected ":bar"
838
- plain " and "
839
- expected ":baz"
840
- plain " with "
841
- expected "any"
842
- plain " keywords and "
843
- expected "unlimited"
844
- plain " arguments"
845
- end
846
- end
847
- )
848
-
849
- expect(program).to produce_output_when_run(expected_output).in_color(
850
- color_enabled
851
- )
852
- end
853
- end
854
-
855
- it "produces the correct failure message when used in the negative" do
856
- as_both_colored_and_uncolored do |color_enabled|
857
- snippet = <<~TEST.strip
858
- class B
859
- def foo(*args, **options); end
860
- def bar(*args, **options); end
861
- def baz(*args, **options); end
862
- end
863
-
864
- expect(B.new).not_to respond_to(:foo, :bar, :baz).with_any_keywords.with_unlimited_arguments
865
- TEST
866
- program = make_plain_test_program(snippet, color_enabled: color_enabled)
867
-
868
- expected_output =
869
- build_expected_output(
870
- color_enabled: color_enabled,
871
- snippet:
872
- "expect(B.new).not_to respond_to(:foo, :bar, :baz).with_any_keywords.with_unlimited_arguments",
873
- newline_before_expectation: true,
874
- expectation:
875
- proc do
876
- line do
877
- plain " Expected "
878
- actual "#<B>"
879
- end
880
-
881
- line do
882
- plain "not to respond to "
883
- expected ":foo"
884
- plain ", "
885
- expected ":bar"
886
- plain " and "
887
- expected ":baz"
888
- plain " with "
889
- expected "any"
890
- plain " keywords and "
891
- expected "unlimited"
892
- plain " arguments"
893
- end
894
- end
895
- )
896
-
897
- expect(program).to produce_output_when_run(
898
- expected_output
899
- ).removing_object_ids.in_color(color_enabled)
900
- end
901
- end
902
- end
903
-
904
- context "qualified with #with_keywords + #with_unlimited_arguments" do
905
- it "produces the correct failure message when used in the positive" do
906
- as_both_colored_and_uncolored do |color_enabled|
907
- snippet = <<~TEST.strip
908
- expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz).with_keywords(:qux, :blargh).with_unlimited_arguments
909
- TEST
910
- program = make_plain_test_program(snippet, color_enabled: color_enabled)
911
-
912
- expected_output =
913
- build_expected_output(
914
- color_enabled: color_enabled,
915
- snippet:
916
- "expect(double(:something_really_long)).to respond_to(:foo, :bar, :baz).with_keywords(:qux, :blargh).with_unlimited_arguments",
917
- newline_before_expectation: true,
918
- expectation:
919
- proc do
920
- line do
921
- plain " Expected "
922
- actual "#<Double :something_really_long>"
923
- end
924
-
925
- line do
926
- plain "to respond to "
927
- expected ":foo"
928
- plain ", "
929
- expected ":bar"
930
- plain " and "
931
- expected ":baz"
932
- plain " with keywords "
933
- expected ":qux"
934
- plain " and "
935
- expected ":blargh"
936
- plain " and "
937
- expected "unlimited"
938
- plain " arguments"
939
- end
940
- end
941
- )
942
-
943
- expect(program).to produce_output_when_run(expected_output).in_color(
944
- color_enabled
945
- )
946
- end
947
- end
948
-
949
- it "produces the correct failure message when used in the negative" do
950
- as_both_colored_and_uncolored do |color_enabled|
951
- snippet = <<~TEST.strip
952
- class B
953
- def foo(*args, qux:, blargh:); end
954
- def bar(*args, qux:, blargh:); end
955
- def baz(*args, qux:, blargh:); end
956
- end
957
-
958
- expect(B.new).not_to respond_to(:foo, :bar, :baz).with_keywords(:qux, :blargh).with_unlimited_arguments
959
- TEST
960
- program = make_plain_test_program(snippet, color_enabled: color_enabled)
961
-
962
- expected_output =
963
- build_expected_output(
964
- color_enabled: color_enabled,
965
- snippet:
966
- "expect(B.new).not_to respond_to(:foo, :bar, :baz).with_keywords(:qux, :blargh).with_unlimited_arguments",
967
- newline_before_expectation: true,
968
- expectation:
969
- proc do
970
- line do
971
- plain " Expected "
972
- actual "#<B>"
973
- end
974
-
975
- line do
976
- plain "not to respond to "
977
- expected ":foo"
978
- plain ", "
979
- expected ":bar"
980
- plain " and "
981
- expected ":baz"
982
- plain " with keywords "
983
- expected ":qux"
984
- plain " and "
985
- expected ":blargh"
986
- plain " and "
987
- expected "unlimited"
988
- plain " arguments"
989
- end
990
- end
991
- )
992
-
993
- expect(program).to produce_output_when_run(
994
- expected_output
995
- ).removing_object_ids.in_color(color_enabled)
996
- end
997
- end
998
- end
999
- end