super_diff 0.4.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +64 -24
  3. data/lib/super_diff.rb +20 -17
  4. data/lib/super_diff/active_record.rb +20 -24
  5. data/lib/super_diff/active_record/diff_formatters/active_record_relation.rb +3 -3
  6. data/lib/super_diff/active_record/differs/active_record_relation.rb +3 -5
  7. data/lib/super_diff/active_record/object_inspection/inspectors/active_record_model.rb +32 -22
  8. data/lib/super_diff/active_record/object_inspection/inspectors/active_record_relation.rb +17 -7
  9. data/lib/super_diff/active_record/operation_tree_builders.rb +14 -0
  10. data/lib/super_diff/active_record/{operational_sequencers → operation_tree_builders}/active_record_model.rb +2 -2
  11. data/lib/super_diff/active_record/{operational_sequencers → operation_tree_builders}/active_record_relation.rb +4 -4
  12. data/lib/super_diff/active_record/{operation_sequences.rb → operation_trees.rb} +2 -2
  13. data/lib/super_diff/active_record/{operation_sequences → operation_trees}/active_record_relation.rb +2 -2
  14. data/lib/super_diff/active_support.rb +16 -19
  15. data/lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb +3 -3
  16. data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +3 -5
  17. data/lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb +17 -7
  18. data/lib/super_diff/active_support/operation_tree_builders.rb +10 -0
  19. data/lib/super_diff/active_support/{operational_sequencers → operation_tree_builders}/hash_with_indifferent_access.rb +2 -2
  20. data/lib/super_diff/active_support/{operation_sequences.rb → operation_trees.rb} +2 -2
  21. data/lib/super_diff/active_support/{operation_sequences → operation_trees}/hash_with_indifferent_access.rb +2 -2
  22. data/lib/super_diff/colorized_document_extensions.rb +4 -4
  23. data/lib/super_diff/configuration.rb +70 -0
  24. data/lib/super_diff/csi.rb +2 -1
  25. data/lib/super_diff/diff_formatters.rb +3 -3
  26. data/lib/super_diff/diff_formatters/array.rb +3 -3
  27. data/lib/super_diff/diff_formatters/base.rb +3 -2
  28. data/lib/super_diff/diff_formatters/collection.rb +3 -3
  29. data/lib/super_diff/diff_formatters/custom_object.rb +3 -3
  30. data/lib/super_diff/diff_formatters/default_object.rb +6 -8
  31. data/lib/super_diff/diff_formatters/defaults.rb +10 -0
  32. data/lib/super_diff/diff_formatters/hash.rb +3 -3
  33. data/lib/super_diff/diff_formatters/main.rb +41 -0
  34. data/lib/super_diff/diff_formatters/multiline_string.rb +7 -7
  35. data/lib/super_diff/differs.rb +4 -11
  36. data/lib/super_diff/differs/array.rb +2 -11
  37. data/lib/super_diff/differs/base.rb +20 -3
  38. data/lib/super_diff/differs/custom_object.rb +2 -11
  39. data/lib/super_diff/differs/default_object.rb +2 -8
  40. data/lib/super_diff/differs/defaults.rb +12 -0
  41. data/lib/super_diff/differs/hash.rb +2 -11
  42. data/lib/super_diff/differs/main.rb +48 -0
  43. data/lib/super_diff/differs/multiline_string.rb +2 -14
  44. data/lib/super_diff/differs/time_like.rb +15 -0
  45. data/lib/super_diff/equality_matchers.rb +3 -9
  46. data/lib/super_diff/equality_matchers/array.rb +3 -9
  47. data/lib/super_diff/equality_matchers/base.rb +1 -1
  48. data/lib/super_diff/equality_matchers/default.rb +3 -9
  49. data/lib/super_diff/equality_matchers/defaults.rb +12 -0
  50. data/lib/super_diff/equality_matchers/hash.rb +3 -9
  51. data/lib/super_diff/equality_matchers/main.rb +21 -0
  52. data/lib/super_diff/equality_matchers/multiline_string.rb +3 -9
  53. data/lib/super_diff/equality_matchers/primitive.rb +2 -2
  54. data/lib/super_diff/equality_matchers/singleline_string.rb +2 -2
  55. data/lib/super_diff/errors.rb +16 -0
  56. data/lib/super_diff/errors/no_diff_formatter_available_error.rb +21 -0
  57. data/lib/super_diff/errors/no_differ_available_error.rb +24 -0
  58. data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +22 -0
  59. data/lib/super_diff/gem_version.rb +45 -0
  60. data/lib/super_diff/implementation_checks.rb +19 -0
  61. data/lib/super_diff/object_inspection.rb +1 -10
  62. data/lib/super_diff/object_inspection/inspection_tree.rb +6 -2
  63. data/lib/super_diff/object_inspection/inspectors.rb +5 -1
  64. data/lib/super_diff/object_inspection/inspectors/array.rb +20 -10
  65. data/lib/super_diff/object_inspection/inspectors/base.rb +36 -0
  66. data/lib/super_diff/object_inspection/inspectors/custom_object.rb +24 -14
  67. data/lib/super_diff/object_inspection/inspectors/default_object.rb +44 -30
  68. data/lib/super_diff/object_inspection/inspectors/defaults.rb +15 -0
  69. data/lib/super_diff/object_inspection/inspectors/hash.rb +20 -10
  70. data/lib/super_diff/object_inspection/inspectors/main.rb +35 -0
  71. data/lib/super_diff/object_inspection/inspectors/primitive.rb +20 -5
  72. data/lib/super_diff/object_inspection/inspectors/string.rb +15 -5
  73. data/lib/super_diff/object_inspection/inspectors/time_like.rb +23 -0
  74. data/lib/super_diff/object_inspection/nodes/inspection.rb +9 -2
  75. data/lib/super_diff/operation_tree_builders.rb +18 -0
  76. data/lib/super_diff/{operational_sequencers → operation_tree_builders}/array.rb +38 -59
  77. data/lib/super_diff/operation_tree_builders/base.rb +98 -0
  78. data/lib/super_diff/{operational_sequencers → operation_tree_builders}/custom_object.rb +3 -3
  79. data/lib/super_diff/{operational_sequencers → operation_tree_builders}/default_object.rb +8 -3
  80. data/lib/super_diff/operation_tree_builders/defaults.rb +5 -0
  81. data/lib/super_diff/operation_tree_builders/hash.rb +226 -0
  82. data/lib/super_diff/operation_tree_builders/main.rb +42 -0
  83. data/lib/super_diff/{operational_sequencers → operation_tree_builders}/multiline_string.rb +3 -3
  84. data/lib/super_diff/operation_tree_builders/time_like.rb +34 -0
  85. data/lib/super_diff/operation_trees.rb +13 -0
  86. data/lib/super_diff/{operation_sequences → operation_trees}/array.rb +5 -1
  87. data/lib/super_diff/{operation_sequences → operation_trees}/base.rb +9 -1
  88. data/lib/super_diff/{operation_sequences → operation_trees}/custom_object.rb +5 -1
  89. data/lib/super_diff/{operation_sequences → operation_trees}/default_object.rb +10 -8
  90. data/lib/super_diff/operation_trees/defaults.rb +5 -0
  91. data/lib/super_diff/{operation_sequences → operation_trees}/hash.rb +5 -1
  92. data/lib/super_diff/operation_trees/main.rb +35 -0
  93. data/lib/super_diff/operation_trees/multiline_string.rb +18 -0
  94. data/lib/super_diff/operations/unary_operation.rb +3 -0
  95. data/lib/super_diff/recursion_guard.rb +2 -0
  96. data/lib/super_diff/rspec.rb +49 -13
  97. data/lib/super_diff/rspec/augmented_matcher.rb +1 -1
  98. data/lib/super_diff/rspec/differ.rb +2 -17
  99. data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +2 -7
  100. data/lib/super_diff/rspec/differs/collection_including.rb +2 -7
  101. data/lib/super_diff/rspec/differs/hash_including.rb +2 -7
  102. data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -7
  103. data/lib/super_diff/rspec/matcher_text_builders/base.rb +7 -7
  104. data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +6 -6
  105. data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +1 -1
  106. data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +4 -4
  107. data/lib/super_diff/rspec/matcher_text_builders/match.rb +1 -1
  108. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -1
  109. data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +6 -6
  110. data/lib/super_diff/rspec/matcher_text_template.rb +1 -1
  111. data/lib/super_diff/rspec/monkey_patches.rb +23 -14
  112. data/lib/super_diff/rspec/object_inspection.rb +0 -1
  113. data/lib/super_diff/rspec/object_inspection/inspectors.rb +16 -0
  114. data/lib/super_diff/rspec/object_inspection/inspectors/collection_containing_exactly.rb +17 -8
  115. data/lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb +15 -9
  116. data/lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb +20 -10
  117. data/lib/super_diff/rspec/object_inspection/inspectors/instance_of.rb +23 -0
  118. data/lib/super_diff/rspec/object_inspection/inspectors/kind_of.rb +23 -0
  119. data/lib/super_diff/rspec/object_inspection/inspectors/object_having_attributes.rb +20 -11
  120. data/lib/super_diff/rspec/object_inspection/inspectors/primitive.rb +13 -0
  121. data/lib/super_diff/rspec/object_inspection/inspectors/value_within.rb +29 -0
  122. data/lib/super_diff/rspec/operation_tree_builders.rb +22 -0
  123. data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_containing_exactly.rb +17 -6
  124. data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_including.rb +2 -2
  125. data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/hash_including.rb +3 -11
  126. data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/object_having_attributes.rb +4 -8
  127. data/lib/super_diff/version.rb +1 -1
  128. data/spec/examples.txt +393 -393
  129. data/spec/integration/rspec/be_falsey_matcher_spec.rb +10 -10
  130. data/spec/integration/rspec/be_matcher_spec.rb +100 -100
  131. data/spec/integration/rspec/be_nil_matcher_spec.rb +10 -10
  132. data/spec/integration/rspec/be_predicate_matcher_spec.rb +103 -103
  133. data/spec/integration/rspec/be_truthy_matcher_spec.rb +10 -10
  134. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +107 -107
  135. data/spec/integration/rspec/eq_matcher_spec.rb +230 -230
  136. data/spec/integration/rspec/have_attributes_matcher_spec.rb +360 -233
  137. data/spec/integration/rspec/have_predicate_matcher_spec.rb +65 -65
  138. data/spec/integration/rspec/include_matcher_spec.rb +73 -73
  139. data/spec/integration/rspec/match_array_matcher_spec.rb +149 -107
  140. data/spec/integration/rspec/match_matcher_spec.rb +274 -274
  141. data/spec/integration/rspec/raise_error_matcher_spec.rb +86 -86
  142. data/spec/integration/rspec/respond_to_matcher_spec.rb +240 -240
  143. data/spec/integration/rspec/third_party_matcher_spec.rb +8 -8
  144. data/spec/integration/rspec/unhandled_errors_spec.rb +69 -13
  145. data/spec/spec_helper.rb +22 -13
  146. data/spec/support/command_runner.rb +3 -0
  147. data/spec/support/integration/helpers.rb +15 -95
  148. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +15 -30
  149. data/spec/support/integration/test_programs/base.rb +122 -0
  150. data/spec/support/integration/test_programs/plain.rb +13 -0
  151. data/spec/support/integration/test_programs/rspec_active_record.rb +17 -0
  152. data/spec/support/integration/test_programs/rspec_active_support.rb +17 -0
  153. data/spec/support/integration/test_programs/rspec_rails.rb +17 -0
  154. data/spec/support/models/active_record/person.rb +4 -11
  155. data/spec/support/models/active_record/shipping_address.rb +10 -14
  156. data/spec/support/object_id.rb +6 -5
  157. data/spec/support/shared_examples/active_record.rb +108 -108
  158. data/spec/support/shared_examples/hash_with_indifferent_access.rb +196 -232
  159. data/spec/tmp/integration_spec.rb +15 -0
  160. data/spec/unit/{equality_matcher_spec.rb → equality_matchers/main_spec.rb} +518 -362
  161. data/spec/unit/object_inspection_spec.rb +77 -1
  162. data/super_diff.gemspec +3 -2
  163. metadata +83 -54
  164. data/lib/super_diff/active_record/object_inspection/map_extension.rb +0 -18
  165. data/lib/super_diff/active_record/operational_sequencers.rb +0 -14
  166. data/lib/super_diff/active_support/object_inspection/map_extension.rb +0 -15
  167. data/lib/super_diff/active_support/operational_sequencers.rb +0 -10
  168. data/lib/super_diff/diff_formatter.rb +0 -32
  169. data/lib/super_diff/differ.rb +0 -51
  170. data/lib/super_diff/differs/time.rb +0 -24
  171. data/lib/super_diff/equality_matcher.rb +0 -32
  172. data/lib/super_diff/no_differ_available_error.rb +0 -22
  173. data/lib/super_diff/no_operational_sequencer_available_error.rb +0 -20
  174. data/lib/super_diff/object_inspection/inspector.rb +0 -27
  175. data/lib/super_diff/object_inspection/inspectors/time.rb +0 -13
  176. data/lib/super_diff/object_inspection/map.rb +0 -30
  177. data/lib/super_diff/operation_sequences.rb +0 -9
  178. data/lib/super_diff/operational_sequencer.rb +0 -48
  179. data/lib/super_diff/operational_sequencers.rb +0 -17
  180. data/lib/super_diff/operational_sequencers/base.rb +0 -89
  181. data/lib/super_diff/operational_sequencers/hash.rb +0 -85
  182. data/lib/super_diff/operational_sequencers/time_like.rb +0 -30
  183. data/lib/super_diff/rspec/configuration.rb +0 -31
  184. data/lib/super_diff/rspec/object_inspection/map_extension.rb +0 -23
  185. data/lib/super_diff/rspec/operational_sequencers.rb +0 -22
@@ -26,12 +26,12 @@ module SuperDiff
26
26
  end
27
27
  end
28
28
 
29
- def beta_color
29
+ def actual_color
30
30
  :yellow
31
31
  end
32
32
 
33
33
  def add_actual_value
34
- template.add_text_in_color(beta_color) do
34
+ template.add_text_in_color(actual_color) do
35
35
  description_of(actual)
36
36
  end
37
37
  end
@@ -39,12 +39,12 @@ module SuperDiff
39
39
  def add_expected_value_to_failure_message(template)
40
40
  template.add_text " "
41
41
  template.add_text_in_color(
42
- alpha_color,
42
+ expected_color,
43
43
  "#{expected_for_failure_message}?",
44
44
  )
45
45
  template.add_text " or "
46
46
  template.add_text_in_color(
47
- alpha_color,
47
+ expected_color,
48
48
  "#{expected_for_failure_message}s?",
49
49
  )
50
50
  end
@@ -52,12 +52,12 @@ module SuperDiff
52
52
  def add_expected_value_to_description(template)
53
53
  template.add_text " "
54
54
  template.add_text_in_color(
55
- alpha_color,
55
+ expected_color,
56
56
  "`#{expected_for_description}?`",
57
57
  )
58
58
  template.add_text " or "
59
59
  template.add_text_in_color(
60
- alpha_color,
60
+ expected_color,
61
61
  "`#{expected_for_description}s?`",
62
62
  )
63
63
  end
@@ -6,7 +6,7 @@ module SuperDiff
6
6
 
7
7
  def add_expected_value_to(template, expected)
8
8
  template.add_text " "
9
- template.add_list_in_color(alpha_color, expected)
9
+ template.add_list_in_color(expected_color, expected)
10
10
  end
11
11
  end
12
12
  end
@@ -20,12 +20,12 @@ module SuperDiff
20
20
  end
21
21
  end
22
22
 
23
- def beta_color
23
+ def actual_color
24
24
  :yellow
25
25
  end
26
26
 
27
27
  def add_actual_value
28
- template.add_text_in_color(beta_color) do
28
+ template.add_text_in_color(actual_color) do
29
29
  description_of(actual)
30
30
  end
31
31
  end
@@ -33,7 +33,7 @@ module SuperDiff
33
33
  def add_expected_value_to_failure_message(template)
34
34
  template.add_text " "
35
35
  template.add_text_in_color(
36
- alpha_color,
36
+ expected_color,
37
37
  expected_for_failure_message,
38
38
  )
39
39
  end
@@ -41,7 +41,7 @@ module SuperDiff
41
41
  def add_expected_value_to_description(template)
42
42
  template.add_text " "
43
43
  template.add_text_in_color(
44
- alpha_color,
44
+ expected_color,
45
45
  "`#{expected_for_description}`",
46
46
  )
47
47
  end
@@ -3,7 +3,7 @@ module SuperDiff
3
3
  module MatcherTextBuilders
4
4
  class Match < Base
5
5
  def initialize(expected_captures:, **rest)
6
- super(rest)
6
+ super(**rest)
7
7
  @expected_captures = expected_captures
8
8
  end
9
9
 
@@ -14,7 +14,7 @@ module SuperDiff
14
14
 
15
15
  def add_actual_value
16
16
  if actual
17
- template.add_text_in_color(beta_color) { actual }
17
+ template.add_text_in_color(actual_color) { actual }
18
18
  else
19
19
  template.add_text("block")
20
20
  end
@@ -9,7 +9,7 @@ module SuperDiff
9
9
  unlimited_arguments:,
10
10
  **rest
11
11
  )
12
- super(rest)
12
+ super(**rest)
13
13
  @expected_arity = expected_arity
14
14
  @arbitrary_keywords = arbitrary_keywords
15
15
  @expected_keywords = expected_keywords
@@ -20,7 +20,7 @@ module SuperDiff
20
20
 
21
21
  def add_expected_value_to(template, expected)
22
22
  template.add_text " "
23
- template.add_list_in_color(alpha_color, expected)
23
+ template.add_list_in_color(expected_color, expected)
24
24
  end
25
25
 
26
26
  def add_extra_after_expected_to(template)
@@ -57,14 +57,14 @@ module SuperDiff
57
57
 
58
58
  def add_arity_clause_to(template)
59
59
  template.add_text " with "
60
- template.add_text_in_color alpha_color, expected_arity
60
+ template.add_text_in_color expected_color, expected_arity
61
61
  template.add_text " "
62
62
  template.add_text pluralize("argument", expected_arity)
63
63
  end
64
64
 
65
65
  def add_arbitrary_keywords_clause_to(template)
66
66
  template.add_text " with "
67
- template.add_text_in_color alpha_color, "any"
67
+ template.add_text_in_color expected_color, "any"
68
68
  template.add_text " keywords"
69
69
  end
70
70
 
@@ -72,7 +72,7 @@ module SuperDiff
72
72
  template.add_text " with "
73
73
  template.add_text pluralize("keyword", expected_keywords.length)
74
74
  template.add_text " "
75
- template.add_list_in_color alpha_color, expected_keywords
75
+ template.add_list_in_color expected_color, expected_keywords
76
76
  end
77
77
 
78
78
  def add_unlimited_arguments_clause_to(template)
@@ -82,7 +82,7 @@ module SuperDiff
82
82
  template.add_text " with "
83
83
  end
84
84
 
85
- template.add_text_in_color alpha_color, "unlimited"
85
+ template.add_text_in_color expected_color, "unlimited"
86
86
  template.add_text " arguments"
87
87
  end
88
88
 
@@ -3,7 +3,7 @@ module SuperDiff
3
3
  class MatcherTextTemplate
4
4
  MAX_LINE_LENGTH = 100
5
5
 
6
- def self.generate(&block)
6
+ def self.render(&block)
7
7
  new(&block).to_s
8
8
  end
9
9
 
@@ -9,6 +9,7 @@ require "rspec/matchers/built_in/eq"
9
9
  require "rspec/matchers/built_in/have_attributes"
10
10
  require "rspec/matchers/built_in/include"
11
11
  require "rspec/matchers/built_in/match"
12
+ require "rspec/version"
12
13
 
13
14
  module RSpec
14
15
  module Expectations
@@ -272,34 +273,34 @@ module RSpec
272
273
  return expected if self === expected
273
274
 
274
275
  text =
275
- colorizer.wrap("Diff:", SuperDiff::COLORS.fetch(:header)) +
276
+ colorizer.wrap("Diff:", SuperDiff.configuration.header_color) +
276
277
  "\n\n" +
277
278
  colorizer.wrap(
278
279
  "┌ (Key) ──────────────────────────┐",
279
- SuperDiff::COLORS.fetch(:border)
280
+ SuperDiff.configuration.border_color
280
281
  ) +
281
282
  "\n" +
282
- colorizer.wrap("│ ", SuperDiff::COLORS.fetch(:border)) +
283
+ colorizer.wrap("│ ", SuperDiff.configuration.border_color) +
283
284
  colorizer.wrap(
284
285
  "‹-› in expected, not in actual",
285
- SuperDiff::COLORS.fetch(:alpha)
286
+ SuperDiff.configuration.expected_color
286
287
  ) +
287
- colorizer.wrap(" │", SuperDiff::COLORS.fetch(:border)) +
288
+ colorizer.wrap(" │", SuperDiff.configuration.border_color) +
288
289
  "\n" +
289
- colorizer.wrap("│ ", SuperDiff::COLORS.fetch(:border)) +
290
+ colorizer.wrap("│ ", SuperDiff.configuration.border_color) +
290
291
  colorizer.wrap(
291
292
  "‹+› in actual, not in expected",
292
- SuperDiff::COLORS.fetch(:beta)
293
+ SuperDiff.configuration.actual_color
293
294
  ) +
294
- colorizer.wrap(" │", SuperDiff::COLORS.fetch(:border)) +
295
+ colorizer.wrap(" │", SuperDiff.configuration.border_color) +
295
296
  "\n" +
296
- colorizer.wrap("│ ", SuperDiff::COLORS.fetch(:border)) +
297
+ colorizer.wrap("│ ", SuperDiff.configuration.border_color) +
297
298
  "‹ › in both expected and actual" +
298
- colorizer.wrap(" │", SuperDiff::COLORS.fetch(:border)) +
299
+ colorizer.wrap(" │", SuperDiff.configuration.border_color) +
299
300
  "\n" +
300
301
  colorizer.wrap(
301
302
  "└─────────────────────────────────┘",
302
- SuperDiff::COLORS.fetch(:border)
303
+ SuperDiff.configuration.border_color
303
304
  )
304
305
 
305
306
  new([[expected, text]])
@@ -394,7 +395,11 @@ module RSpec
394
395
  end
395
396
 
396
397
  def expected_for_matcher_text
397
- expected
398
+ if SuperDiff::RSpec.rspec_version < "3.10"
399
+ expected
400
+ else
401
+ predicate.to_s.chomp('?')
402
+ end
398
403
  end
399
404
 
400
405
  def expected_action_for_matcher_text
@@ -545,7 +550,11 @@ module RSpec
545
550
  end
546
551
 
547
552
  def expected_for_matcher_text
548
- "#{predicate}#{failure_message_args_description}"
553
+ if SuperDiff::RSpec.rspec_version < "3.10"
554
+ "#{predicate}#{failure_message_args_description}"
555
+ else
556
+ "#{predicate}#{args_to_s}"
557
+ end
549
558
  end
550
559
 
551
560
  def expected_action_for_matcher_text
@@ -729,7 +738,7 @@ module RSpec
729
738
  end
730
739
 
731
740
  def match_array(items)
732
- BuiltIn::MatchArray.new(items)
741
+ BuiltIn::MatchArray.new(items.is_a?(String) ? [items] : items)
733
742
  end
734
743
  alias_matcher :an_array_matching, :match_array
735
744
  end
@@ -2,7 +2,6 @@ module SuperDiff
2
2
  module RSpec
3
3
  module ObjectInspection
4
4
  autoload :Inspectors, "super_diff/rspec/object_inspection/inspectors"
5
- autoload :MapExtension, "super_diff/rspec/object_inspection/map_extension"
6
5
  end
7
6
  end
8
7
  end
@@ -14,10 +14,26 @@ module SuperDiff
14
14
  :HashIncluding,
15
15
  "super_diff/rspec/object_inspection/inspectors/hash_including",
16
16
  )
17
+ autoload(
18
+ :InstanceOf,
19
+ "super_diff/rspec/object_inspection/inspectors/instance_of",
20
+ )
21
+ autoload(
22
+ :KindOf,
23
+ "super_diff/rspec/object_inspection/inspectors/kind_of",
24
+ )
17
25
  autoload(
18
26
  :ObjectHavingAttributes,
19
27
  "super_diff/rspec/object_inspection/inspectors/object_having_attributes",
20
28
  )
29
+ autoload(
30
+ :Primitive,
31
+ "super_diff/rspec/object_inspection/inspectors/primitive",
32
+ )
33
+ autoload(
34
+ :ValueWithin,
35
+ "super_diff/rspec/object_inspection/inspectors/value_within",
36
+ )
21
37
  end
22
38
  end
23
39
  end
@@ -2,17 +2,26 @@ module SuperDiff
2
2
  module RSpec
3
3
  module ObjectInspection
4
4
  module Inspectors
5
- CollectionContainingExactly =
6
- SuperDiff::ObjectInspection::InspectionTree.new do
7
- add_text "#<a collection containing exactly ("
5
+ class CollectionContainingExactly < SuperDiff::ObjectInspection::Inspectors::Base
6
+ def self.applies_to?(value)
7
+ SuperDiff::RSpec.a_collection_containing_exactly_something?(value)
8
+ end
8
9
 
9
- nested do |aliased_matcher|
10
- insert_array_inspection_of(aliased_matcher.expected)
11
- end
10
+ protected
11
+
12
+ def inspection_tree
13
+ SuperDiff::ObjectInspection::InspectionTree.new do
14
+ add_text "#<a collection containing exactly ("
12
15
 
13
- add_break
14
- add_text ")>"
16
+ nested do |aliased_matcher|
17
+ insert_array_inspection_of(aliased_matcher.expected)
18
+ end
19
+
20
+ add_break
21
+ add_text ")>"
22
+ end
15
23
  end
24
+ end
16
25
  end
17
26
  end
18
27
  end
@@ -2,19 +2,25 @@ module SuperDiff
2
2
  module RSpec
3
3
  module ObjectInspection
4
4
  module Inspectors
5
- CollectionIncluding = SuperDiff::ObjectInspection::InspectionTree.new do
6
- def self.applies_to?(object)
7
- SuperDiff::RSpec.a_collection_including?(object)
5
+ class CollectionIncluding < SuperDiff::ObjectInspection::Inspectors::Base
6
+ def self.applies_to?(value)
7
+ SuperDiff::RSpec.a_collection_including_something?(value)
8
8
  end
9
9
 
10
- add_text "#<a collection including ("
10
+ protected
11
11
 
12
- nested do |aliased_matcher|
13
- insert_array_inspection_of(aliased_matcher.expecteds)
14
- end
12
+ def inspection_tree
13
+ SuperDiff::ObjectInspection::InspectionTree.new do
14
+ add_text "#<a collection including ("
15
+
16
+ nested do |aliased_matcher|
17
+ insert_array_inspection_of(aliased_matcher.expecteds)
18
+ end
15
19
 
16
- add_break
17
- add_text ")>"
20
+ add_break
21
+ add_text ")>"
22
+ end
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -2,18 +2,28 @@ module SuperDiff
2
2
  module RSpec
3
3
  module ObjectInspection
4
4
  module Inspectors
5
- HashIncluding = SuperDiff::ObjectInspection::InspectionTree.new do
6
- add_text "#<a hash including ("
7
-
8
- nested do |aliased_matcher|
9
- insert_hash_inspection_of(
10
- aliased_matcher.expecteds.first,
11
- initial_break: nil,
12
- )
5
+ class HashIncluding < SuperDiff::ObjectInspection::Inspectors::Base
6
+ def self.applies_to?(value)
7
+ SuperDiff::RSpec.a_hash_including_something?(value)
13
8
  end
14
9
 
15
- add_break
16
- add_text ")>"
10
+ protected
11
+
12
+ def inspection_tree
13
+ SuperDiff::ObjectInspection::InspectionTree.new do
14
+ add_text "#<a hash including ("
15
+
16
+ nested do |aliased_matcher|
17
+ insert_hash_inspection_of(
18
+ aliased_matcher.expecteds.first,
19
+ initial_break: nil,
20
+ )
21
+ end
22
+
23
+ add_break
24
+ add_text ")>"
25
+ end
26
+ end
17
27
  end
18
28
  end
19
29
  end
@@ -0,0 +1,23 @@
1
+ module SuperDiff
2
+ module RSpec
3
+ module ObjectInspection
4
+ module Inspectors
5
+ class InstanceOf < SuperDiff::ObjectInspection::Inspectors::Base
6
+ def self.applies_to?(value)
7
+ SuperDiff::RSpec.an_instance_of_something?(value)
8
+ end
9
+
10
+ protected
11
+
12
+ def inspection_tree
13
+ SuperDiff::ObjectInspection::InspectionTree.new do
14
+ add_text do |aliased_matcher|
15
+ "#<an instance of #{aliased_matcher.expected}>"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module SuperDiff
2
+ module RSpec
3
+ module ObjectInspection
4
+ module Inspectors
5
+ class KindOf < SuperDiff::ObjectInspection::Inspectors::Base
6
+ def self.applies_to?(value)
7
+ SuperDiff::RSpec.a_kind_of_something?(value)
8
+ end
9
+
10
+ protected
11
+
12
+ def inspection_tree
13
+ SuperDiff::ObjectInspection::InspectionTree.new do
14
+ add_text do |aliased_matcher|
15
+ "#<a kind of #{aliased_matcher.expected}>"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end