super_diff 0.10.0 → 0.11.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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +24 -12
  3. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +15 -6
  4. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +23 -8
  5. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/ordered_options.rb +46 -0
  6. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +4 -0
  7. data/lib/super_diff/active_support.rb +2 -1
  8. data/lib/super_diff/differs/date_like.rb +15 -0
  9. data/lib/super_diff/differs/defaults.rb +1 -0
  10. data/lib/super_diff/differs.rb +1 -0
  11. data/lib/super_diff/errors.rb +0 -4
  12. data/lib/super_diff/object_inspection/inspection_tree.rb +25 -20
  13. data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +31 -12
  14. data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +19 -9
  15. data/lib/super_diff/object_inspection/inspection_tree_builders/date_like.rb +51 -0
  16. data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +46 -21
  17. data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -0
  18. data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +39 -14
  19. data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +3 -5
  20. data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +31 -20
  21. data/lib/super_diff/object_inspection/inspection_tree_builders.rb +4 -0
  22. data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +3 -2
  23. data/lib/super_diff/operation_tree_builders/date_like.rb +15 -0
  24. data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
  25. data/lib/super_diff/operation_tree_builders.rb +1 -0
  26. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +3 -7
  27. data/lib/super_diff/rspec/monkey_patches.rb +59 -8
  28. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_containing_exactly.rb +14 -7
  29. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +19 -13
  30. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +30 -26
  31. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/generic_describable_matcher.rb +19 -0
  32. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +19 -14
  33. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +9 -10
  34. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +9 -10
  35. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/object_having_attributes.rb +14 -7
  36. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +10 -11
  37. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +4 -0
  38. data/lib/super_diff/rspec.rb +10 -9
  39. data/lib/super_diff/version.rb +1 -1
  40. data/lib/super_diff.rb +9 -0
  41. data/spec/examples.txt +543 -493
  42. data/spec/integration/rails/engines_spec.rb +8 -3
  43. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +19 -19
  44. data/spec/integration/rspec/eq_matcher_spec.rb +111 -39
  45. data/spec/integration/rspec/generic_describable_matchers_spec.rb +177 -0
  46. data/spec/integration/rspec/have_attributes_matcher_spec.rb +25 -25
  47. data/spec/integration/rspec/include_matcher_spec.rb +23 -23
  48. data/spec/integration/rspec/magic_metadata_spec.rb +51 -0
  49. data/spec/integration/rspec/match_array_matcher_spec.rb +30 -30
  50. data/spec/integration/rspec/match_matcher_spec.rb +93 -93
  51. data/spec/integration/rspec/raise_error_matcher_spec.rb +813 -69
  52. data/spec/internal/log/test.log +0 -0
  53. data/spec/spec_helper.rb +3 -0
  54. data/spec/support/integration/helpers.rb +15 -10
  55. data/spec/support/integration/matchers.rb +34 -0
  56. data/spec/support/integration/test_programs/base.rb +6 -6
  57. data/spec/support/integration/test_programs/rspec_rails_engine.rb +3 -13
  58. data/spec/support/shared_examples/active_record.rb +33 -33
  59. data/spec/support/shared_examples/active_support.rb +125 -4
  60. data/spec/support/shared_examples/elided_diffs.rb +48 -48
  61. data/spec/support/shared_examples/hash_with_indifferent_access.rb +88 -88
  62. data/spec/support/shared_examples/key.rb +10 -10
  63. data/spec/unit/active_support/object_inspection_spec.rb +170 -0
  64. data/spec/unit/rspec/matchers/raise_error_spec.rb +43 -11
  65. data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +91 -0
  66. data/spec/unit/rspec/object_inspection_spec.rb +2 -2
  67. data/spec/unit/super_diff_spec.rb +64 -0
  68. metadata +17 -4
  69. data/lib/super_diff/errors/no_diff_formatter_available_error.rb +0 -21
  70. data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +0 -22
@@ -7,31 +7,56 @@ module SuperDiff
7
7
  end
8
8
 
9
9
  def call
10
- empty = -> { object.empty? }
11
- nonempty = -> { !object.empty? }
12
-
13
- InspectionTree.new do
14
- only_when empty do
15
- as_lines_when_rendering_to_lines { add_text "{}" }
10
+ InspectionTree.new do |t1|
11
+ t1.only_when empty do |t2|
12
+ # stree-ignore
13
+ t2.as_lines_when_rendering_to_lines do |t3|
14
+ t3.add_text "{}"
15
+ end
16
16
  end
17
17
 
18
- only_when nonempty do
19
- as_lines_when_rendering_to_lines(collection_bookend: :open) do
20
- add_text "{"
18
+ t1.only_when nonempty do |t2|
19
+ # stree-ignore
20
+ t2.as_lines_when_rendering_to_lines(
21
+ collection_bookend: :open
22
+ ) do |t3|
23
+ t3.add_text "{"
21
24
  end
22
25
 
23
- when_rendering_to_string { add_text " " }
26
+ # stree-ignore
27
+ t2.when_rendering_to_string do |t3|
28
+ t3.add_text " "
29
+ end
24
30
 
25
- nested { |hash| insert_hash_inspection_of(hash) }
31
+ # stree-ignore
32
+ t2.nested do |t3|
33
+ t3.insert_hash_inspection_of(object)
34
+ end
26
35
 
27
- when_rendering_to_string { add_text " " }
36
+ # stree-ignore
37
+ t2.when_rendering_to_string do |t3|
38
+ t3.add_text " "
39
+ end
28
40
 
29
- as_lines_when_rendering_to_lines(collection_bookend: :close) do
30
- add_text "}"
41
+ # stree-ignore
42
+ t2.as_lines_when_rendering_to_lines(
43
+ collection_bookend: :close
44
+ ) do |t3|
45
+ t3.add_text "}"
31
46
  end
32
47
  end
33
48
  end
34
49
  end
50
+
51
+ private
52
+
53
+ def empty
54
+ -> { object.empty? }
55
+ end
56
+
57
+ def nonempty
58
+ -> { !object.empty? }
59
+ end
35
60
  end
36
61
  end
37
62
  end
@@ -7,11 +7,9 @@ module SuperDiff
7
7
  end
8
8
 
9
9
  def call
10
- InspectionTree.new do
11
- as_lines_when_rendering_to_lines do
12
- # rubocop:disable Style/SymbolProc
13
- add_text { |object| object.inspect }
14
- # rubocop:enable Style/SymbolProc
10
+ InspectionTree.new do |t1|
11
+ t1.as_lines_when_rendering_to_lines do |t2|
12
+ t2.add_text object.inspect
15
13
  end
16
14
  end
17
15
  end
@@ -7,37 +7,48 @@ module SuperDiff
7
7
  end
8
8
 
9
9
  def call
10
- InspectionTree.new do
11
- as_lines_when_rendering_to_lines(collection_bookend: :open) do
12
- add_text { |time| "#<#{time.class} " }
10
+ InspectionTree.new do |t1|
11
+ t1.as_lines_when_rendering_to_lines(
12
+ collection_bookend: :open
13
+ ) do |t2|
14
+ t2.add_text "#<#{object.class} "
13
15
 
14
- when_rendering_to_lines { add_text "{" }
16
+ # stree-ignore
17
+ t2.when_rendering_to_lines do |t3|
18
+ t3.add_text "{"
19
+ end
15
20
  end
16
21
 
17
- when_rendering_to_string do
18
- add_text do |time|
19
- time.strftime("%Y-%m-%d %H:%M:%S") +
20
- (time.subsec == 0 ? "" : "+#{time.subsec.inspect}") + " " +
21
- time.strftime("%:z") + (time.zone ? " (#{time.zone})" : "")
22
- end
22
+ t1.when_rendering_to_string do |t2|
23
+ t2.add_text(
24
+ object.strftime("%Y-%m-%d %H:%M:%S") +
25
+ (object.subsec == 0 ? "" : "+#{object.subsec.inspect}") +
26
+ " " + object.strftime("%:z") +
27
+ (object.zone ? " (#{object.zone})" : "")
28
+ )
23
29
  end
24
30
 
25
- when_rendering_to_lines do
26
- nested do |time|
27
- insert_separated_list(
31
+ t1.when_rendering_to_lines do |t2|
32
+ t2.nested do |t3|
33
+ t3.insert_separated_list(
28
34
  %i[year month day hour min sec subsec zone utc_offset]
29
- ) do |name|
30
- add_text name.to_s
31
- add_text ": "
32
- add_inspection_of time.public_send(name)
35
+ ) do |t4, name|
36
+ t4.add_text name.to_s
37
+ t4.add_text ": "
38
+ t4.add_inspection_of object.public_send(name)
33
39
  end
34
40
  end
35
41
  end
36
42
 
37
- as_lines_when_rendering_to_lines(collection_bookend: :close) do
38
- when_rendering_to_lines { add_text "}" }
43
+ t1.as_lines_when_rendering_to_lines(
44
+ collection_bookend: :close
45
+ ) do |t2|
46
+ # stree-ignore
47
+ t2.when_rendering_to_lines do |t3|
48
+ t3.add_text "}"
49
+ end
39
50
 
40
- add_text ">"
51
+ t2.add_text ">"
41
52
  end
42
53
  end
43
54
  end
@@ -37,6 +37,10 @@ module SuperDiff
37
37
  :TimeLike,
38
38
  "super_diff/object_inspection/inspection_tree_builders/time_like"
39
39
  )
40
+ autoload(
41
+ :DateLike,
42
+ "super_diff/object_inspection/inspection_tree_builders/date_like"
43
+ )
40
44
  end
41
45
  end
42
46
  end
@@ -15,9 +15,10 @@ module SuperDiff
15
15
  *args,
16
16
  add_comma: false,
17
17
  collection_bookend: nil,
18
- **rest
18
+ **rest,
19
+ &block
19
20
  )
20
- super(tree, *args, **rest)
21
+ super(tree, *args, **rest, &block)
21
22
 
22
23
  @add_comma = add_comma
23
24
  @collection_bookend = collection_bookend
@@ -0,0 +1,15 @@
1
+ module SuperDiff
2
+ module OperationTreeBuilders
3
+ class DateLike < CustomObject
4
+ def self.applies_to?(expected, actual)
5
+ SuperDiff.date_like?(expected) && SuperDiff.date_like?(actual)
6
+ end
7
+
8
+ protected
9
+
10
+ def attribute_names
11
+ %w[year month day]
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module SuperDiff
2
2
  module OperationTreeBuilders
3
- DEFAULTS = [Array, Hash, TimeLike, CustomObject].freeze
3
+ DEFAULTS = [Array, Hash, TimeLike, DateLike, CustomObject].freeze
4
4
  end
5
5
  end
@@ -12,6 +12,7 @@ module SuperDiff
12
12
  "super_diff/operation_tree_builders/multiline_string"
13
13
  )
14
14
  autoload :TimeLike, "super_diff/operation_tree_builders/time_like"
15
+ autoload :DateLike, "super_diff/operation_tree_builders/date_like"
15
16
  end
16
17
  end
17
18
 
@@ -5,14 +5,10 @@ module SuperDiff
5
5
  protected
6
6
 
7
7
  def actual_phrase
8
- actual ? "Expected raised exception" : "Expected"
9
- end
10
-
11
- def add_actual_value
12
- if actual
13
- template.add_text_in_color(actual_color) { actual }
8
+ if actual == "exception-free block"
9
+ "Expected"
14
10
  else
15
- template.add_text("block")
11
+ "Expected raised exception"
16
12
  end
17
13
  end
18
14
  end
@@ -218,7 +218,10 @@ module RSpec
218
218
  }
219
219
  end
220
220
  end
221
-
221
+ @failure_line_groups << {
222
+ lines: extra_failure_lines,
223
+ already_colorized: true
224
+ }
222
225
  @failure_line_groups
223
226
  end
224
227
  end
@@ -241,6 +244,24 @@ module RSpec
241
244
  lines
242
245
  end
243
246
 
247
+ # Override to ensure that each item in the array returned is one and
248
+ # only one line and doesn't contain any newline characters
249
+ def extra_failure_lines
250
+ @extra_failure_lines ||=
251
+ begin
252
+ original_lines = Array(example.metadata[:extra_failure_lines])
253
+ normalized_lines =
254
+ original_lines.flat_map { |line| line.split("\n") }
255
+ unless normalized_lines.empty?
256
+ unless normalized_lines.first == ""
257
+ normalized_lines.unshift("")
258
+ end
259
+ normalized_lines.push("") unless normalized_lines.last == ""
260
+ end
261
+ normalized_lines
262
+ end
263
+ end
264
+
244
265
  # Exclude this file from being included in backtraces, so that the
245
266
  # SnippetExtractor prints the right thing
246
267
  def find_failed_line
@@ -701,9 +722,15 @@ module RSpec
701
722
  SuperDiff.insert_overrides(self, SuperDiff::RSpec::AugmentedMatcher)
702
723
 
703
724
  SuperDiff.insert_overrides(self) do
725
+ def expected_action_for_description
726
+ "raise"
727
+ end
728
+
704
729
  def actual_for_matcher_text
705
730
  if @actual_error
706
731
  "#<#{@actual_error.class.name} #{@actual_error.message.inspect}>"
732
+ else
733
+ "exception-free block"
707
734
  end
708
735
  end
709
736
 
@@ -712,12 +739,19 @@ module RSpec
712
739
  end
713
740
 
714
741
  def expected_for_matcher_text
715
- if @expected_message
716
- "#<#{@expected_error.name} #{description_of(@expected_message)}>"
717
- elsif @expected_error.is_a? Regexp
718
- "#<Exception #{description_of(@expected_error)}>"
742
+ case @expected_message
743
+ when nil
744
+ if RSpec::Matchers.is_a_describable_matcher?(@expected_error)
745
+ description_of(@expected_error)
746
+ elsif @expected_error.is_a?(Regexp)
747
+ "a kind of Exception with message matching #{description_of(@expected_error)}"
748
+ else
749
+ "a kind of #{@expected_error}"
750
+ end
751
+ when Regexp
752
+ "#{described_expected_error} with message matching #{description_of(@expected_message)}"
719
753
  else
720
- "#<#{@expected_error.name}>"
754
+ "#{described_expected_error} with message #{description_of(@expected_message)}"
721
755
  end
722
756
  end
723
757
 
@@ -730,12 +764,22 @@ module RSpec
730
764
  end
731
765
 
732
766
  def expected_action_for_failure_message
733
- @actual_error ? "match" : "raise error"
767
+ @actual_error ? "match" : "raise"
734
768
  end
735
769
 
736
770
  def matcher_text_builder_class
737
771
  SuperDiff::RSpec::MatcherTextBuilders::RaiseError
738
772
  end
773
+
774
+ private
775
+
776
+ def described_expected_error
777
+ if @expected_error.is_a?(Class)
778
+ "a kind of #{@expected_error}"
779
+ else
780
+ description_of(@expected_error)
781
+ end
782
+ end
739
783
  end
740
784
 
741
785
  def self.matcher_name
@@ -782,7 +826,14 @@ module RSpec
782
826
  end
783
827
 
784
828
  def match_array(items)
785
- BuiltIn::MatchArray.new(items.is_a?(String) ? [items] : items)
829
+ # This is a bit strange, but this is fundamentally different from
830
+ # splatting `items` in the argument list. It's functionally equivalent
831
+ # to, though not quite the same as:
832
+ #
833
+ # items.is_a?(Array) ? items : [items]
834
+ #
835
+ items = *items
836
+ BuiltIn::MatchArray.new(items)
786
837
  end
787
838
  end
788
839
  end
@@ -8,17 +8,24 @@ module SuperDiff
8
8
  end
9
9
 
10
10
  def call
11
- SuperDiff::ObjectInspection::InspectionTree.new do
12
- as_lines_when_rendering_to_lines(collection_bookend: :open) do
13
- add_text "#<a collection containing exactly ("
11
+ SuperDiff::ObjectInspection::InspectionTree.new do |t1|
12
+ # stree-ignore
13
+ t1.as_lines_when_rendering_to_lines(
14
+ collection_bookend: :open
15
+ ) do |t2|
16
+ t2.add_text "#<a collection containing exactly ("
14
17
  end
15
18
 
16
- nested do |aliased_matcher|
17
- insert_array_inspection_of(aliased_matcher.expected)
19
+ # stree-ignore
20
+ t1.nested do |t2|
21
+ t2.insert_array_inspection_of(object.expected)
18
22
  end
19
23
 
20
- as_lines_when_rendering_to_lines(collection_bookend: :close) do
21
- add_text ")>"
24
+ # stree-ignore
25
+ t1.as_lines_when_rendering_to_lines(
26
+ collection_bookend: :close
27
+ ) do |t2|
28
+ t2.add_text ")>"
22
29
  end
23
30
  end
24
31
  end
@@ -9,23 +9,29 @@ module SuperDiff
9
9
  end
10
10
 
11
11
  def call
12
- SuperDiff::ObjectInspection::InspectionTree.new do
13
- as_lines_when_rendering_to_lines(collection_bookend: :open) do
14
- add_text "#<a collection including ("
12
+ SuperDiff::ObjectInspection::InspectionTree.new do |t1|
13
+ # stree-ignore
14
+ t1.as_lines_when_rendering_to_lines(
15
+ collection_bookend: :open
16
+ ) do |t2|
17
+ t2.add_text "#<a collection including ("
15
18
  end
16
19
 
17
- nested do |value|
18
- array =
19
- if SuperDiff::RSpec.a_collection_including_something?(value)
20
- value.expecteds
21
- else
22
- value.instance_variable_get(:@expected)
23
- end
24
- insert_array_inspection_of(array)
20
+ t1.nested do |t2|
21
+ if SuperDiff::RSpec.a_collection_including_something?(object)
22
+ t2.insert_array_inspection_of(object.expecteds)
23
+ else
24
+ t2.insert_array_inspection_of(
25
+ object.instance_variable_get(:@expected)
26
+ )
27
+ end
25
28
  end
26
29
 
27
- as_lines_when_rendering_to_lines(collection_bookend: :close) do
28
- add_text ")>"
30
+ # stree-ignore
31
+ t1.as_lines_when_rendering_to_lines(
32
+ collection_bookend: :close
33
+ ) do |t2|
34
+ t2.add_text ")>"
29
35
  end
30
36
  end
31
37
  end
@@ -8,47 +8,51 @@ module SuperDiff
8
8
  end
9
9
 
10
10
  def call
11
- builder = self
12
- empty = -> { empty? }
13
- nonempty = -> { !empty? }
14
-
15
- SuperDiff::ObjectInspection::InspectionTree.new do
16
- only_when empty do
17
- as_lines_when_rendering_to_lines do
18
- add_text do |object|
19
- inspected_class = builder.inspected_class
20
- inspected_name = builder.inspected_name
21
- "#<#{inspected_class} #{inspected_name}>"
22
- end
11
+ SuperDiff::ObjectInspection::InspectionTree.new do |t1|
12
+ t1.only_when method(:empty?) do |t2|
13
+ t2.as_lines_when_rendering_to_lines do |t3|
14
+ t3.add_text("#<#{inspected_class} #{inspected_name}>")
23
15
  end
24
16
  end
25
17
 
26
- only_when nonempty do
27
- as_lines_when_rendering_to_lines(collection_bookend: :open) do
28
- add_text do |object|
29
- inspected_class = builder.inspected_class
30
- inspected_name = builder.inspected_name
31
- "#<#{inspected_class} #{inspected_name}"
32
- end
18
+ t1.only_when method(:nonempty?) do |t2|
19
+ t2.as_lines_when_rendering_to_lines(
20
+ collection_bookend: :open
21
+ ) do |t3|
22
+ t3.add_text("#<#{inspected_class} #{inspected_name}")
33
23
 
34
- when_rendering_to_lines { add_text " {" }
24
+ # stree-ignore
25
+ t3.when_rendering_to_lines do |t4|
26
+ t4.add_text " {"
27
+ end
35
28
  end
36
29
 
37
- when_rendering_to_string { add_text " " }
30
+ # stree-ignore
31
+ t2.when_rendering_to_string do |t3|
32
+ t3.add_text " "
33
+ end
38
34
 
39
- nested do |object|
40
- insert_hash_inspection_of(builder.doubled_methods)
35
+ # stree-ignore
36
+ t2.nested do |t3|
37
+ t3.insert_hash_inspection_of doubled_methods
41
38
  end
42
39
 
43
- as_lines_when_rendering_to_lines(collection_bookend: :close) do
44
- when_rendering_to_lines { add_text "}" }
40
+ t2.as_lines_when_rendering_to_lines(
41
+ collection_bookend: :close
42
+ ) do |t3|
43
+ # stree-ignore
44
+ t3.when_rendering_to_lines do |t4|
45
+ t4.add_text "}"
46
+ end
45
47
 
46
- add_text ">"
48
+ t3.add_text ">"
47
49
  end
48
50
  end
49
51
  end
50
52
  end
51
53
 
54
+ private
55
+
52
56
  def empty?
53
57
  doubled_methods.empty?
54
58
  end
@@ -0,0 +1,19 @@
1
+ module SuperDiff
2
+ module RSpec
3
+ module ObjectInspection
4
+ module InspectionTreeBuilders
5
+ class GenericDescribableMatcher < SuperDiff::ObjectInspection::InspectionTreeBuilders::Base
6
+ def self.applies_to?(value)
7
+ ::RSpec::Matchers.is_a_describable_matcher?(value)
8
+ end
9
+
10
+ def call
11
+ SuperDiff::ObjectInspection::InspectionTree.new do |t1|
12
+ t1.add_text "#<#{object.description}>"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -9,24 +9,29 @@ module SuperDiff
9
9
  end
10
10
 
11
11
  def call
12
- SuperDiff::ObjectInspection::InspectionTree.new do
13
- as_lines_when_rendering_to_lines(collection_bookend: :open) do
14
- add_text "#<a hash including ("
12
+ SuperDiff::ObjectInspection::InspectionTree.new do |t1|
13
+ # stree-ignore
14
+ t1.as_lines_when_rendering_to_lines(
15
+ collection_bookend: :open
16
+ ) do |t2|
17
+ t2.add_text "#<a hash including ("
15
18
  end
16
19
 
17
- nested do |value|
18
- hash =
19
- if SuperDiff::RSpec.a_hash_including_something?(value)
20
- value.expecteds.first
21
- else
22
- value.instance_variable_get(:@expected)
23
- end
24
-
25
- insert_hash_inspection_of(hash)
20
+ t1.nested do |t2|
21
+ if SuperDiff::RSpec.a_hash_including_something?(object)
22
+ t2.insert_hash_inspection_of(object.expecteds.first)
23
+ else
24
+ t2.insert_hash_inspection_of(
25
+ object.instance_variable_get(:@expected)
26
+ )
27
+ end
26
28
  end
27
29
 
28
- as_lines_when_rendering_to_lines(collection_bookend: :close) do
29
- add_text ")>"
30
+ # stree-ignore
31
+ t1.as_lines_when_rendering_to_lines(
32
+ collection_bookend: :close
33
+ ) do |t2|
34
+ t2.add_text ")>"
30
35
  end
31
36
  end
32
37
  end
@@ -9,16 +9,15 @@ module SuperDiff
9
9
  end
10
10
 
11
11
  def call
12
- SuperDiff::ObjectInspection::InspectionTree.new do
13
- add_text do |value|
14
- klass =
15
- if SuperDiff::RSpec.an_instance_of_something?(value)
16
- value.expected
17
- else
18
- value.instance_variable_get(:@klass)
19
- end
20
- "#<an instance of #{klass}>"
21
- end
12
+ SuperDiff::ObjectInspection::InspectionTree.new do |t1|
13
+ klass =
14
+ if SuperDiff::RSpec.an_instance_of_something?(object)
15
+ object.expected
16
+ else
17
+ object.instance_variable_get(:@klass)
18
+ end
19
+
20
+ t1.add_text "#<an instance of #{klass}>"
22
21
  end
23
22
  end
24
23
  end
@@ -9,16 +9,15 @@ module SuperDiff
9
9
  end
10
10
 
11
11
  def call
12
- SuperDiff::ObjectInspection::InspectionTree.new do
13
- add_text do |value|
14
- klass =
15
- if SuperDiff::RSpec.a_kind_of_something?(value)
16
- value.expected
17
- else
18
- value.instance_variable_get(:@klass)
19
- end
20
- "#<a kind of #{klass}>"
21
- end
12
+ SuperDiff::ObjectInspection::InspectionTree.new do |t1|
13
+ klass =
14
+ if SuperDiff::RSpec.a_kind_of_something?(object)
15
+ object.expected
16
+ else
17
+ object.instance_variable_get(:@klass)
18
+ end
19
+
20
+ t1.add_text "#<a kind of #{klass}>"
22
21
  end
23
22
  end
24
23
  end
@@ -8,17 +8,24 @@ module SuperDiff
8
8
  end
9
9
 
10
10
  def call
11
- SuperDiff::ObjectInspection::InspectionTree.new do
12
- as_lines_when_rendering_to_lines(collection_bookend: :open) do
13
- add_text "#<an object having attributes ("
11
+ SuperDiff::ObjectInspection::InspectionTree.new do |t1|
12
+ # stree-ignore
13
+ t1.as_lines_when_rendering_to_lines(
14
+ collection_bookend: :open
15
+ ) do |t2|
16
+ t2.add_text "#<an object having attributes ("
14
17
  end
15
18
 
16
- nested do |aliased_matcher|
17
- insert_hash_inspection_of(aliased_matcher.expected)
19
+ # stree-ignore
20
+ t1.nested do |t2|
21
+ t2.insert_hash_inspection_of(object.expected)
18
22
  end
19
23
 
20
- as_lines_when_rendering_to_lines(collection_bookend: :close) do
21
- add_text ")>"
24
+ # stree-ignore
25
+ t1.as_lines_when_rendering_to_lines(
26
+ collection_bookend: :close
27
+ ) do |t2|
28
+ t2.add_text ")>"
22
29
  end
23
30
  end
24
31
  end