super_diff 0.4.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +64 -24
- data/lib/super_diff.rb +20 -17
- data/lib/super_diff/active_record.rb +20 -24
- data/lib/super_diff/active_record/diff_formatters/active_record_relation.rb +3 -3
- data/lib/super_diff/active_record/differs/active_record_relation.rb +3 -5
- data/lib/super_diff/active_record/object_inspection/inspectors/active_record_model.rb +32 -22
- data/lib/super_diff/active_record/object_inspection/inspectors/active_record_relation.rb +17 -7
- data/lib/super_diff/active_record/operation_tree_builders.rb +14 -0
- data/lib/super_diff/active_record/{operational_sequencers → operation_tree_builders}/active_record_model.rb +2 -2
- data/lib/super_diff/active_record/{operational_sequencers → operation_tree_builders}/active_record_relation.rb +4 -4
- data/lib/super_diff/active_record/{operation_sequences.rb → operation_trees.rb} +2 -2
- data/lib/super_diff/active_record/{operation_sequences → operation_trees}/active_record_relation.rb +2 -2
- data/lib/super_diff/active_support.rb +16 -19
- data/lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb +3 -3
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +3 -5
- data/lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb +17 -7
- data/lib/super_diff/active_support/operation_tree_builders.rb +10 -0
- data/lib/super_diff/active_support/{operational_sequencers → operation_tree_builders}/hash_with_indifferent_access.rb +2 -2
- data/lib/super_diff/active_support/{operation_sequences.rb → operation_trees.rb} +2 -2
- data/lib/super_diff/active_support/{operation_sequences → operation_trees}/hash_with_indifferent_access.rb +2 -2
- data/lib/super_diff/colorized_document_extensions.rb +4 -4
- data/lib/super_diff/configuration.rb +70 -0
- data/lib/super_diff/csi.rb +2 -1
- data/lib/super_diff/diff_formatters.rb +3 -3
- data/lib/super_diff/diff_formatters/array.rb +3 -3
- data/lib/super_diff/diff_formatters/base.rb +3 -2
- data/lib/super_diff/diff_formatters/collection.rb +3 -3
- data/lib/super_diff/diff_formatters/custom_object.rb +3 -3
- data/lib/super_diff/diff_formatters/default_object.rb +6 -8
- data/lib/super_diff/diff_formatters/defaults.rb +10 -0
- data/lib/super_diff/diff_formatters/hash.rb +3 -3
- data/lib/super_diff/diff_formatters/main.rb +41 -0
- data/lib/super_diff/diff_formatters/multiline_string.rb +7 -7
- data/lib/super_diff/differs.rb +4 -11
- data/lib/super_diff/differs/array.rb +2 -11
- data/lib/super_diff/differs/base.rb +20 -3
- data/lib/super_diff/differs/custom_object.rb +2 -11
- data/lib/super_diff/differs/default_object.rb +2 -8
- data/lib/super_diff/differs/defaults.rb +12 -0
- data/lib/super_diff/differs/hash.rb +2 -11
- data/lib/super_diff/differs/main.rb +48 -0
- data/lib/super_diff/differs/multiline_string.rb +2 -14
- data/lib/super_diff/differs/time_like.rb +15 -0
- data/lib/super_diff/equality_matchers.rb +3 -9
- data/lib/super_diff/equality_matchers/array.rb +3 -9
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +3 -9
- data/lib/super_diff/equality_matchers/defaults.rb +12 -0
- data/lib/super_diff/equality_matchers/hash.rb +3 -9
- data/lib/super_diff/equality_matchers/main.rb +21 -0
- data/lib/super_diff/equality_matchers/multiline_string.rb +3 -9
- data/lib/super_diff/equality_matchers/primitive.rb +2 -2
- data/lib/super_diff/equality_matchers/singleline_string.rb +2 -2
- data/lib/super_diff/errors.rb +16 -0
- data/lib/super_diff/errors/no_diff_formatter_available_error.rb +21 -0
- data/lib/super_diff/errors/no_differ_available_error.rb +24 -0
- data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +22 -0
- data/lib/super_diff/gem_version.rb +45 -0
- data/lib/super_diff/implementation_checks.rb +19 -0
- data/lib/super_diff/object_inspection.rb +1 -10
- data/lib/super_diff/object_inspection/inspection_tree.rb +6 -2
- data/lib/super_diff/object_inspection/inspectors.rb +5 -1
- data/lib/super_diff/object_inspection/inspectors/array.rb +20 -10
- data/lib/super_diff/object_inspection/inspectors/base.rb +36 -0
- data/lib/super_diff/object_inspection/inspectors/custom_object.rb +24 -14
- data/lib/super_diff/object_inspection/inspectors/default_object.rb +44 -30
- data/lib/super_diff/object_inspection/inspectors/defaults.rb +15 -0
- data/lib/super_diff/object_inspection/inspectors/hash.rb +20 -10
- data/lib/super_diff/object_inspection/inspectors/main.rb +35 -0
- data/lib/super_diff/object_inspection/inspectors/primitive.rb +20 -5
- data/lib/super_diff/object_inspection/inspectors/string.rb +15 -5
- data/lib/super_diff/object_inspection/inspectors/time_like.rb +23 -0
- data/lib/super_diff/object_inspection/nodes/inspection.rb +9 -2
- data/lib/super_diff/operation_tree_builders.rb +18 -0
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/array.rb +38 -59
- data/lib/super_diff/operation_tree_builders/base.rb +98 -0
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/custom_object.rb +3 -3
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/default_object.rb +8 -3
- data/lib/super_diff/operation_tree_builders/defaults.rb +5 -0
- data/lib/super_diff/operation_tree_builders/hash.rb +226 -0
- data/lib/super_diff/operation_tree_builders/main.rb +42 -0
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/multiline_string.rb +3 -3
- data/lib/super_diff/operation_tree_builders/time_like.rb +34 -0
- data/lib/super_diff/operation_trees.rb +13 -0
- data/lib/super_diff/{operation_sequences → operation_trees}/array.rb +5 -1
- data/lib/super_diff/{operation_sequences → operation_trees}/base.rb +9 -1
- data/lib/super_diff/{operation_sequences → operation_trees}/custom_object.rb +5 -1
- data/lib/super_diff/{operation_sequences → operation_trees}/default_object.rb +10 -8
- data/lib/super_diff/operation_trees/defaults.rb +5 -0
- data/lib/super_diff/{operation_sequences → operation_trees}/hash.rb +5 -1
- data/lib/super_diff/operation_trees/main.rb +35 -0
- data/lib/super_diff/operation_trees/multiline_string.rb +18 -0
- data/lib/super_diff/operations/unary_operation.rb +3 -0
- data/lib/super_diff/recursion_guard.rb +2 -0
- data/lib/super_diff/rspec.rb +49 -13
- data/lib/super_diff/rspec/augmented_matcher.rb +1 -1
- data/lib/super_diff/rspec/differ.rb +2 -17
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +2 -7
- data/lib/super_diff/rspec/differs/collection_including.rb +2 -7
- data/lib/super_diff/rspec/differs/hash_including.rb +2 -7
- data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -7
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +7 -7
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +6 -6
- data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +4 -4
- data/lib/super_diff/rspec/matcher_text_builders/match.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +6 -6
- data/lib/super_diff/rspec/matcher_text_template.rb +1 -1
- data/lib/super_diff/rspec/monkey_patches.rb +23 -14
- data/lib/super_diff/rspec/object_inspection.rb +0 -1
- data/lib/super_diff/rspec/object_inspection/inspectors.rb +16 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/collection_containing_exactly.rb +17 -8
- data/lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb +15 -9
- data/lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb +20 -10
- data/lib/super_diff/rspec/object_inspection/inspectors/instance_of.rb +23 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/kind_of.rb +23 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/object_having_attributes.rb +20 -11
- data/lib/super_diff/rspec/object_inspection/inspectors/primitive.rb +13 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/value_within.rb +29 -0
- data/lib/super_diff/rspec/operation_tree_builders.rb +22 -0
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_containing_exactly.rb +17 -6
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_including.rb +2 -2
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/hash_including.rb +3 -11
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/object_having_attributes.rb +4 -8
- data/lib/super_diff/version.rb +1 -1
- data/spec/examples.txt +393 -393
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +10 -10
- data/spec/integration/rspec/be_matcher_spec.rb +100 -100
- data/spec/integration/rspec/be_nil_matcher_spec.rb +10 -10
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +103 -103
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +10 -10
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +107 -107
- data/spec/integration/rspec/eq_matcher_spec.rb +230 -230
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +360 -233
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +65 -65
- data/spec/integration/rspec/include_matcher_spec.rb +73 -73
- data/spec/integration/rspec/match_array_matcher_spec.rb +149 -107
- data/spec/integration/rspec/match_matcher_spec.rb +274 -274
- data/spec/integration/rspec/raise_error_matcher_spec.rb +86 -86
- data/spec/integration/rspec/respond_to_matcher_spec.rb +240 -240
- data/spec/integration/rspec/third_party_matcher_spec.rb +8 -8
- data/spec/integration/rspec/unhandled_errors_spec.rb +69 -13
- data/spec/spec_helper.rb +22 -13
- data/spec/support/command_runner.rb +3 -0
- data/spec/support/integration/helpers.rb +15 -95
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +15 -30
- data/spec/support/integration/test_programs/base.rb +122 -0
- data/spec/support/integration/test_programs/plain.rb +13 -0
- data/spec/support/integration/test_programs/rspec_active_record.rb +17 -0
- data/spec/support/integration/test_programs/rspec_active_support.rb +17 -0
- data/spec/support/integration/test_programs/rspec_rails.rb +17 -0
- data/spec/support/models/active_record/person.rb +4 -11
- data/spec/support/models/active_record/shipping_address.rb +10 -14
- data/spec/support/object_id.rb +6 -5
- data/spec/support/shared_examples/active_record.rb +108 -108
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +196 -232
- data/spec/tmp/integration_spec.rb +15 -0
- data/spec/unit/{equality_matcher_spec.rb → equality_matchers/main_spec.rb} +518 -362
- data/spec/unit/object_inspection_spec.rb +77 -1
- data/super_diff.gemspec +3 -2
- metadata +83 -54
- data/lib/super_diff/active_record/object_inspection/map_extension.rb +0 -18
- data/lib/super_diff/active_record/operational_sequencers.rb +0 -14
- data/lib/super_diff/active_support/object_inspection/map_extension.rb +0 -15
- data/lib/super_diff/active_support/operational_sequencers.rb +0 -10
- data/lib/super_diff/diff_formatter.rb +0 -32
- data/lib/super_diff/differ.rb +0 -51
- data/lib/super_diff/differs/time.rb +0 -24
- data/lib/super_diff/equality_matcher.rb +0 -32
- data/lib/super_diff/no_differ_available_error.rb +0 -22
- data/lib/super_diff/no_operational_sequencer_available_error.rb +0 -20
- data/lib/super_diff/object_inspection/inspector.rb +0 -27
- data/lib/super_diff/object_inspection/inspectors/time.rb +0 -13
- data/lib/super_diff/object_inspection/map.rb +0 -30
- data/lib/super_diff/operation_sequences.rb +0 -9
- data/lib/super_diff/operational_sequencer.rb +0 -48
- data/lib/super_diff/operational_sequencers.rb +0 -17
- data/lib/super_diff/operational_sequencers/base.rb +0 -89
- data/lib/super_diff/operational_sequencers/hash.rb +0 -85
- data/lib/super_diff/operational_sequencers/time_like.rb +0 -30
- data/lib/super_diff/rspec/configuration.rb +0 -31
- data/lib/super_diff/rspec/object_inspection/map_extension.rb +0 -23
- data/lib/super_diff/rspec/operational_sequencers.rb +0 -22
@@ -0,0 +1,122 @@
|
|
1
|
+
require "attr_extras/explicit"
|
2
|
+
|
3
|
+
module SuperDiff
|
4
|
+
module IntegrationTests
|
5
|
+
module TestPrograms
|
6
|
+
class Base
|
7
|
+
extend AttrExtras.mixin
|
8
|
+
|
9
|
+
PROJECT_DIRECTORY = Pathname.new("../../../..").expand_path(__dir__)
|
10
|
+
TEMP_DIRECTORY = PROJECT_DIRECTORY.join("tmp")
|
11
|
+
|
12
|
+
attr_private :code, :color_enabled, :preserve_as_whole_file
|
13
|
+
|
14
|
+
def initialize(code, color_enabled:, preserve_as_whole_file: false)
|
15
|
+
@code = code.strip
|
16
|
+
@color_enabled = color_enabled
|
17
|
+
@preserve_as_whole_file = preserve_as_whole_file
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
result_of_command
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def test_plan_prelude
|
27
|
+
""
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_plan_command
|
31
|
+
raise NotImplementedError
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_query :color_enabled?
|
37
|
+
attr_query :preserve_as_whole_file?
|
38
|
+
|
39
|
+
def result_of_command
|
40
|
+
@_result_of_command ||=
|
41
|
+
if zeus_running?
|
42
|
+
Bundler.with_unbundled_env { CommandRunner.run(*command) }
|
43
|
+
else
|
44
|
+
CommandRunner.run(*command)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def command
|
49
|
+
if ENV["RAILS_ENV"]
|
50
|
+
raise "RAILS_ENV is being set somehow?!"
|
51
|
+
end
|
52
|
+
|
53
|
+
if zeus_running?
|
54
|
+
["zeus", test_plan_command, color_option, tempfile.to_s]
|
55
|
+
else
|
56
|
+
[
|
57
|
+
"rspec",
|
58
|
+
"--options",
|
59
|
+
"/tmp/dummy-rspec-config",
|
60
|
+
tempfile.to_s,
|
61
|
+
]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def zeus_running?
|
66
|
+
PROJECT_DIRECTORY.join(".zeus.sock").exist?
|
67
|
+
end
|
68
|
+
|
69
|
+
def color_option
|
70
|
+
color_enabled ? "--color" : "--no-color"
|
71
|
+
end
|
72
|
+
|
73
|
+
def tempfile
|
74
|
+
@_tempfile ||= begin
|
75
|
+
TEMP_DIRECTORY.mkpath
|
76
|
+
TEMP_DIRECTORY.join("integration_spec.rb").tap do |file|
|
77
|
+
file.write(program)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def program
|
83
|
+
if zeus_running?
|
84
|
+
minimal_program
|
85
|
+
else
|
86
|
+
<<~PROGRAM
|
87
|
+
require "#{PROJECT_DIRECTORY.join("support/test_plan.rb")}"
|
88
|
+
|
89
|
+
test_plan = TestPlan.new(
|
90
|
+
using_outside_of_zeus: true,
|
91
|
+
color_enabled: #{color_enabled?}
|
92
|
+
)
|
93
|
+
test_plan.boot
|
94
|
+
#{test_plan_prelude}
|
95
|
+
test_plan.#{test_plan_command}
|
96
|
+
|
97
|
+
#{minimal_program}
|
98
|
+
PROGRAM
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def minimal_program
|
103
|
+
if preserve_as_whole_file?
|
104
|
+
code
|
105
|
+
else
|
106
|
+
<<~PROGRAM
|
107
|
+
RSpec.describe "test" do
|
108
|
+
it "passes" do
|
109
|
+
#{reindent(code, level: 2)}
|
110
|
+
end
|
111
|
+
end
|
112
|
+
PROGRAM
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def reindent(code, level: 0)
|
117
|
+
code.strip.split("\n").map { |line| (" " * level) + line }.join("\n")
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
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 RSpecActiveSupport < Base
|
5
|
+
protected
|
6
|
+
|
7
|
+
def test_plan_prelude
|
8
|
+
"test_plan.boot_active_support"
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_plan_command
|
12
|
+
"run_rspec_active_support_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.
|
20
|
-
|
21
|
-
|
22
|
-
|
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.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
data/spec/support/object_id.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
require "json"
|
2
|
+
require_relative "ruby_versions"
|
2
3
|
|
3
|
-
if !SuperDiff::Test.jruby? && SuperDiff::Test.version_match?(
|
4
|
-
require
|
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?(
|
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))[
|
18
|
+
address = JSON.parse(ObjectSpace.dump(object))["address"]
|
18
19
|
"0x%016x" % Integer(address, 16)
|
19
20
|
end
|
20
21
|
else
|
@@ -10,7 +10,7 @@ shared_examples_for "integration with ActiveRecord" do
|
|
10
10
|
state: "CA",
|
11
11
|
zip: "90382",
|
12
12
|
)
|
13
|
-
actual
|
13
|
+
actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
14
14
|
line_1: "456 Ponderosa Ct.",
|
15
15
|
city: "Oakland",
|
16
16
|
state: "CA",
|
@@ -25,27 +25,27 @@ shared_examples_for "integration with ActiveRecord" do
|
|
25
25
|
snippet: "expect(actual).to eq(expected)",
|
26
26
|
expectation: proc {
|
27
27
|
line do
|
28
|
-
plain
|
29
|
-
|
28
|
+
plain %|Expected |
|
29
|
+
actual %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234">|
|
30
30
|
end
|
31
31
|
|
32
32
|
line do
|
33
|
-
plain
|
34
|
-
|
33
|
+
plain %| to eq |
|
34
|
+
expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
|
35
35
|
end
|
36
36
|
},
|
37
37
|
diff: proc {
|
38
|
-
plain_line
|
39
|
-
plain_line
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
plain_line
|
45
|
-
plain_line
|
46
|
-
|
47
|
-
|
48
|
-
plain_line
|
38
|
+
plain_line %| #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
|
39
|
+
plain_line %| id: nil,|
|
40
|
+
expected_line %|- city: "Hill Valley",|
|
41
|
+
actual_line %|+ city: "Oakland",|
|
42
|
+
expected_line %|- line_1: "123 Main St.",|
|
43
|
+
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
44
|
+
plain_line %| line_2: "",|
|
45
|
+
plain_line %| state: "CA",|
|
46
|
+
expected_line %|- zip: "90382"|
|
47
|
+
actual_line %|+ zip: "91234"|
|
48
|
+
plain_line %| }>|
|
49
49
|
},
|
50
50
|
)
|
51
51
|
|
@@ -66,7 +66,7 @@ shared_examples_for "integration with ActiveRecord" do
|
|
66
66
|
state: "CA",
|
67
67
|
zip: "90382",
|
68
68
|
)
|
69
|
-
actual
|
69
|
+
actual = SuperDiff::Test::Models::ActiveRecord::Person.new(
|
70
70
|
name: "Elliot",
|
71
71
|
age: 31,
|
72
72
|
)
|
@@ -80,13 +80,13 @@ shared_examples_for "integration with ActiveRecord" do
|
|
80
80
|
newline_before_expectation: true,
|
81
81
|
expectation: proc {
|
82
82
|
line do
|
83
|
-
plain
|
84
|
-
|
83
|
+
plain %|Expected |
|
84
|
+
actual %|#<SuperDiff::Test::Models::ActiveRecord::Person id: nil, age: 31, name: "Elliot">|
|
85
85
|
end
|
86
86
|
|
87
87
|
line do
|
88
|
-
plain
|
89
|
-
|
88
|
+
plain %| to eq |
|
89
|
+
expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
|
90
90
|
end
|
91
91
|
},
|
92
92
|
)
|
@@ -108,7 +108,7 @@ shared_examples_for "integration with ActiveRecord" do
|
|
108
108
|
state: "CA",
|
109
109
|
zip: "90382"
|
110
110
|
)
|
111
|
-
actual
|
111
|
+
actual = nil
|
112
112
|
expect(actual).to eq(expected)
|
113
113
|
TEST
|
114
114
|
program = make_program(snippet, color_enabled: color_enabled)
|
@@ -119,13 +119,13 @@ shared_examples_for "integration with ActiveRecord" do
|
|
119
119
|
newline_before_expectation: true,
|
120
120
|
expectation: proc {
|
121
121
|
line do
|
122
|
-
plain
|
123
|
-
|
122
|
+
plain %|Expected |
|
123
|
+
actual %|nil|
|
124
124
|
end
|
125
125
|
|
126
126
|
line do
|
127
|
-
plain
|
128
|
-
|
127
|
+
plain %| to eq |
|
128
|
+
expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
|
129
129
|
end
|
130
130
|
},
|
131
131
|
)
|
@@ -150,7 +150,7 @@ shared_examples_for "integration with ActiveRecord" do
|
|
150
150
|
zip: "90382",
|
151
151
|
)
|
152
152
|
}
|
153
|
-
actual
|
153
|
+
actual = {
|
154
154
|
name: "Marty McFly",
|
155
155
|
shipping_address: SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
|
156
156
|
line_1: "456 Ponderosa Ct.",
|
@@ -168,30 +168,30 @@ shared_examples_for "integration with ActiveRecord" do
|
|
168
168
|
snippet: "expect(actual).to eq(expected)",
|
169
169
|
expectation: proc {
|
170
170
|
line do
|
171
|
-
plain
|
172
|
-
|
171
|
+
plain %|Expected |
|
172
|
+
actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234"> }|
|
173
173
|
end
|
174
174
|
|
175
175
|
line do
|
176
|
-
plain
|
177
|
-
|
176
|
+
plain %| to eq |
|
177
|
+
expected %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382"> }|
|
178
178
|
end
|
179
179
|
},
|
180
180
|
diff: proc {
|
181
|
-
plain_line
|
182
|
-
plain_line
|
183
|
-
plain_line
|
184
|
-
plain_line
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
plain_line
|
190
|
-
plain_line
|
191
|
-
|
192
|
-
|
193
|
-
plain_line
|
194
|
-
plain_line
|
181
|
+
plain_line %| {|
|
182
|
+
plain_line %| name: "Marty McFly",|
|
183
|
+
plain_line %| shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
|
184
|
+
plain_line %| id: nil,|
|
185
|
+
expected_line %|- city: "Hill Valley",|
|
186
|
+
actual_line %|+ city: "Oakland",|
|
187
|
+
expected_line %|- line_1: "123 Main St.",|
|
188
|
+
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
189
|
+
plain_line %| line_2: "",|
|
190
|
+
plain_line %| state: "CA",|
|
191
|
+
expected_line %|- zip: "90382"|
|
192
|
+
actual_line %|+ zip: "91234"|
|
193
|
+
plain_line %| }>|
|
194
|
+
plain_line %| }|
|
195
195
|
},
|
196
196
|
)
|
197
197
|
|
@@ -215,7 +215,7 @@ shared_examples_for "integration with ActiveRecord" do
|
|
215
215
|
zip: "90382",
|
216
216
|
)
|
217
217
|
}
|
218
|
-
actual
|
218
|
+
actual = {
|
219
219
|
name: "Marty McFly",
|
220
220
|
shipping_address: SuperDiff::Test::Models::ActiveRecord::Person.new(
|
221
221
|
name: "Elliot",
|
@@ -231,32 +231,32 @@ shared_examples_for "integration with ActiveRecord" do
|
|
231
231
|
snippet: "expect(actual).to eq(expected)",
|
232
232
|
expectation: proc {
|
233
233
|
line do
|
234
|
-
plain
|
235
|
-
|
234
|
+
plain %|Expected |
|
235
|
+
actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::Person id: nil, age: 31, name: "Elliot"> }|
|
236
236
|
end
|
237
237
|
|
238
238
|
line do
|
239
|
-
plain
|
240
|
-
|
239
|
+
plain %| to eq |
|
240
|
+
expected %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382"> }|
|
241
241
|
end
|
242
242
|
},
|
243
243
|
diff: proc {
|
244
|
-
plain_line
|
245
|
-
plain_line
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
plain_line
|
244
|
+
plain_line %| {|
|
245
|
+
plain_line %| name: "Marty McFly",|
|
246
|
+
expected_line %|- shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
|
247
|
+
expected_line %|- id: nil,|
|
248
|
+
expected_line %|- city: "Hill Valley",|
|
249
|
+
expected_line %|- line_1: "123 Main St.",|
|
250
|
+
expected_line %|- line_2: "",|
|
251
|
+
expected_line %|- state: "CA",|
|
252
|
+
expected_line %|- zip: "90382"|
|
253
|
+
expected_line %|- }>|
|
254
|
+
actual_line %|+ shipping_address: #<SuperDiff::Test::Models::ActiveRecord::Person {|
|
255
|
+
actual_line %|+ id: nil,|
|
256
|
+
actual_line %|+ age: 31,|
|
257
|
+
actual_line %|+ name: "Elliot"|
|
258
|
+
actual_line %|+ }>|
|
259
|
+
plain_line %| }|
|
260
260
|
},
|
261
261
|
)
|
262
262
|
|
@@ -287,7 +287,7 @@ shared_examples_for "integration with ActiveRecord" do
|
|
287
287
|
)
|
288
288
|
]
|
289
289
|
expected = [shipping_addresses.first]
|
290
|
-
actual
|
290
|
+
actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.all
|
291
291
|
expect(actual).to eq(expected)
|
292
292
|
TEST
|
293
293
|
program = make_program(snippet, color_enabled: color_enabled)
|
@@ -297,34 +297,34 @@ shared_examples_for "integration with ActiveRecord" do
|
|
297
297
|
snippet: "expect(actual).to eq(expected)",
|
298
298
|
expectation: proc {
|
299
299
|
line do
|
300
|
-
plain
|
301
|
-
|
300
|
+
plain %|Expected |
|
301
|
+
actual %|#<ActiveRecord::Relation [#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 1, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">, #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 2, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234">]>|
|
302
302
|
end
|
303
303
|
|
304
304
|
line do
|
305
|
-
plain
|
306
|
-
|
305
|
+
plain %| to eq |
|
306
|
+
expected %|[#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 1, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">]|
|
307
307
|
end
|
308
308
|
},
|
309
309
|
diff: proc {
|
310
|
-
plain_line
|
311
|
-
plain_line
|
312
|
-
plain_line
|
313
|
-
plain_line
|
314
|
-
plain_line
|
315
|
-
plain_line
|
316
|
-
plain_line
|
317
|
-
plain_line
|
318
|
-
plain_line
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
plain_line
|
310
|
+
plain_line %| #<ActiveRecord::Relation [|
|
311
|
+
plain_line %| #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
|
312
|
+
plain_line %| id: 1,|
|
313
|
+
plain_line %| city: "Hill Valley",|
|
314
|
+
plain_line %| line_1: "123 Main St.",|
|
315
|
+
plain_line %| line_2: "",|
|
316
|
+
plain_line %| state: "CA",|
|
317
|
+
plain_line %| zip: "90382"|
|
318
|
+
plain_line %| }>,|
|
319
|
+
actual_line %|+ #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
|
320
|
+
actual_line %|+ id: 2,|
|
321
|
+
actual_line %|+ city: "Oakland",|
|
322
|
+
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
323
|
+
actual_line %|+ line_2: "",|
|
324
|
+
actual_line %|+ state: "CA",|
|
325
|
+
actual_line %|+ zip: "91234"|
|
326
|
+
actual_line %|+ }>|
|
327
|
+
plain_line %| ]>|
|
328
328
|
},
|
329
329
|
)
|
330
330
|
|
@@ -354,7 +354,7 @@ shared_examples_for "integration with ActiveRecord" do
|
|
354
354
|
)
|
355
355
|
]
|
356
356
|
|
357
|
-
actual
|
357
|
+
actual = [
|
358
358
|
SuperDiff::Test::Models::ActiveRecord::Query.new(
|
359
359
|
results: SuperDiff::Test::Models::ActiveRecord::Person.all
|
360
360
|
)
|
@@ -371,30 +371,30 @@ shared_examples_for "integration with ActiveRecord" do
|
|
371
371
|
newline_before_expectation: true,
|
372
372
|
expectation: proc {
|
373
373
|
line do
|
374
|
-
plain
|
375
|
-
|
374
|
+
plain %|Expected |
|
375
|
+
actual %|[#<SuperDiff::Test::Models::ActiveRecord::Query @results=#<ActiveRecord::Relation [#<SuperDiff::Test::Models::ActiveRecord::Person id: 1, name: "Murphy", age: 20>]>>]|
|
376
376
|
end
|
377
377
|
|
378
378
|
line do
|
379
|
-
plain
|
380
|
-
|
379
|
+
plain %|to match |
|
380
|
+
expected %|[#<an object having attributes (results: [#<an object having attributes (name: "John", age: 19)>])>]|
|
381
381
|
end
|
382
382
|
},
|
383
383
|
diff: proc {
|
384
|
-
plain_line
|
385
|
-
plain_line
|
386
|
-
plain_line
|
387
|
-
plain_line
|
388
|
-
plain_line
|
389
|
-
#
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
plain_line
|
395
|
-
plain_line
|
396
|
-
plain_line
|
397
|
-
plain_line
|
384
|
+
plain_line %| [|
|
385
|
+
plain_line %| #<SuperDiff::Test::Models::ActiveRecord::Query {|
|
386
|
+
plain_line %| @results=#<ActiveRecord::Relation [|
|
387
|
+
plain_line %| #<SuperDiff::Test::Models::ActiveRecord::Person {|
|
388
|
+
plain_line %| id: 1,|
|
389
|
+
# expected_line %|- age: 19,| # TODO
|
390
|
+
expected_line %|- age: 19|
|
391
|
+
actual_line %|+ age: 20,|
|
392
|
+
expected_line %|- name: "John"|
|
393
|
+
actual_line %|+ name: "Murphy"|
|
394
|
+
plain_line %| }>|
|
395
|
+
plain_line %| ]>|
|
396
|
+
plain_line %| }>|
|
397
|
+
plain_line %| ]|
|
398
398
|
},
|
399
399
|
)
|
400
400
|
|