super_diff 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +117 -89
  3. data/lib/super_diff.rb +33 -47
  4. data/lib/super_diff/active_record.rb +41 -0
  5. data/lib/super_diff/active_record/diff_formatters.rb +10 -0
  6. data/lib/super_diff/active_record/diff_formatters/active_record_relation.rb +23 -0
  7. data/lib/super_diff/active_record/differs.rb +10 -0
  8. data/lib/super_diff/active_record/differs/active_record_relation.rb +30 -0
  9. data/lib/super_diff/active_record/object_inspection.rb +14 -0
  10. data/lib/super_diff/active_record/object_inspection/inspectors.rb +16 -0
  11. data/lib/super_diff/active_record/object_inspection/inspectors/active_record_model.rb +38 -0
  12. data/lib/super_diff/active_record/object_inspection/inspectors/active_record_relation.rb +18 -0
  13. data/lib/super_diff/active_record/object_inspection/map_extension.rb +18 -0
  14. data/lib/super_diff/active_record/operation_sequences.rb +10 -0
  15. data/lib/super_diff/active_record/operation_sequences/active_record_relation.rb +16 -0
  16. data/lib/super_diff/active_record/operational_sequencers.rb +14 -0
  17. data/lib/super_diff/active_record/operational_sequencers/active_record_model.rb +19 -0
  18. data/lib/super_diff/active_record/operational_sequencers/active_record_relation.rb +24 -0
  19. data/lib/super_diff/active_support.rb +33 -0
  20. data/lib/super_diff/active_support/diff_formatters.rb +10 -0
  21. data/lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb +36 -0
  22. data/lib/super_diff/active_support/differs.rb +10 -0
  23. data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +36 -0
  24. data/lib/super_diff/active_support/object_inspection.rb +14 -0
  25. data/lib/super_diff/active_support/object_inspection/inspectors.rb +12 -0
  26. data/lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb +18 -0
  27. data/lib/super_diff/active_support/object_inspection/map_extension.rb +15 -0
  28. data/lib/super_diff/active_support/operation_sequences.rb +10 -0
  29. data/lib/super_diff/active_support/operation_sequences/hash_with_indifferent_access.rb +16 -0
  30. data/lib/super_diff/active_support/operational_sequencers.rb +10 -0
  31. data/lib/super_diff/active_support/operational_sequencers/hash_with_indifferent_access.rb +21 -0
  32. data/lib/super_diff/colorized_document_extensions.rb +17 -0
  33. data/lib/super_diff/csi.rb +45 -15
  34. data/lib/super_diff/csi/bold_sequence.rb +9 -0
  35. data/lib/super_diff/csi/color.rb +62 -0
  36. data/lib/super_diff/csi/color_sequence_block.rb +28 -0
  37. data/lib/super_diff/csi/colorized_document.rb +72 -0
  38. data/lib/super_diff/csi/document.rb +183 -0
  39. data/lib/super_diff/csi/eight_bit_color.rb +72 -26
  40. data/lib/super_diff/csi/four_bit_color.rb +63 -29
  41. data/lib/super_diff/csi/twenty_four_bit_color.rb +79 -18
  42. data/lib/super_diff/csi/uncolorized_document.rb +29 -0
  43. data/lib/super_diff/diff_formatter.rb +10 -15
  44. data/lib/super_diff/diff_formatters.rb +10 -1
  45. data/lib/super_diff/diff_formatters/base.rb +12 -17
  46. data/lib/super_diff/diff_formatters/collection.rb +81 -50
  47. data/lib/super_diff/diff_formatters/{object.rb → custom_object.rb} +12 -9
  48. data/lib/super_diff/diff_formatters/default_object.rb +48 -0
  49. data/lib/super_diff/diff_formatters/multiline_string.rb +31 -0
  50. data/lib/super_diff/differ.rb +35 -32
  51. data/lib/super_diff/differs.rb +16 -1
  52. data/lib/super_diff/differs/array.rb +2 -2
  53. data/lib/super_diff/differs/base.rb +11 -21
  54. data/lib/super_diff/differs/custom_object.rb +26 -0
  55. data/lib/super_diff/differs/default_object.rb +25 -0
  56. data/lib/super_diff/differs/empty.rb +1 -1
  57. data/lib/super_diff/differs/hash.rb +2 -2
  58. data/lib/super_diff/differs/{multi_line_string.rb → multiline_string.rb} +6 -5
  59. data/lib/super_diff/equality_matcher.rb +9 -22
  60. data/lib/super_diff/equality_matchers.rb +19 -1
  61. data/lib/super_diff/equality_matchers/array.rb +6 -4
  62. data/lib/super_diff/equality_matchers/base.rb +8 -16
  63. data/lib/super_diff/equality_matchers/default.rb +60 -0
  64. data/lib/super_diff/equality_matchers/hash.rb +6 -4
  65. data/lib/super_diff/equality_matchers/{multi_line_string.rb → multiline_string.rb} +9 -6
  66. data/lib/super_diff/equality_matchers/primitive.rb +34 -0
  67. data/lib/super_diff/equality_matchers/{single_line_string.rb → singleline_string.rb} +7 -5
  68. data/lib/super_diff/helpers.rb +17 -81
  69. data/lib/super_diff/no_differ_available_error.rb +22 -0
  70. data/lib/super_diff/{errors.rb → no_operational_sequencer_available_error.rb} +0 -0
  71. data/lib/super_diff/object_inspection.rb +24 -0
  72. data/lib/super_diff/object_inspection/inspection_tree.rb +144 -0
  73. data/lib/super_diff/object_inspection/inspector.rb +27 -0
  74. data/lib/super_diff/object_inspection/inspectors.rb +18 -0
  75. data/lib/super_diff/object_inspection/inspectors/array.rb +22 -0
  76. data/lib/super_diff/object_inspection/inspectors/custom_object.rb +27 -0
  77. data/lib/super_diff/object_inspection/inspectors/default_object.rb +47 -0
  78. data/lib/super_diff/object_inspection/inspectors/hash.rb +22 -0
  79. data/lib/super_diff/object_inspection/inspectors/primitive.rb +13 -0
  80. data/lib/super_diff/object_inspection/inspectors/string.rb +13 -0
  81. data/lib/super_diff/object_inspection/map.rb +28 -0
  82. data/lib/super_diff/object_inspection/nodes.rb +49 -0
  83. data/lib/super_diff/object_inspection/nodes/base.rb +86 -0
  84. data/lib/super_diff/object_inspection/nodes/break.rb +15 -0
  85. data/lib/super_diff/object_inspection/nodes/inspection.rb +15 -0
  86. data/lib/super_diff/object_inspection/nodes/nesting.rb +16 -0
  87. data/lib/super_diff/object_inspection/nodes/text.rb +15 -0
  88. data/lib/super_diff/object_inspection/nodes/when_empty.rb +30 -0
  89. data/lib/super_diff/object_inspection/nodes/when_multiline.rb +22 -0
  90. data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +30 -0
  91. data/lib/super_diff/object_inspection/nodes/when_singleline.rb +24 -0
  92. data/lib/super_diff/operation_sequences.rb +9 -0
  93. data/lib/super_diff/operation_sequences/base.rb +1 -1
  94. data/lib/super_diff/operation_sequences/{object.rb → custom_object.rb} +4 -3
  95. data/lib/super_diff/operation_sequences/default_object.rb +25 -0
  96. data/lib/super_diff/operational_sequencer.rb +23 -18
  97. data/lib/super_diff/operational_sequencers.rb +12 -1
  98. data/lib/super_diff/operational_sequencers/array.rb +65 -62
  99. data/lib/super_diff/operational_sequencers/base.rb +18 -26
  100. data/lib/super_diff/operational_sequencers/custom_object.rb +35 -0
  101. data/lib/super_diff/operational_sequencers/{object.rb → default_object.rb} +21 -11
  102. data/lib/super_diff/operational_sequencers/hash.rb +8 -5
  103. data/lib/super_diff/operational_sequencers/{multi_line_string.rb → multiline_string.rb} +11 -6
  104. data/lib/super_diff/operations.rb +6 -0
  105. data/lib/super_diff/operations/binary_operation.rb +14 -34
  106. data/lib/super_diff/operations/unary_operation.rb +11 -2
  107. data/lib/super_diff/rails.rb +1 -0
  108. data/lib/super_diff/recursion_guard.rb +47 -0
  109. data/lib/super_diff/rspec-rails.rb +2 -0
  110. data/lib/super_diff/rspec.rb +52 -8
  111. data/lib/super_diff/rspec/augmented_matcher.rb +98 -0
  112. data/lib/super_diff/rspec/configuration.rb +31 -0
  113. data/lib/super_diff/rspec/differ.rb +60 -16
  114. data/lib/super_diff/rspec/differs.rb +13 -0
  115. data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +23 -0
  116. data/lib/super_diff/rspec/differs/partial_array.rb +22 -0
  117. data/lib/super_diff/rspec/differs/partial_hash.rb +22 -0
  118. data/lib/super_diff/rspec/differs/partial_object.rb +22 -0
  119. data/lib/super_diff/rspec/matcher_text_builders.rb +24 -0
  120. data/lib/super_diff/rspec/matcher_text_builders/base.rb +155 -0
  121. data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +78 -0
  122. data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +14 -0
  123. data/lib/super_diff/rspec/matcher_text_builders/match.rb +23 -0
  124. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +13 -0
  125. data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +99 -0
  126. data/lib/super_diff/rspec/matcher_text_template.rb +240 -0
  127. data/lib/super_diff/rspec/monkey_patches.rb +601 -98
  128. data/lib/super_diff/rspec/object_inspection.rb +8 -0
  129. data/lib/super_diff/rspec/object_inspection/inspectors.rb +24 -0
  130. data/lib/super_diff/rspec/object_inspection/inspectors/collection_containing_exactly.rb +19 -0
  131. data/lib/super_diff/rspec/object_inspection/inspectors/partial_array.rb +22 -0
  132. data/lib/super_diff/rspec/object_inspection/inspectors/partial_hash.rb +21 -0
  133. data/lib/super_diff/rspec/object_inspection/inspectors/partial_object.rb +21 -0
  134. data/lib/super_diff/rspec/object_inspection/map_extension.rb +23 -0
  135. data/lib/super_diff/rspec/operational_sequencers.rb +22 -0
  136. data/lib/super_diff/rspec/operational_sequencers/collection_containing_exactly.rb +97 -0
  137. data/lib/super_diff/rspec/operational_sequencers/partial_array.rb +23 -0
  138. data/lib/super_diff/rspec/operational_sequencers/partial_hash.rb +32 -0
  139. data/lib/super_diff/rspec/operational_sequencers/partial_object.rb +64 -0
  140. data/lib/super_diff/version.rb +1 -1
  141. data/spec/examples.txt +328 -46
  142. data/spec/integration/rails/active_record_spec.rb +19 -0
  143. data/spec/integration/rails/hash_with_indifferent_access_spec.rb +19 -0
  144. data/spec/integration/rspec/be_falsey_matcher_spec.rb +53 -0
  145. data/spec/integration/rspec/be_matcher_spec.rb +565 -0
  146. data/spec/integration/rspec/be_nil_matcher_spec.rb +53 -0
  147. data/spec/integration/rspec/be_predicate_matcher_spec.rb +546 -0
  148. data/spec/integration/rspec/be_truthy_matcher_spec.rb +57 -0
  149. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +368 -0
  150. data/spec/integration/rspec/eq_matcher_spec.rb +874 -0
  151. data/spec/integration/rspec/have_attributes_matcher_spec.rb +299 -0
  152. data/spec/integration/rspec/include_matcher_spec.rb +350 -0
  153. data/spec/integration/rspec/match_matcher_spec.rb +1258 -0
  154. data/spec/integration/rspec/raise_error_matcher_spec.rb +350 -0
  155. data/spec/integration/rspec/respond_to_matcher_spec.rb +994 -0
  156. data/spec/integration/rspec/unhandled_errors_spec.rb +94 -0
  157. data/spec/spec_helper.rb +19 -4
  158. data/spec/support/colorizer.rb +9 -0
  159. data/spec/support/command_runner.rb +4 -0
  160. data/spec/support/integration/helpers.rb +179 -0
  161. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +79 -41
  162. data/spec/support/models/a.rb +11 -0
  163. data/spec/support/models/active_record/person.rb +26 -0
  164. data/spec/support/models/active_record/shipping_address.rb +29 -0
  165. data/spec/support/models/customer.rb +24 -0
  166. data/spec/support/models/empty_class.rb +6 -0
  167. data/spec/support/models/item.rb +10 -0
  168. data/spec/support/models/order.rb +9 -0
  169. data/spec/support/models/person.rb +20 -0
  170. data/spec/support/models/player.rb +33 -0
  171. data/spec/support/models/shipping_address.rb +34 -0
  172. data/spec/support/ruby_versions.rb +7 -0
  173. data/spec/support/shared_examples/active_record.rb +338 -0
  174. data/spec/support/shared_examples/hash_with_indifferent_access.rb +233 -0
  175. data/spec/unit/equality_matcher_spec.rb +579 -171
  176. data/spec/unit/object_inspection_spec.rb +1092 -0
  177. data/spec/unit/rspec/matchers/be_compared_to_spec.rb +23 -0
  178. data/spec/unit/rspec/matchers/be_falsey_spec.rb +9 -0
  179. data/spec/unit/rspec/matchers/be_nil_spec.rb +9 -0
  180. data/spec/unit/rspec/matchers/be_predicate_spec.rb +31 -0
  181. data/spec/unit/rspec/matchers/be_spec.rb +17 -0
  182. data/spec/unit/rspec/matchers/be_truthy_spec.rb +9 -0
  183. data/spec/unit/rspec/matchers/contain_exactly_spec.rb +11 -0
  184. data/spec/unit/rspec/matchers/eq_spec.rb +9 -0
  185. data/spec/unit/rspec/matchers/have_attributes_spec.rb +11 -0
  186. data/spec/unit/rspec/matchers/include_spec.rb +21 -0
  187. data/spec/unit/rspec/matchers/match_spec.rb +9 -0
  188. data/spec/unit/rspec/matchers/raise_error_spec.rb +29 -0
  189. data/spec/unit/rspec/matchers/respond_to_spec.rb +78 -0
  190. data/super_diff.gemspec +4 -2
  191. metadata +231 -34
  192. data/lib/super_diff/csi/color_helper.rb +0 -52
  193. data/lib/super_diff/csi/eight_bit_sequence.rb +0 -27
  194. data/lib/super_diff/csi/four_bit_sequence.rb +0 -24
  195. data/lib/super_diff/csi/sequence.rb +0 -22
  196. data/lib/super_diff/csi/twenty_four_bit_sequence.rb +0 -27
  197. data/lib/super_diff/diff_formatters/multi_line_string.rb +0 -31
  198. data/lib/super_diff/differs/object.rb +0 -68
  199. data/lib/super_diff/equality_matchers/object.rb +0 -18
  200. data/lib/super_diff/value_inspection.rb +0 -11
  201. data/spec/integration/rspec_spec.rb +0 -261
  202. data/spec/support/color_helper.rb +0 -49
  203. data/spec/support/person.rb +0 -23
  204. data/spec/support/person_diff_formatter.rb +0 -15
  205. data/spec/support/person_operation_sequence.rb +0 -14
  206. data/spec/support/person_operational_sequencer.rb +0 -19
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `be` matcher used with an operator" do
4
+ describe "#description" do
5
+ [:==, :===, :=~].each do |operator|
6
+ context "when the operator is #{operator}" do
7
+ it "returns the correct output" do
8
+ expect(be.public_send(operator, 2).description).to eq("#{operator} 2")
9
+ end
10
+ end
11
+ end
12
+
13
+ [:<, :<=, :>=, :>].each do |operator|
14
+ context "when the operator is #{operator}" do
15
+ it "returns the correct output" do
16
+ expect(be.public_send(operator, 2).description).to eq(
17
+ "be #{operator} 2",
18
+ )
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `be_truthy` matcher" do
4
+ describe "#description" do
5
+ it "returns the correct output" do
6
+ expect(be_falsey.description).to eq("be falsey")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `be_nil` matcher" do
4
+ describe "#description" do
5
+ it "returns the correct output" do
6
+ expect(be_nil.description).to eq("be nil")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `be_<predicate>` matcher" do
4
+ describe "#description" do
5
+ it "returns the correct output" do
6
+ expect(be_famous.description).to eq(
7
+ "return true for `famous?` or `famouss?`",
8
+ )
9
+ end
10
+ end
11
+ end
12
+
13
+ RSpec.describe "RSpec's `be_a_<predicate>` matcher" do
14
+ describe "#description" do
15
+ it "returns the correct output" do
16
+ expect(be_a_big_big_star.description).to eq(
17
+ "return true for `big_big_star?` or `big_big_stars?`",
18
+ )
19
+ end
20
+ end
21
+ end
22
+
23
+ RSpec.describe "RSpec's `be_an_<predicate>` matcher" do
24
+ describe "#description" do
25
+ it "returns the correct output" do
26
+ expect(be_an_open_book.description).to eq(
27
+ "return true for `open_book?` or `open_books?`",
28
+ )
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `be` matcher" do
4
+ describe "#description" do
5
+ context "given nothing" do
6
+ it "returns the correct output" do
7
+ expect(be.description).to eq("be truthy")
8
+ end
9
+ end
10
+
11
+ context "given an argument" do
12
+ it "returns the correct output" do
13
+ expect(be(:foo).description).to eq("equal :foo")
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `be_truthy` matcher" do
4
+ describe "#description" do
5
+ it "returns the correct output" do
6
+ expect(be_truthy.description).to eq("be truthy")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `contain_exactly` matcher" do
4
+ describe "#description" do
5
+ it "returns the correct output" do
6
+ expect(contain_exactly(:foo, :bar, :baz).description).to eq(
7
+ "contain exactly :foo, :bar and :baz",
8
+ )
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `eq` matcher" do
4
+ describe "#description" do
5
+ it "returns the correct output" do
6
+ expect(eq(:foo).description).to eq("eq :foo")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `have_attributes` matcher" do
4
+ describe "#description" do
5
+ it "returns the correct output" do
6
+ expect(have_attributes(foo: "bar", baz: "qux").description).to eq(
7
+ %|have attributes (foo: "bar", baz: "qux")|,
8
+ )
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `include` matcher" do
4
+ describe "#description" do
5
+ context "given a list of items" do
6
+ it "returns the correct output" do
7
+ expect(include(:foo, :bar, :baz).description).to eq(
8
+ "include :foo, :bar, and :baz",
9
+ )
10
+ end
11
+ end
12
+
13
+ context "given a hash" do
14
+ it "returns the correct output" do
15
+ expect(include(foo: "bar", baz: "qux").description).to eq(
16
+ 'include (foo: "bar", baz: "qux")',
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `match` matcher" do
4
+ describe "#description" do
5
+ it "returns the correct output" do
6
+ expect(match(:foo).description).to eq("match :foo")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `raise_error` matcher" do
4
+ describe "#description" do
5
+ context "given only an exception class" do
6
+ it "returns the correct output" do
7
+ expect(raise_error(RuntimeError).description).to eq(
8
+ %|raise error #<RuntimeError>|,
9
+ )
10
+ end
11
+ end
12
+
13
+ context "with only a message (and assuming a RuntimeError)" do
14
+ it "returns the correct output" do
15
+ expect(raise_error("hell").description).to eq(
16
+ %|raise error #<Exception "hell">|,
17
+ )
18
+ end
19
+ end
20
+
21
+ context "with both an exception and a message" do
22
+ it "returns the correct output" do
23
+ expect(raise_error(RuntimeError, "hell").description).to eq(
24
+ %|raise error #<RuntimeError "hell">|,
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,78 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "RSpec's `respond_to` matcher" do
4
+ describe "#description" do
5
+ context "without any qualifiers" do
6
+ it "returns the correct output" do
7
+ expect(respond_to(:foo, :bar, :baz).description).to eq(
8
+ "respond to :foo, :bar and :baz",
9
+ )
10
+ end
11
+ end
12
+
13
+ context "qualified with #with + #arguments" do
14
+ it "returns the correct output" do
15
+ expect(respond_to(:foo, :bar, :baz).with(3).arguments.description).
16
+ to eq("respond to :foo, :bar and :baz with 3 arguments")
17
+ end
18
+ end
19
+
20
+ context "qualified with #with_keywords" do
21
+ it "returns the correct output" do
22
+ matcher = respond_to(:foo, :bar, :baz).
23
+ with_keywords(:qux, :blargh, :fizz)
24
+
25
+ expect(matcher.description).to eq(
26
+ "respond to :foo, :bar and :baz with keywords :qux, :blargh " +
27
+ "and :fizz",
28
+ )
29
+ end
30
+ end
31
+
32
+ context "qualified with #with_any_keywords" do
33
+ it "returns the correct output" do
34
+ matcher = respond_to(:foo, :bar, :baz).with_any_keywords
35
+
36
+ expect(matcher.description).to eq(
37
+ "respond to :foo, :bar and :baz with any keywords",
38
+ )
39
+ end
40
+ end
41
+
42
+ context "qualified with #with_unlimited_arguments" do
43
+ it "returns the correct output" do
44
+ matcher = respond_to(:foo, :bar, :baz).with_unlimited_arguments
45
+
46
+ expect(matcher.description).to eq(
47
+ "respond to :foo, :bar and :baz with unlimited arguments",
48
+ )
49
+ end
50
+ end
51
+
52
+ context "qualified with #with_any_keywords + #with_unlimited_arguments" do
53
+ it "returns the correct output" do
54
+ matcher = respond_to(:foo, :bar, :baz).
55
+ with_any_keywords.
56
+ with_unlimited_arguments
57
+
58
+ expect(matcher.description).to eq(
59
+ "respond to :foo, :bar and :baz with any keywords and unlimited " +
60
+ "arguments",
61
+ )
62
+ end
63
+ end
64
+
65
+ context "qualified with #with_keywords + #with_unlimited_arguments" do
66
+ it "returns the correct output" do
67
+ matcher = respond_to(:foo, :bar, :baz).
68
+ with_keywords(:qux, :blargh, :fizz).
69
+ with_unlimited_arguments
70
+
71
+ expect(matcher.description).to eq(
72
+ "respond to :foo, :bar and :baz with keywords :qux, :blargh and " +
73
+ ":fizz and unlimited arguments",
74
+ )
75
+ end
76
+ end
77
+ end
78
+ end
data/super_diff.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- require File.expand_path("../lib/super_diff/version", __FILE__)
1
+ require File.expand_path("lib/super_diff/version", __dir__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "super_diff"
@@ -12,12 +12,14 @@ Gem::Specification.new do |s|
12
12
  Ruby, and gives you helpful output to show you exactly how the two data
13
13
  structures differ.
14
14
  DESC
15
- s.required_ruby_version = "~> 2.3"
15
+ s.required_ruby_version = "~> 2.4"
16
16
 
17
17
  s.files = ["README.md", "super_diff.gemspec"] + Dir["lib/**/*"]
18
18
  s.test_files = Dir["spec/**/*"]
19
19
  s.executables = Dir["exe/**/*"].map { |f| File.basename(f) }
20
20
 
21
+ s.add_dependency "activerecord", "> 4.2", "< 7.0"
22
+ s.add_dependency "attr_extras"
21
23
  s.add_dependency "diff-lcs"
22
24
  s.add_dependency "patience_diff"
23
25
  end
metadata CHANGED
@@ -1,15 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Winkler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-03 00:00:00.000000000 Z
11
+ date: 2019-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: attr_extras
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
13
47
  - !ruby/object:Gem::Dependency
14
48
  name: diff-lcs
15
49
  requirement: !ruby/object:Gem::Requirement
@@ -50,71 +84,197 @@ extra_rdoc_files: []
50
84
  files:
51
85
  - README.md
52
86
  - lib/super_diff.rb
87
+ - lib/super_diff/active_record.rb
88
+ - lib/super_diff/active_record/diff_formatters.rb
89
+ - lib/super_diff/active_record/diff_formatters/active_record_relation.rb
90
+ - lib/super_diff/active_record/differs.rb
91
+ - lib/super_diff/active_record/differs/active_record_relation.rb
92
+ - lib/super_diff/active_record/object_inspection.rb
93
+ - lib/super_diff/active_record/object_inspection/inspectors.rb
94
+ - lib/super_diff/active_record/object_inspection/inspectors/active_record_model.rb
95
+ - lib/super_diff/active_record/object_inspection/inspectors/active_record_relation.rb
96
+ - lib/super_diff/active_record/object_inspection/map_extension.rb
97
+ - lib/super_diff/active_record/operation_sequences.rb
98
+ - lib/super_diff/active_record/operation_sequences/active_record_relation.rb
99
+ - lib/super_diff/active_record/operational_sequencers.rb
100
+ - lib/super_diff/active_record/operational_sequencers/active_record_model.rb
101
+ - lib/super_diff/active_record/operational_sequencers/active_record_relation.rb
102
+ - lib/super_diff/active_support.rb
103
+ - lib/super_diff/active_support/diff_formatters.rb
104
+ - lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb
105
+ - lib/super_diff/active_support/differs.rb
106
+ - lib/super_diff/active_support/differs/hash_with_indifferent_access.rb
107
+ - lib/super_diff/active_support/object_inspection.rb
108
+ - lib/super_diff/active_support/object_inspection/inspectors.rb
109
+ - lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb
110
+ - lib/super_diff/active_support/object_inspection/map_extension.rb
111
+ - lib/super_diff/active_support/operation_sequences.rb
112
+ - lib/super_diff/active_support/operation_sequences/hash_with_indifferent_access.rb
113
+ - lib/super_diff/active_support/operational_sequencers.rb
114
+ - lib/super_diff/active_support/operational_sequencers/hash_with_indifferent_access.rb
115
+ - lib/super_diff/colorized_document_extensions.rb
53
116
  - lib/super_diff/csi.rb
54
- - lib/super_diff/csi/color_helper.rb
117
+ - lib/super_diff/csi/bold_sequence.rb
118
+ - lib/super_diff/csi/color.rb
119
+ - lib/super_diff/csi/color_sequence_block.rb
120
+ - lib/super_diff/csi/colorized_document.rb
121
+ - lib/super_diff/csi/document.rb
55
122
  - lib/super_diff/csi/eight_bit_color.rb
56
- - lib/super_diff/csi/eight_bit_sequence.rb
57
123
  - lib/super_diff/csi/four_bit_color.rb
58
- - lib/super_diff/csi/four_bit_sequence.rb
59
124
  - lib/super_diff/csi/reset_sequence.rb
60
- - lib/super_diff/csi/sequence.rb
61
125
  - lib/super_diff/csi/twenty_four_bit_color.rb
62
- - lib/super_diff/csi/twenty_four_bit_sequence.rb
126
+ - lib/super_diff/csi/uncolorized_document.rb
63
127
  - lib/super_diff/diff_formatter.rb
64
128
  - lib/super_diff/diff_formatters.rb
65
129
  - lib/super_diff/diff_formatters/array.rb
66
130
  - lib/super_diff/diff_formatters/base.rb
67
131
  - lib/super_diff/diff_formatters/collection.rb
132
+ - lib/super_diff/diff_formatters/custom_object.rb
133
+ - lib/super_diff/diff_formatters/default_object.rb
68
134
  - lib/super_diff/diff_formatters/hash.rb
69
- - lib/super_diff/diff_formatters/multi_line_string.rb
70
- - lib/super_diff/diff_formatters/object.rb
135
+ - lib/super_diff/diff_formatters/multiline_string.rb
71
136
  - lib/super_diff/differ.rb
72
137
  - lib/super_diff/differs.rb
73
138
  - lib/super_diff/differs/array.rb
74
139
  - lib/super_diff/differs/base.rb
140
+ - lib/super_diff/differs/custom_object.rb
141
+ - lib/super_diff/differs/default_object.rb
75
142
  - lib/super_diff/differs/empty.rb
76
143
  - lib/super_diff/differs/hash.rb
77
- - lib/super_diff/differs/multi_line_string.rb
78
- - lib/super_diff/differs/object.rb
144
+ - lib/super_diff/differs/multiline_string.rb
79
145
  - lib/super_diff/equality_matcher.rb
80
146
  - lib/super_diff/equality_matchers.rb
81
147
  - lib/super_diff/equality_matchers/array.rb
82
148
  - lib/super_diff/equality_matchers/base.rb
149
+ - lib/super_diff/equality_matchers/default.rb
83
150
  - lib/super_diff/equality_matchers/hash.rb
84
- - lib/super_diff/equality_matchers/multi_line_string.rb
85
- - lib/super_diff/equality_matchers/object.rb
86
- - lib/super_diff/equality_matchers/single_line_string.rb
87
- - lib/super_diff/errors.rb
151
+ - lib/super_diff/equality_matchers/multiline_string.rb
152
+ - lib/super_diff/equality_matchers/primitive.rb
153
+ - lib/super_diff/equality_matchers/singleline_string.rb
88
154
  - lib/super_diff/helpers.rb
155
+ - lib/super_diff/no_differ_available_error.rb
156
+ - lib/super_diff/no_operational_sequencer_available_error.rb
157
+ - lib/super_diff/object_inspection.rb
158
+ - lib/super_diff/object_inspection/inspection_tree.rb
159
+ - lib/super_diff/object_inspection/inspector.rb
160
+ - lib/super_diff/object_inspection/inspectors.rb
161
+ - lib/super_diff/object_inspection/inspectors/array.rb
162
+ - lib/super_diff/object_inspection/inspectors/custom_object.rb
163
+ - lib/super_diff/object_inspection/inspectors/default_object.rb
164
+ - lib/super_diff/object_inspection/inspectors/hash.rb
165
+ - lib/super_diff/object_inspection/inspectors/primitive.rb
166
+ - lib/super_diff/object_inspection/inspectors/string.rb
167
+ - lib/super_diff/object_inspection/map.rb
168
+ - lib/super_diff/object_inspection/nodes.rb
169
+ - lib/super_diff/object_inspection/nodes/base.rb
170
+ - lib/super_diff/object_inspection/nodes/break.rb
171
+ - lib/super_diff/object_inspection/nodes/inspection.rb
172
+ - lib/super_diff/object_inspection/nodes/nesting.rb
173
+ - lib/super_diff/object_inspection/nodes/text.rb
174
+ - lib/super_diff/object_inspection/nodes/when_empty.rb
175
+ - lib/super_diff/object_inspection/nodes/when_multiline.rb
176
+ - lib/super_diff/object_inspection/nodes/when_non_empty.rb
177
+ - lib/super_diff/object_inspection/nodes/when_singleline.rb
178
+ - lib/super_diff/operation_sequences.rb
89
179
  - lib/super_diff/operation_sequences/array.rb
90
180
  - lib/super_diff/operation_sequences/base.rb
181
+ - lib/super_diff/operation_sequences/custom_object.rb
182
+ - lib/super_diff/operation_sequences/default_object.rb
91
183
  - lib/super_diff/operation_sequences/hash.rb
92
- - lib/super_diff/operation_sequences/object.rb
93
184
  - lib/super_diff/operational_sequencer.rb
94
185
  - lib/super_diff/operational_sequencers.rb
95
186
  - lib/super_diff/operational_sequencers/array.rb
96
187
  - lib/super_diff/operational_sequencers/base.rb
188
+ - lib/super_diff/operational_sequencers/custom_object.rb
189
+ - lib/super_diff/operational_sequencers/default_object.rb
97
190
  - lib/super_diff/operational_sequencers/hash.rb
98
- - lib/super_diff/operational_sequencers/multi_line_string.rb
99
- - lib/super_diff/operational_sequencers/object.rb
191
+ - lib/super_diff/operational_sequencers/multiline_string.rb
192
+ - lib/super_diff/operations.rb
100
193
  - lib/super_diff/operations/binary_operation.rb
101
194
  - lib/super_diff/operations/unary_operation.rb
195
+ - lib/super_diff/rails.rb
196
+ - lib/super_diff/recursion_guard.rb
197
+ - lib/super_diff/rspec-rails.rb
102
198
  - lib/super_diff/rspec.rb
199
+ - lib/super_diff/rspec/augmented_matcher.rb
200
+ - lib/super_diff/rspec/configuration.rb
103
201
  - lib/super_diff/rspec/differ.rb
202
+ - lib/super_diff/rspec/differs.rb
203
+ - lib/super_diff/rspec/differs/collection_containing_exactly.rb
204
+ - lib/super_diff/rspec/differs/partial_array.rb
205
+ - lib/super_diff/rspec/differs/partial_hash.rb
206
+ - lib/super_diff/rspec/differs/partial_object.rb
207
+ - lib/super_diff/rspec/matcher_text_builders.rb
208
+ - lib/super_diff/rspec/matcher_text_builders/base.rb
209
+ - lib/super_diff/rspec/matcher_text_builders/be_predicate.rb
210
+ - lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb
211
+ - lib/super_diff/rspec/matcher_text_builders/match.rb
212
+ - lib/super_diff/rspec/matcher_text_builders/raise_error.rb
213
+ - lib/super_diff/rspec/matcher_text_builders/respond_to.rb
214
+ - lib/super_diff/rspec/matcher_text_template.rb
104
215
  - lib/super_diff/rspec/monkey_patches.rb
105
- - lib/super_diff/value_inspection.rb
216
+ - lib/super_diff/rspec/object_inspection.rb
217
+ - lib/super_diff/rspec/object_inspection/inspectors.rb
218
+ - lib/super_diff/rspec/object_inspection/inspectors/collection_containing_exactly.rb
219
+ - lib/super_diff/rspec/object_inspection/inspectors/partial_array.rb
220
+ - lib/super_diff/rspec/object_inspection/inspectors/partial_hash.rb
221
+ - lib/super_diff/rspec/object_inspection/inspectors/partial_object.rb
222
+ - lib/super_diff/rspec/object_inspection/map_extension.rb
223
+ - lib/super_diff/rspec/operational_sequencers.rb
224
+ - lib/super_diff/rspec/operational_sequencers/collection_containing_exactly.rb
225
+ - lib/super_diff/rspec/operational_sequencers/partial_array.rb
226
+ - lib/super_diff/rspec/operational_sequencers/partial_hash.rb
227
+ - lib/super_diff/rspec/operational_sequencers/partial_object.rb
106
228
  - lib/super_diff/version.rb
107
229
  - spec/examples.txt
108
- - spec/integration/rspec_spec.rb
230
+ - spec/integration/rails/active_record_spec.rb
231
+ - spec/integration/rails/hash_with_indifferent_access_spec.rb
232
+ - spec/integration/rspec/be_falsey_matcher_spec.rb
233
+ - spec/integration/rspec/be_matcher_spec.rb
234
+ - spec/integration/rspec/be_nil_matcher_spec.rb
235
+ - spec/integration/rspec/be_predicate_matcher_spec.rb
236
+ - spec/integration/rspec/be_truthy_matcher_spec.rb
237
+ - spec/integration/rspec/contain_exactly_matcher_spec.rb
238
+ - spec/integration/rspec/eq_matcher_spec.rb
239
+ - spec/integration/rspec/have_attributes_matcher_spec.rb
240
+ - spec/integration/rspec/include_matcher_spec.rb
241
+ - spec/integration/rspec/match_matcher_spec.rb
242
+ - spec/integration/rspec/raise_error_matcher_spec.rb
243
+ - spec/integration/rspec/respond_to_matcher_spec.rb
244
+ - spec/integration/rspec/unhandled_errors_spec.rb
109
245
  - spec/spec_helper.rb
110
- - spec/support/color_helper.rb
246
+ - spec/support/colorizer.rb
111
247
  - spec/support/command_runner.rb
248
+ - spec/support/integration/helpers.rb
112
249
  - spec/support/integration/matchers/produce_output_when_run_matcher.rb
113
- - spec/support/person.rb
114
- - spec/support/person_diff_formatter.rb
115
- - spec/support/person_operation_sequence.rb
116
- - spec/support/person_operational_sequencer.rb
250
+ - spec/support/models/a.rb
251
+ - spec/support/models/active_record/person.rb
252
+ - spec/support/models/active_record/shipping_address.rb
253
+ - spec/support/models/customer.rb
254
+ - spec/support/models/empty_class.rb
255
+ - spec/support/models/item.rb
256
+ - spec/support/models/order.rb
257
+ - spec/support/models/person.rb
258
+ - spec/support/models/player.rb
259
+ - spec/support/models/shipping_address.rb
260
+ - spec/support/ruby_versions.rb
261
+ - spec/support/shared_examples/active_record.rb
262
+ - spec/support/shared_examples/hash_with_indifferent_access.rb
117
263
  - spec/unit/equality_matcher_spec.rb
264
+ - spec/unit/object_inspection_spec.rb
265
+ - spec/unit/rspec/matchers/be_compared_to_spec.rb
266
+ - spec/unit/rspec/matchers/be_falsey_spec.rb
267
+ - spec/unit/rspec/matchers/be_nil_spec.rb
268
+ - spec/unit/rspec/matchers/be_predicate_spec.rb
269
+ - spec/unit/rspec/matchers/be_spec.rb
270
+ - spec/unit/rspec/matchers/be_truthy_spec.rb
271
+ - spec/unit/rspec/matchers/contain_exactly_spec.rb
272
+ - spec/unit/rspec/matchers/eq_spec.rb
273
+ - spec/unit/rspec/matchers/have_attributes_spec.rb
274
+ - spec/unit/rspec/matchers/include_spec.rb
275
+ - spec/unit/rspec/matchers/match_spec.rb
276
+ - spec/unit/rspec/matchers/raise_error_spec.rb
277
+ - spec/unit/rspec/matchers/respond_to_spec.rb
118
278
  - super_diff.gemspec
119
279
  homepage: https://github.com/mcmire/super_diff
120
280
  licenses: []
@@ -127,27 +287,64 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
287
  requirements:
128
288
  - - "~>"
129
289
  - !ruby/object:Gem::Version
130
- version: '2.3'
290
+ version: '2.4'
131
291
  required_rubygems_version: !ruby/object:Gem::Requirement
132
292
  requirements:
133
293
  - - ">="
134
294
  - !ruby/object:Gem::Version
135
295
  version: '0'
136
296
  requirements: []
137
- rubyforge_project:
138
- rubygems_version: 2.7.6
297
+ rubygems_version: 3.0.6
139
298
  signing_key:
140
299
  specification_version: 4
141
300
  summary: Diff complex data structures in Ruby, with helpful output.
142
301
  test_files:
143
302
  - spec/spec_helper.rb
303
+ - spec/unit/object_inspection_spec.rb
144
304
  - spec/unit/equality_matcher_spec.rb
305
+ - spec/unit/rspec/matchers/contain_exactly_spec.rb
306
+ - spec/unit/rspec/matchers/be_predicate_spec.rb
307
+ - spec/unit/rspec/matchers/raise_error_spec.rb
308
+ - spec/unit/rspec/matchers/eq_spec.rb
309
+ - spec/unit/rspec/matchers/have_attributes_spec.rb
310
+ - spec/unit/rspec/matchers/match_spec.rb
311
+ - spec/unit/rspec/matchers/be_spec.rb
312
+ - spec/unit/rspec/matchers/be_compared_to_spec.rb
313
+ - spec/unit/rspec/matchers/respond_to_spec.rb
314
+ - spec/unit/rspec/matchers/be_nil_spec.rb
315
+ - spec/unit/rspec/matchers/be_falsey_spec.rb
316
+ - spec/unit/rspec/matchers/be_truthy_spec.rb
317
+ - spec/unit/rspec/matchers/include_spec.rb
145
318
  - spec/examples.txt
146
- - spec/integration/rspec_spec.rb
147
- - spec/support/person_operational_sequencer.rb
319
+ - spec/integration/rspec/be_predicate_matcher_spec.rb
320
+ - spec/integration/rspec/be_falsey_matcher_spec.rb
321
+ - spec/integration/rspec/be_truthy_matcher_spec.rb
322
+ - spec/integration/rspec/be_nil_matcher_spec.rb
323
+ - spec/integration/rspec/unhandled_errors_spec.rb
324
+ - spec/integration/rspec/be_matcher_spec.rb
325
+ - spec/integration/rspec/respond_to_matcher_spec.rb
326
+ - spec/integration/rspec/match_matcher_spec.rb
327
+ - spec/integration/rspec/have_attributes_matcher_spec.rb
328
+ - spec/integration/rspec/raise_error_matcher_spec.rb
329
+ - spec/integration/rspec/eq_matcher_spec.rb
330
+ - spec/integration/rspec/contain_exactly_matcher_spec.rb
331
+ - spec/integration/rspec/include_matcher_spec.rb
332
+ - spec/integration/rails/active_record_spec.rb
333
+ - spec/integration/rails/hash_with_indifferent_access_spec.rb
334
+ - spec/support/integration/helpers.rb
148
335
  - spec/support/integration/matchers/produce_output_when_run_matcher.rb
149
- - spec/support/person_diff_formatter.rb
336
+ - spec/support/models/item.rb
337
+ - spec/support/models/customer.rb
338
+ - spec/support/models/empty_class.rb
339
+ - spec/support/models/player.rb
340
+ - spec/support/models/active_record/shipping_address.rb
341
+ - spec/support/models/active_record/person.rb
342
+ - spec/support/models/a.rb
343
+ - spec/support/models/shipping_address.rb
344
+ - spec/support/models/order.rb
345
+ - spec/support/models/person.rb
150
346
  - spec/support/command_runner.rb
151
- - spec/support/person_operation_sequence.rb
152
- - spec/support/person.rb
153
- - spec/support/color_helper.rb
347
+ - spec/support/ruby_versions.rb
348
+ - spec/support/colorizer.rb
349
+ - spec/support/shared_examples/hash_with_indifferent_access.rb
350
+ - spec/support/shared_examples/active_record.rb