super_diff 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -8
  3. data/lib/super_diff.rb +20 -11
  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/configuration.rb +60 -0
  23. data/lib/super_diff/diff_formatters.rb +3 -3
  24. data/lib/super_diff/diff_formatters/array.rb +3 -3
  25. data/lib/super_diff/diff_formatters/base.rb +3 -2
  26. data/lib/super_diff/diff_formatters/collection.rb +2 -2
  27. data/lib/super_diff/diff_formatters/custom_object.rb +3 -3
  28. data/lib/super_diff/diff_formatters/default_object.rb +6 -8
  29. data/lib/super_diff/diff_formatters/defaults.rb +10 -0
  30. data/lib/super_diff/diff_formatters/hash.rb +3 -3
  31. data/lib/super_diff/diff_formatters/main.rb +41 -0
  32. data/lib/super_diff/diff_formatters/multiline_string.rb +3 -3
  33. data/lib/super_diff/differs.rb +4 -11
  34. data/lib/super_diff/differs/array.rb +2 -11
  35. data/lib/super_diff/differs/base.rb +20 -3
  36. data/lib/super_diff/differs/custom_object.rb +2 -11
  37. data/lib/super_diff/differs/default_object.rb +2 -8
  38. data/lib/super_diff/differs/defaults.rb +12 -0
  39. data/lib/super_diff/differs/hash.rb +2 -11
  40. data/lib/super_diff/differs/main.rb +48 -0
  41. data/lib/super_diff/differs/multiline_string.rb +2 -14
  42. data/lib/super_diff/differs/time_like.rb +15 -0
  43. data/lib/super_diff/equality_matchers.rb +3 -9
  44. data/lib/super_diff/equality_matchers/array.rb +1 -7
  45. data/lib/super_diff/equality_matchers/base.rb +1 -1
  46. data/lib/super_diff/equality_matchers/default.rb +1 -7
  47. data/lib/super_diff/equality_matchers/defaults.rb +12 -0
  48. data/lib/super_diff/equality_matchers/hash.rb +1 -7
  49. data/lib/super_diff/equality_matchers/main.rb +21 -0
  50. data/lib/super_diff/equality_matchers/multiline_string.rb +1 -7
  51. data/lib/super_diff/errors.rb +16 -0
  52. data/lib/super_diff/errors/no_diff_formatter_available_error.rb +21 -0
  53. data/lib/super_diff/errors/no_differ_available_error.rb +24 -0
  54. data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +22 -0
  55. data/lib/super_diff/implementation_checks.rb +19 -0
  56. data/lib/super_diff/object_inspection.rb +1 -10
  57. data/lib/super_diff/object_inspection/inspection_tree.rb +6 -2
  58. data/lib/super_diff/object_inspection/inspectors.rb +5 -1
  59. data/lib/super_diff/object_inspection/inspectors/array.rb +20 -10
  60. data/lib/super_diff/object_inspection/inspectors/base.rb +36 -0
  61. data/lib/super_diff/object_inspection/inspectors/custom_object.rb +24 -14
  62. data/lib/super_diff/object_inspection/inspectors/default_object.rb +44 -30
  63. data/lib/super_diff/object_inspection/inspectors/defaults.rb +15 -0
  64. data/lib/super_diff/object_inspection/inspectors/hash.rb +20 -10
  65. data/lib/super_diff/object_inspection/inspectors/main.rb +35 -0
  66. data/lib/super_diff/object_inspection/inspectors/primitive.rb +20 -5
  67. data/lib/super_diff/object_inspection/inspectors/string.rb +15 -5
  68. data/lib/super_diff/object_inspection/inspectors/time_like.rb +23 -0
  69. data/lib/super_diff/object_inspection/nodes/inspection.rb +9 -2
  70. data/lib/super_diff/operation_tree_builders.rb +18 -0
  71. data/lib/super_diff/{operational_sequencers → operation_tree_builders}/array.rb +38 -59
  72. data/lib/super_diff/operation_tree_builders/base.rb +98 -0
  73. data/lib/super_diff/{operational_sequencers → operation_tree_builders}/custom_object.rb +3 -3
  74. data/lib/super_diff/{operational_sequencers → operation_tree_builders}/default_object.rb +8 -3
  75. data/lib/super_diff/operation_tree_builders/defaults.rb +5 -0
  76. data/lib/super_diff/operation_tree_builders/hash.rb +226 -0
  77. data/lib/super_diff/operation_tree_builders/main.rb +42 -0
  78. data/lib/super_diff/{operational_sequencers → operation_tree_builders}/multiline_string.rb +3 -3
  79. data/lib/super_diff/operation_tree_builders/time_like.rb +34 -0
  80. data/lib/super_diff/operation_trees.rb +13 -0
  81. data/lib/super_diff/{operation_sequences → operation_trees}/array.rb +5 -1
  82. data/lib/super_diff/{operation_sequences → operation_trees}/base.rb +7 -1
  83. data/lib/super_diff/{operation_sequences → operation_trees}/custom_object.rb +5 -1
  84. data/lib/super_diff/{operation_sequences → operation_trees}/default_object.rb +10 -8
  85. data/lib/super_diff/operation_trees/defaults.rb +5 -0
  86. data/lib/super_diff/{operation_sequences → operation_trees}/hash.rb +5 -1
  87. data/lib/super_diff/operation_trees/main.rb +35 -0
  88. data/lib/super_diff/operation_trees/multiline_string.rb +18 -0
  89. data/lib/super_diff/operations/unary_operation.rb +3 -0
  90. data/lib/super_diff/rspec.rb +45 -13
  91. data/lib/super_diff/rspec/augmented_matcher.rb +1 -1
  92. data/lib/super_diff/rspec/differ.rb +2 -17
  93. data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +2 -7
  94. data/lib/super_diff/rspec/differs/collection_including.rb +2 -7
  95. data/lib/super_diff/rspec/differs/hash_including.rb +2 -7
  96. data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -7
  97. data/lib/super_diff/rspec/matcher_text_builders/match.rb +1 -1
  98. data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +1 -1
  99. data/lib/super_diff/rspec/matcher_text_template.rb +1 -1
  100. data/lib/super_diff/rspec/object_inspection.rb +0 -1
  101. data/lib/super_diff/rspec/object_inspection/inspectors.rb +16 -0
  102. data/lib/super_diff/rspec/object_inspection/inspectors/collection_containing_exactly.rb +17 -8
  103. data/lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb +15 -9
  104. data/lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb +20 -10
  105. data/lib/super_diff/rspec/object_inspection/inspectors/instance_of.rb +23 -0
  106. data/lib/super_diff/rspec/object_inspection/inspectors/kind_of.rb +23 -0
  107. data/lib/super_diff/rspec/object_inspection/inspectors/object_having_attributes.rb +20 -11
  108. data/lib/super_diff/rspec/object_inspection/inspectors/primitive.rb +13 -0
  109. data/lib/super_diff/rspec/object_inspection/inspectors/value_within.rb +29 -0
  110. data/lib/super_diff/rspec/operation_tree_builders.rb +22 -0
  111. data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_containing_exactly.rb +5 -5
  112. data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_including.rb +2 -2
  113. data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/hash_including.rb +3 -11
  114. data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/object_having_attributes.rb +4 -8
  115. data/lib/super_diff/version.rb +1 -1
  116. data/spec/examples.txt +397 -393
  117. data/spec/integration/rspec/have_attributes_matcher_spec.rb +354 -227
  118. data/spec/integration/rspec/include_matcher_spec.rb +2 -2
  119. data/spec/integration/rspec/unhandled_errors_spec.rb +68 -12
  120. data/spec/support/command_runner.rb +3 -0
  121. data/spec/support/integration/helpers.rb +12 -96
  122. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +14 -29
  123. data/spec/support/integration/test_programs/base.rb +120 -0
  124. data/spec/support/integration/test_programs/plain.rb +13 -0
  125. data/spec/support/integration/test_programs/rspec_active_record.rb +17 -0
  126. data/spec/support/integration/test_programs/rspec_rails.rb +17 -0
  127. data/spec/support/models/active_record/person.rb +4 -11
  128. data/spec/support/models/active_record/shipping_address.rb +10 -14
  129. data/spec/support/object_id.rb +6 -5
  130. data/spec/tmp/integration_spec.rb +15 -0
  131. data/spec/unit/{equality_matcher_spec.rb → equality_matchers/main_spec.rb} +157 -1
  132. data/spec/unit/object_inspection_spec.rb +77 -1
  133. data/super_diff.gemspec +0 -1
  134. metadata +72 -64
  135. data/lib/super_diff/active_record/object_inspection/map_extension.rb +0 -18
  136. data/lib/super_diff/active_record/operational_sequencers.rb +0 -14
  137. data/lib/super_diff/active_support/object_inspection/map_extension.rb +0 -15
  138. data/lib/super_diff/active_support/operational_sequencers.rb +0 -10
  139. data/lib/super_diff/diff_formatter.rb +0 -32
  140. data/lib/super_diff/differ.rb +0 -51
  141. data/lib/super_diff/differs/time.rb +0 -24
  142. data/lib/super_diff/equality_matcher.rb +0 -32
  143. data/lib/super_diff/no_differ_available_error.rb +0 -22
  144. data/lib/super_diff/no_operational_sequencer_available_error.rb +0 -20
  145. data/lib/super_diff/object_inspection/inspector.rb +0 -27
  146. data/lib/super_diff/object_inspection/inspectors/time.rb +0 -13
  147. data/lib/super_diff/object_inspection/map.rb +0 -30
  148. data/lib/super_diff/operation_sequences.rb +0 -9
  149. data/lib/super_diff/operational_sequencer.rb +0 -48
  150. data/lib/super_diff/operational_sequencers.rb +0 -17
  151. data/lib/super_diff/operational_sequencers/base.rb +0 -89
  152. data/lib/super_diff/operational_sequencers/hash.rb +0 -85
  153. data/lib/super_diff/operational_sequencers/time_like.rb +0 -30
  154. data/lib/super_diff/rspec/configuration.rb +0 -31
  155. data/lib/super_diff/rspec/object_inspection/map_extension.rb +0 -23
  156. data/lib/super_diff/rspec/operational_sequencers.rb +0 -22
@@ -0,0 +1,13 @@
1
+ module SuperDiff
2
+ module IntegrationTests
3
+ module TestPrograms
4
+ class Plain < Base
5
+ protected
6
+
7
+ def test_plan_command
8
+ "run_plain_test"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module SuperDiff
2
+ module IntegrationTests
3
+ module TestPrograms
4
+ class RspecActiveRecord < Base
5
+ protected
6
+
7
+ def test_plan_prelude
8
+ "test_plan.boot_active_record"
9
+ end
10
+
11
+ def test_plan_command
12
+ "run_rspec_active_record_test"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module SuperDiff
2
+ module IntegrationTests
3
+ module TestPrograms
4
+ class RspecRails < Base
5
+ protected
6
+
7
+ def test_plan_prelude
8
+ "test_plan.boot_active_record"
9
+ end
10
+
11
+ def test_plan_command
12
+ "run_rspec_rails_test"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -9,18 +9,11 @@ module SuperDiff
9
9
  end
10
10
  end
11
11
 
12
- ActiveRecord::Base.connection.create_table(:people) do |t|
13
- t.string :name, null: false
14
- t.integer :age, null: false
15
- end
16
-
17
12
  RSpec.configure do |config|
18
13
  config.before do
19
- ActiveRecord::Base.connection.execute(
20
- "DELETE FROM people",
21
- )
22
- ActiveRecord::Base.connection.execute(
23
- "DELETE FROM sqlite_sequence WHERE name='people'",
24
- )
14
+ ActiveRecord::Base.connection.create_table(:people, force: true) do |t|
15
+ t.string :name, null: false
16
+ t.integer :age, null: false
17
+ end
25
18
  end
26
19
  end
@@ -9,21 +9,17 @@ module SuperDiff
9
9
  end
10
10
  end
11
11
 
12
- ActiveRecord::Base.connection.create_table(:shipping_addresses) do |t|
13
- t.string :line_1, null: false, default: ""
14
- t.string :line_2, null: false, default: ""
15
- t.string :city, null: false, default: ""
16
- t.string :state, null: false, default: ""
17
- t.string :zip, null: false, default: ""
18
- end
19
-
20
12
  RSpec.configure do |config|
21
13
  config.before do
22
- ActiveRecord::Base.connection.execute(
23
- "DELETE FROM shipping_addresses",
24
- )
25
- ActiveRecord::Base.connection.execute(
26
- "DELETE FROM sqlite_sequence WHERE name='shipping_addresses'",
27
- )
14
+ ActiveRecord::Base.connection.create_table(
15
+ :shipping_addresses,
16
+ force: true,
17
+ ) do |t|
18
+ t.string :line_1, null: false, default: ""
19
+ t.string :line_2, null: false, default: ""
20
+ t.string :city, null: false, default: ""
21
+ t.string :state, null: false, default: ""
22
+ t.string :zip, null: false, default: ""
23
+ end
28
24
  end
29
25
  end
@@ -1,7 +1,8 @@
1
- require_relative 'ruby_versions'
1
+ require "json"
2
+ require_relative "ruby_versions"
2
3
 
3
- if !SuperDiff::Test.jruby? && SuperDiff::Test.version_match?('>= 2.7.0')
4
- require 'objspace'
4
+ if !SuperDiff::Test.jruby? && SuperDiff::Test.version_match?(">= 2.7.0")
5
+ require "objspace"
5
6
  end
6
7
 
7
8
  module SuperDiff
@@ -11,10 +12,10 @@ module SuperDiff
11
12
  # Source: <https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/RubyBasicObject.java>
12
13
  "0x%x" % object.hash
13
14
  end
14
- elsif version_match?('>= 2.7.0')
15
+ elsif version_match?(">= 2.7.0")
15
16
  def self.object_id_hex(object)
16
17
  # Sources: <https://bugs.ruby-lang.org/issues/15408> and <https://bugs.ruby-lang.org/issues/15626#Object-ID>
17
- address = JSON.parse(ObjectSpace.dump(object))['address']
18
+ address = JSON.parse(ObjectSpace.dump(object))["address"]
18
19
  "0x%016x" % Integer(address, 16)
19
20
  end
20
21
  else
@@ -0,0 +1,15 @@
1
+ require "/Users/elliot/code/github/mine/super_diff/spec/config/zeus_plan.rb"
2
+
3
+ zeus_plan = CustomZeusPlan.new
4
+ zeus_plan.boot
5
+
6
+ zeus_plan.run_plain_test
7
+
8
+ RSpec.describe "test" do
9
+ it "passes" do
10
+ expected = "This is a line\nAnd that's a line\nAnd there's a line too\n"
11
+ actual = "This is a line\nSomething completely different\nAnd there's a line too\n"
12
+ expect(actual).to eq(expected)
13
+ end
14
+ end
15
+
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- RSpec.describe SuperDiff::EqualityMatcher do
3
+ RSpec.describe SuperDiff::EqualityMatchers::Main do
4
4
  describe "#call" do
5
5
  context "given the same integers" do
6
6
  it "returns an empty string" do
@@ -1056,6 +1056,162 @@ RSpec.describe SuperDiff::EqualityMatcher do
1056
1056
  end
1057
1057
  end
1058
1058
 
1059
+ context "given two equal-size, one-dimensional hashes where there is a mixture of missing and extra keys in relatively the same order" do
1060
+ context "and the actual value is in relatively the same order as the expected" do
1061
+ it "preserves the order of the keys as they are defined" do
1062
+ actual_output = described_class.call(
1063
+ expected: {
1064
+ listed_count: 37_009,
1065
+ created_at: "Tue Jan 13 19:28:24 +0000 2009",
1066
+ favourites_count: 38,
1067
+ geo_enabled: false,
1068
+ verified: true,
1069
+ statuses_count: 273_860,
1070
+ media_count: 51_044,
1071
+ contributors_enabled: false,
1072
+ profile_background_color: "FFF1E0",
1073
+ profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",
1074
+ profile_background_tile: false,
1075
+ profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
1076
+ profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
1077
+ profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",
1078
+ },
1079
+ actual: {
1080
+ listed_count: 37_009,
1081
+ created_at: "Tue Jan 13 19:28:24 +0000 2009",
1082
+ favourites_count: 38,
1083
+ utc_offset: nil,
1084
+ time_zone: nil,
1085
+ statuses_count: 273_860,
1086
+ media_count: 51_044,
1087
+ contributors_enabled: false,
1088
+ is_translator: false,
1089
+ is_translation_enabled: false,
1090
+ profile_background_color: "FFF1E0",
1091
+ profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",
1092
+ profile_background_tile: false,
1093
+ profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",
1094
+ }
1095
+ )
1096
+
1097
+ expected_output = <<~STR.strip
1098
+ Differing hashes.
1099
+
1100
+ #{
1101
+ colored do
1102
+ alpha_line %(Expected: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, geo_enabled: false, verified: true, statuses_count: 273860, media_count: 51044, contributors_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_tile: false, profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1103
+ beta_line %( Actual: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, time_zone: nil, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_tile: false, profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1104
+ end
1105
+ }
1106
+
1107
+ Diff:
1108
+
1109
+ #{
1110
+ colored do
1111
+ plain_line %( {)
1112
+ plain_line %( listed_count: 37009,)
1113
+ plain_line %( created_at: "Tue Jan 13 19:28:24 +0000 2009",)
1114
+ plain_line %( favourites_count: 38,)
1115
+ alpha_line %(- geo_enabled: false,)
1116
+ alpha_line %(- verified: true,)
1117
+ beta_line %(+ utc_offset: nil,)
1118
+ beta_line %(+ time_zone: nil,)
1119
+ plain_line %( statuses_count: 273860,)
1120
+ plain_line %( media_count: 51044,)
1121
+ plain_line %( contributors_enabled: false,)
1122
+ beta_line %(+ is_translator: false,)
1123
+ beta_line %(+ is_translation_enabled: false,)
1124
+ plain_line %( profile_background_color: "FFF1E0",)
1125
+ plain_line %( profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",)
1126
+ plain_line %( profile_background_tile: false,)
1127
+ alpha_line %(- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",)
1128
+ alpha_line %(- profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",)
1129
+ plain_line %( profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592")
1130
+ plain_line %( })
1131
+ end
1132
+ }
1133
+ STR
1134
+
1135
+ expect(actual_output).to eq(expected_output)
1136
+ end
1137
+ end
1138
+
1139
+ context "and the actual value is in a different order than the expected" do
1140
+ it "preserves the order of the keys as they are defined" do
1141
+ actual_output = described_class.call(
1142
+ expected: {
1143
+ created_at: "Tue Jan 13 19:28:24 +0000 2009",
1144
+ favourites_count: 38,
1145
+ geo_enabled: false,
1146
+ verified: true,
1147
+ media_count: 51_044,
1148
+ statuses_count: 273_860,
1149
+ contributors_enabled: false,
1150
+ profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",
1151
+ profile_background_color: "FFF1E0",
1152
+ profile_background_tile: false,
1153
+ profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
1154
+ listed_count: 37_009,
1155
+ profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",
1156
+ },
1157
+ actual: {
1158
+ listed_count: 37_009,
1159
+ created_at: "Tue Jan 13 19:28:24 +0000 2009",
1160
+ favourites_count: 38,
1161
+ utc_offset: nil,
1162
+ statuses_count: 273_860,
1163
+ media_count: 51_044,
1164
+ contributors_enabled: false,
1165
+ is_translator: false,
1166
+ is_translation_enabled: false,
1167
+ profile_background_color: "FFF1E0",
1168
+ profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",
1169
+ profile_background_tile: false,
1170
+ profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",
1171
+ }
1172
+ )
1173
+
1174
+ expected_output = <<~STR.strip
1175
+ Differing hashes.
1176
+
1177
+ #{
1178
+ colored do
1179
+ alpha_line %(Expected: { created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, geo_enabled: false, verified: true, media_count: 51044, statuses_count: 273860, contributors_enabled: false, profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_color: "FFF1E0", profile_background_tile: false, profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", listed_count: 37009, profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1180
+ beta_line %( Actual: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_tile: false, profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1181
+ end
1182
+ }
1183
+
1184
+ Diff:
1185
+
1186
+ #{
1187
+ colored do
1188
+ plain_line %( {)
1189
+ plain_line %( listed_count: 37009,)
1190
+ plain_line %( created_at: "Tue Jan 13 19:28:24 +0000 2009",)
1191
+ plain_line %( favourites_count: 38,)
1192
+ alpha_line %(- geo_enabled: false,)
1193
+ alpha_line %(- verified: true,)
1194
+ beta_line %(+ utc_offset: nil,)
1195
+ plain_line %( statuses_count: 273860,)
1196
+ plain_line %( media_count: 51044,)
1197
+ plain_line %( contributors_enabled: false,)
1198
+ beta_line %(+ is_translator: false,)
1199
+ beta_line %(+ is_translation_enabled: false,)
1200
+ plain_line %( profile_background_color: "FFF1E0",)
1201
+ plain_line %( profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",)
1202
+ plain_line %( profile_background_tile: false,)
1203
+ alpha_line %(- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",)
1204
+ plain_line %( profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592")
1205
+ plain_line %( })
1206
+ end
1207
+ }
1208
+ STR
1209
+
1210
+ expect(actual_output).to eq(expected_output)
1211
+ end
1212
+ end
1213
+ end
1214
+
1059
1215
  context "given two hashes containing arrays with differing values" do
1060
1216
  it "returns a message along with the diff" do
1061
1217
  actual_output = described_class.call(
@@ -601,7 +601,7 @@ RSpec.describe SuperDiff::ObjectInspection do
601
601
  as_single_line: false,
602
602
  )
603
603
  expect(inspection).to match(
604
- /#<SuperDiff::Test::EmptyClass:0x[a-z0-9]+>/
604
+ /#<SuperDiff::Test::EmptyClass:0x[a-z0-9]+>/,
605
605
  )
606
606
  end
607
607
  end
@@ -734,6 +734,82 @@ RSpec.describe SuperDiff::ObjectInspection do
734
734
  end
735
735
  end
736
736
 
737
+ context "given a kind-of-<something>" do
738
+ context "given as_single_line: true" do
739
+ it "returns a representation of the object on a single line" do
740
+ inspection = described_class.inspect(
741
+ a_kind_of(Symbol),
742
+ as_single_line: true,
743
+ )
744
+
745
+ expect(inspection).to eq(%(#<a kind of Symbol>))
746
+ end
747
+ end
748
+
749
+ context "given as_single_line: false" do
750
+ it "returns a representation of the object on a single line" do
751
+ inspection = described_class.inspect(
752
+ a_kind_of(Symbol),
753
+ as_single_line: false,
754
+ )
755
+
756
+ expect(inspection).to eq(%(#<a kind of Symbol>))
757
+ end
758
+ end
759
+ end
760
+
761
+ context "given an-instance-of-<something>" do
762
+ context "given as_single_line: true" do
763
+ it "returns a representation of the object on a single line" do
764
+ inspection = described_class.inspect(
765
+ an_instance_of(Symbol),
766
+ as_single_line: true,
767
+ )
768
+
769
+ expect(inspection).to eq(%(#<an instance of Symbol>))
770
+ end
771
+ end
772
+
773
+ context "given as_single_line: false" do
774
+ it "returns a representation of the object on a single line" do
775
+ inspection = described_class.inspect(
776
+ an_instance_of(Symbol),
777
+ as_single_line: false,
778
+ )
779
+
780
+ expect(inspection).to eq(%(#<an instance of Symbol>))
781
+ end
782
+ end
783
+ end
784
+
785
+ context "given a-value-within-<something>" do
786
+ context "given as_single_line: true" do
787
+ it "returns a representation of the object on a single line" do
788
+ inspection = described_class.inspect(
789
+ a_value_within(1).of(Time.utc(2020, 4, 9)),
790
+ as_single_line: true,
791
+ )
792
+
793
+ expect(inspection).to eq(
794
+ %(#<a value within 1 of 2020-04-09 00:00:00.000 UTC +00:00 (Time)>),
795
+ )
796
+ end
797
+ end
798
+
799
+ context "given as_single_line: false" do
800
+ it "returns a representation of the object on a single line" do
801
+ inspection = described_class.inspect(
802
+ a_value_within(1).of(Time.utc(2020, 4, 9)),
803
+ as_single_line: false,
804
+ )
805
+
806
+ expect(inspection).to eq(
807
+ %(#<a value within 1 of 2020-04-09 00:00:00.000 UTC +00:00 (Time)>),
808
+ )
809
+ end
810
+ end
811
+ end
812
+
737
813
  context "given a Double" do
738
814
  context "that is anonymous" do
739
815
  context "given as_single_line: true" do
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.test_files = Dir["spec/**/*"]
18
18
  s.executables = Dir["exe/**/*"].map { |f| File.basename(f) }
19
19
 
20
- s.add_dependency "attr_extras"
21
20
  s.add_dependency "diff-lcs"
22
21
  s.add_dependency "patience_diff"
23
22
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Winkler
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
11
+ date: 2020-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: attr_extras
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: diff-lcs
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -73,12 +59,11 @@ files:
73
59
  - lib/super_diff/active_record/object_inspection/inspectors.rb
74
60
  - lib/super_diff/active_record/object_inspection/inspectors/active_record_model.rb
75
61
  - lib/super_diff/active_record/object_inspection/inspectors/active_record_relation.rb
76
- - lib/super_diff/active_record/object_inspection/map_extension.rb
77
- - lib/super_diff/active_record/operation_sequences.rb
78
- - lib/super_diff/active_record/operation_sequences/active_record_relation.rb
79
- - lib/super_diff/active_record/operational_sequencers.rb
80
- - lib/super_diff/active_record/operational_sequencers/active_record_model.rb
81
- - lib/super_diff/active_record/operational_sequencers/active_record_relation.rb
62
+ - lib/super_diff/active_record/operation_tree_builders.rb
63
+ - lib/super_diff/active_record/operation_tree_builders/active_record_model.rb
64
+ - lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb
65
+ - lib/super_diff/active_record/operation_trees.rb
66
+ - lib/super_diff/active_record/operation_trees/active_record_relation.rb
82
67
  - lib/super_diff/active_support.rb
83
68
  - lib/super_diff/active_support/diff_formatters.rb
84
69
  - lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb
@@ -87,12 +72,12 @@ files:
87
72
  - lib/super_diff/active_support/object_inspection.rb
88
73
  - lib/super_diff/active_support/object_inspection/inspectors.rb
89
74
  - lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb
90
- - lib/super_diff/active_support/object_inspection/map_extension.rb
91
- - lib/super_diff/active_support/operation_sequences.rb
92
- - lib/super_diff/active_support/operation_sequences/hash_with_indifferent_access.rb
93
- - lib/super_diff/active_support/operational_sequencers.rb
94
- - lib/super_diff/active_support/operational_sequencers/hash_with_indifferent_access.rb
75
+ - lib/super_diff/active_support/operation_tree_builders.rb
76
+ - lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb
77
+ - lib/super_diff/active_support/operation_trees.rb
78
+ - lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb
95
79
  - lib/super_diff/colorized_document_extensions.rb
80
+ - lib/super_diff/configuration.rb
96
81
  - lib/super_diff/csi.rb
97
82
  - lib/super_diff/csi/bold_sequence.rb
98
83
  - lib/super_diff/csi/color.rb
@@ -104,49 +89,56 @@ files:
104
89
  - lib/super_diff/csi/reset_sequence.rb
105
90
  - lib/super_diff/csi/twenty_four_bit_color.rb
106
91
  - lib/super_diff/csi/uncolorized_document.rb
107
- - lib/super_diff/diff_formatter.rb
108
92
  - lib/super_diff/diff_formatters.rb
109
93
  - lib/super_diff/diff_formatters/array.rb
110
94
  - lib/super_diff/diff_formatters/base.rb
111
95
  - lib/super_diff/diff_formatters/collection.rb
112
96
  - lib/super_diff/diff_formatters/custom_object.rb
113
97
  - lib/super_diff/diff_formatters/default_object.rb
98
+ - lib/super_diff/diff_formatters/defaults.rb
114
99
  - lib/super_diff/diff_formatters/hash.rb
100
+ - lib/super_diff/diff_formatters/main.rb
115
101
  - lib/super_diff/diff_formatters/multiline_string.rb
116
- - lib/super_diff/differ.rb
117
102
  - lib/super_diff/differs.rb
118
103
  - lib/super_diff/differs/array.rb
119
104
  - lib/super_diff/differs/base.rb
120
105
  - lib/super_diff/differs/custom_object.rb
121
106
  - lib/super_diff/differs/default_object.rb
107
+ - lib/super_diff/differs/defaults.rb
122
108
  - lib/super_diff/differs/empty.rb
123
109
  - lib/super_diff/differs/hash.rb
110
+ - lib/super_diff/differs/main.rb
124
111
  - lib/super_diff/differs/multiline_string.rb
125
- - lib/super_diff/differs/time.rb
126
- - lib/super_diff/equality_matcher.rb
112
+ - lib/super_diff/differs/time_like.rb
127
113
  - lib/super_diff/equality_matchers.rb
128
114
  - lib/super_diff/equality_matchers/array.rb
129
115
  - lib/super_diff/equality_matchers/base.rb
130
116
  - lib/super_diff/equality_matchers/default.rb
117
+ - lib/super_diff/equality_matchers/defaults.rb
131
118
  - lib/super_diff/equality_matchers/hash.rb
119
+ - lib/super_diff/equality_matchers/main.rb
132
120
  - lib/super_diff/equality_matchers/multiline_string.rb
133
121
  - lib/super_diff/equality_matchers/primitive.rb
134
122
  - lib/super_diff/equality_matchers/singleline_string.rb
123
+ - lib/super_diff/errors.rb
124
+ - lib/super_diff/errors/no_diff_formatter_available_error.rb
125
+ - lib/super_diff/errors/no_differ_available_error.rb
126
+ - lib/super_diff/errors/no_operational_sequencer_available_error.rb
135
127
  - lib/super_diff/helpers.rb
136
- - lib/super_diff/no_differ_available_error.rb
137
- - lib/super_diff/no_operational_sequencer_available_error.rb
128
+ - lib/super_diff/implementation_checks.rb
138
129
  - lib/super_diff/object_inspection.rb
139
130
  - lib/super_diff/object_inspection/inspection_tree.rb
140
- - lib/super_diff/object_inspection/inspector.rb
141
131
  - lib/super_diff/object_inspection/inspectors.rb
142
132
  - lib/super_diff/object_inspection/inspectors/array.rb
133
+ - lib/super_diff/object_inspection/inspectors/base.rb
143
134
  - lib/super_diff/object_inspection/inspectors/custom_object.rb
144
135
  - lib/super_diff/object_inspection/inspectors/default_object.rb
136
+ - lib/super_diff/object_inspection/inspectors/defaults.rb
145
137
  - lib/super_diff/object_inspection/inspectors/hash.rb
138
+ - lib/super_diff/object_inspection/inspectors/main.rb
146
139
  - lib/super_diff/object_inspection/inspectors/primitive.rb
147
140
  - lib/super_diff/object_inspection/inspectors/string.rb
148
- - lib/super_diff/object_inspection/inspectors/time.rb
149
- - lib/super_diff/object_inspection/map.rb
141
+ - lib/super_diff/object_inspection/inspectors/time_like.rb
150
142
  - lib/super_diff/object_inspection/nodes.rb
151
143
  - lib/super_diff/object_inspection/nodes/base.rb
152
144
  - lib/super_diff/object_inspection/nodes/break.rb
@@ -157,21 +149,25 @@ files:
157
149
  - lib/super_diff/object_inspection/nodes/when_multiline.rb
158
150
  - lib/super_diff/object_inspection/nodes/when_non_empty.rb
159
151
  - lib/super_diff/object_inspection/nodes/when_singleline.rb
160
- - lib/super_diff/operation_sequences.rb
161
- - lib/super_diff/operation_sequences/array.rb
162
- - lib/super_diff/operation_sequences/base.rb
163
- - lib/super_diff/operation_sequences/custom_object.rb
164
- - lib/super_diff/operation_sequences/default_object.rb
165
- - lib/super_diff/operation_sequences/hash.rb
166
- - lib/super_diff/operational_sequencer.rb
167
- - lib/super_diff/operational_sequencers.rb
168
- - lib/super_diff/operational_sequencers/array.rb
169
- - lib/super_diff/operational_sequencers/base.rb
170
- - lib/super_diff/operational_sequencers/custom_object.rb
171
- - lib/super_diff/operational_sequencers/default_object.rb
172
- - lib/super_diff/operational_sequencers/hash.rb
173
- - lib/super_diff/operational_sequencers/multiline_string.rb
174
- - lib/super_diff/operational_sequencers/time_like.rb
152
+ - lib/super_diff/operation_tree_builders.rb
153
+ - lib/super_diff/operation_tree_builders/array.rb
154
+ - lib/super_diff/operation_tree_builders/base.rb
155
+ - lib/super_diff/operation_tree_builders/custom_object.rb
156
+ - lib/super_diff/operation_tree_builders/default_object.rb
157
+ - lib/super_diff/operation_tree_builders/defaults.rb
158
+ - lib/super_diff/operation_tree_builders/hash.rb
159
+ - lib/super_diff/operation_tree_builders/main.rb
160
+ - lib/super_diff/operation_tree_builders/multiline_string.rb
161
+ - lib/super_diff/operation_tree_builders/time_like.rb
162
+ - lib/super_diff/operation_trees.rb
163
+ - lib/super_diff/operation_trees/array.rb
164
+ - lib/super_diff/operation_trees/base.rb
165
+ - lib/super_diff/operation_trees/custom_object.rb
166
+ - lib/super_diff/operation_trees/default_object.rb
167
+ - lib/super_diff/operation_trees/defaults.rb
168
+ - lib/super_diff/operation_trees/hash.rb
169
+ - lib/super_diff/operation_trees/main.rb
170
+ - lib/super_diff/operation_trees/multiline_string.rb
175
171
  - lib/super_diff/operations.rb
176
172
  - lib/super_diff/operations/binary_operation.rb
177
173
  - lib/super_diff/operations/unary_operation.rb
@@ -180,7 +176,6 @@ files:
180
176
  - lib/super_diff/rspec-rails.rb
181
177
  - lib/super_diff/rspec.rb
182
178
  - lib/super_diff/rspec/augmented_matcher.rb
183
- - lib/super_diff/rspec/configuration.rb
184
179
  - lib/super_diff/rspec/differ.rb
185
180
  - lib/super_diff/rspec/differs.rb
186
181
  - lib/super_diff/rspec/differs/collection_containing_exactly.rb
@@ -202,13 +197,16 @@ files:
202
197
  - lib/super_diff/rspec/object_inspection/inspectors/collection_containing_exactly.rb
203
198
  - lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb
204
199
  - lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb
200
+ - lib/super_diff/rspec/object_inspection/inspectors/instance_of.rb
201
+ - lib/super_diff/rspec/object_inspection/inspectors/kind_of.rb
205
202
  - lib/super_diff/rspec/object_inspection/inspectors/object_having_attributes.rb
206
- - lib/super_diff/rspec/object_inspection/map_extension.rb
207
- - lib/super_diff/rspec/operational_sequencers.rb
208
- - lib/super_diff/rspec/operational_sequencers/collection_containing_exactly.rb
209
- - lib/super_diff/rspec/operational_sequencers/collection_including.rb
210
- - lib/super_diff/rspec/operational_sequencers/hash_including.rb
211
- - lib/super_diff/rspec/operational_sequencers/object_having_attributes.rb
203
+ - lib/super_diff/rspec/object_inspection/inspectors/primitive.rb
204
+ - lib/super_diff/rspec/object_inspection/inspectors/value_within.rb
205
+ - lib/super_diff/rspec/operation_tree_builders.rb
206
+ - lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb
207
+ - lib/super_diff/rspec/operation_tree_builders/collection_including.rb
208
+ - lib/super_diff/rspec/operation_tree_builders/hash_including.rb
209
+ - lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb
212
210
  - lib/super_diff/version.rb
213
211
  - spec/examples.txt
214
212
  - spec/integration/rails/active_record_spec.rb
@@ -235,6 +233,10 @@ files:
235
233
  - spec/support/integration/helpers.rb
236
234
  - spec/support/integration/matchers.rb
237
235
  - spec/support/integration/matchers/produce_output_when_run_matcher.rb
236
+ - spec/support/integration/test_programs/base.rb
237
+ - spec/support/integration/test_programs/plain.rb
238
+ - spec/support/integration/test_programs/rspec_active_record.rb
239
+ - spec/support/integration/test_programs/rspec_rails.rb
238
240
  - spec/support/models/a.rb
239
241
  - spec/support/models/active_record/person.rb
240
242
  - spec/support/models/active_record/query.rb
@@ -250,7 +252,8 @@ files:
250
252
  - spec/support/ruby_versions.rb
251
253
  - spec/support/shared_examples/active_record.rb
252
254
  - spec/support/shared_examples/hash_with_indifferent_access.rb
253
- - spec/unit/equality_matcher_spec.rb
255
+ - spec/tmp/integration_spec.rb
256
+ - spec/unit/equality_matchers/main_spec.rb
254
257
  - spec/unit/object_inspection_spec.rb
255
258
  - spec/unit/rspec/matchers/be_compared_to_spec.rb
256
259
  - spec/unit/rspec/matchers/be_falsey_spec.rb
@@ -271,7 +274,7 @@ files:
271
274
  homepage: https://github.com/mcmire/super_diff
272
275
  licenses: []
273
276
  metadata: {}
274
- post_install_message:
277
+ post_install_message:
275
278
  rdoc_options: []
276
279
  require_paths:
277
280
  - lib
@@ -286,14 +289,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
289
  - !ruby/object:Gem::Version
287
290
  version: '0'
288
291
  requirements: []
289
- rubygems_version: 3.0.6
290
- signing_key:
292
+ rubygems_version: 3.1.2
293
+ signing_key:
291
294
  specification_version: 4
292
295
  summary: A better way to view differences between complex data structures in RSpec.
293
296
  test_files:
294
297
  - spec/spec_helper.rb
298
+ - spec/unit/equality_matchers/main_spec.rb
295
299
  - spec/unit/object_inspection_spec.rb
296
- - spec/unit/equality_matcher_spec.rb
297
300
  - spec/unit/rspec/matchers/contain_exactly_spec.rb
298
301
  - spec/unit/rspec/matchers/be_predicate_spec.rb
299
302
  - spec/unit/rspec/matchers/raise_error_spec.rb
@@ -329,6 +332,10 @@ test_files:
329
332
  - spec/integration/rails/active_record_spec.rb
330
333
  - spec/integration/rails/hash_with_indifferent_access_spec.rb
331
334
  - spec/support/object_id.rb
335
+ - spec/support/integration/test_programs/base.rb
336
+ - spec/support/integration/test_programs/rspec_rails.rb
337
+ - spec/support/integration/test_programs/plain.rb
338
+ - spec/support/integration/test_programs/rspec_active_record.rb
332
339
  - spec/support/integration/helpers.rb
333
340
  - spec/support/integration/matchers.rb
334
341
  - spec/support/integration/matchers/produce_output_when_run_matcher.rb
@@ -348,3 +355,4 @@ test_files:
348
355
  - spec/support/colorizer.rb
349
356
  - spec/support/shared_examples/hash_with_indifferent_access.rb
350
357
  - spec/support/shared_examples/active_record.rb
358
+ - spec/tmp/integration_spec.rb