super_diff 0.9.0 → 0.10.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 +65 -26
- data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/differs.rb +1 -1
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +5 -13
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +1 -3
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/object_inspection.rb +1 -1
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_record/operation_trees.rb +1 -1
- data/lib/super_diff/active_record.rb +7 -15
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/differs.rb +1 -1
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +3 -9
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/object_inspection.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_support/operation_trees.rb +1 -1
- data/lib/super_diff/active_support.rb +6 -11
- data/lib/super_diff/colorized_document_extensions.rb +2 -4
- data/lib/super_diff/configuration.rb +14 -8
- data/lib/super_diff/csi/color.rb +4 -4
- data/lib/super_diff/csi/colorized_document.rb +12 -16
- data/lib/super_diff/csi/document.rb +8 -19
- data/lib/super_diff/csi/eight_bit_color.rb +19 -19
- data/lib/super_diff/csi/four_bit_color.rb +82 -31
- data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
- data/lib/super_diff/csi/uncolorized_document.rb +2 -6
- data/lib/super_diff/csi.rb +10 -14
- data/lib/super_diff/diff_formatters/collection.rb +35 -41
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/defaults.rb +1 -1
- data/lib/super_diff/differs/main.rb +2 -13
- data/lib/super_diff/equality_matchers/array.rb +10 -12
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +2 -4
- data/lib/super_diff/equality_matchers/defaults.rb +1 -1
- data/lib/super_diff/equality_matchers/hash.rb +10 -12
- data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
- data/lib/super_diff/equality_matchers/primitive.rb +10 -12
- data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
- data/lib/super_diff/equality_matchers.rb +1 -1
- data/lib/super_diff/errors.rb +3 -3
- data/lib/super_diff/gem_version.rb +3 -3
- data/lib/super_diff/helpers.rb +10 -10
- data/lib/super_diff/implementation_checks.rb +2 -2
- data/lib/super_diff/line.rb +3 -3
- data/lib/super_diff/object_inspection/inspection_tree.rb +46 -60
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +2 -6
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +3 -9
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +5 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +4 -12
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +6 -23
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +8 -20
- data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
- data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
- data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
- data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
- data/lib/super_diff/object_inspection/nodes.rb +7 -7
- data/lib/super_diff/object_inspection.rb +3 -3
- data/lib/super_diff/operation_tree_builders/array.rb +12 -11
- data/lib/super_diff/operation_tree_builders/base.rb +17 -15
- data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
- data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
- data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
- data/lib/super_diff/operation_tree_builders/main.rb +4 -11
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
- data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
- data/lib/super_diff/operation_tree_builders.rb +1 -1
- data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
- data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
- data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
- data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
- data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
- data/lib/super_diff/operation_tree_flatteners.rb +3 -3
- data/lib/super_diff/operation_trees/base.rb +3 -5
- data/lib/super_diff/operation_trees/default_object.rb +1 -3
- data/lib/super_diff/operations/binary_operation.rb +2 -2
- data/lib/super_diff/operations/unary_operation.rb +1 -1
- data/lib/super_diff/rails.rb +2 -1
- data/lib/super_diff/recursion_guard.rb +5 -4
- data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
- data/lib/super_diff/rspec/differ.rb +6 -13
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
- data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
- data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
- data/lib/super_diff/rspec/differs.rb +3 -3
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -5
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
- data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
- data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
- data/lib/super_diff/rspec/monkey_patches.rb +122 -116
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +11 -16
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +2 -1
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/rspec/object_inspection.rb +1 -1
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
- data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
- data/lib/super_diff/rspec.rb +11 -13
- data/lib/super_diff/tiered_lines_elider.rb +87 -115
- data/lib/super_diff/tiered_lines_formatter.rb +5 -9
- data/lib/super_diff/version.rb +1 -1
- data/lib/super_diff.rb +4 -9
- data/spec/examples.txt +493 -485
- data/spec/integration/rails/active_record_spec.rb +3 -1
- data/spec/integration/rails/engines_spec.rb +20 -0
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
- data/spec/integration/rspec/be_matcher_spec.rb +360 -320
- data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +242 -239
- data/spec/integration/rspec/eq_matcher_spec.rb +595 -557
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +294 -286
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
- data/spec/integration/rspec/include_matcher_spec.rb +317 -215
- data/spec/integration/rspec/match_array_matcher_spec.rb +276 -273
- data/spec/integration/rspec/match_matcher_spec.rb +847 -834
- data/spec/integration/rspec/raise_error_matcher_spec.rb +468 -453
- data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
- data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
- data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
- data/spec/spec_helper.rb +17 -20
- data/spec/support/command_runner.rb +34 -57
- data/spec/support/integration/helpers.rb +35 -28
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
- data/spec/support/integration/test_programs/base.rb +12 -17
- data/spec/support/integration/test_programs/plain.rb +6 -0
- data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
- data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +30 -0
- data/spec/support/models/active_record/person.rb +6 -4
- data/spec/support/models/active_record/shipping_address.rb +9 -10
- data/spec/support/models/customer.rb +2 -4
- data/spec/support/models/player.rb +3 -6
- data/spec/support/models/shipping_address.rb +4 -13
- data/spec/support/shared_examples/active_record.rb +232 -214
- data/spec/support/shared_examples/active_support.rb +53 -51
- data/spec/support/shared_examples/elided_diffs.rb +405 -381
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +424 -388
- data/spec/support/shared_examples/key.rb +123 -0
- data/spec/support/unit/helpers.rb +1 -3
- data/spec/support/unit/matchers/match_output.rb +12 -13
- data/spec/unit/active_record/object_inspection_spec.rb +222 -206
- data/spec/unit/equality_matchers/main_spec.rb +1049 -984
- data/spec/unit/helpers_spec.rb +14 -21
- data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
- data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
- data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
- data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
- data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
- data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
- data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
- data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
- data/spec/unit/rspec/matchers/include_spec.rb +2 -2
- data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
- data/spec/unit/rspec/matchers/raise_error_spec.rb +5 -5
- data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
- data/spec/unit/rspec/object_inspection_spec.rb +349 -324
- data/spec/unit/super_diff_spec.rb +1542 -1449
- data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
- data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
- data/super_diff.gemspec +13 -12
- metadata +73 -73
- data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -28,16 +28,13 @@ class CommandRunner
|
|
28
28
|
Command #{command.inspect} failed, exiting with status #{exit_status}.
|
29
29
|
MESSAGE
|
30
30
|
|
31
|
-
if output
|
32
|
-
message << <<-MESSAGE
|
31
|
+
message << <<-MESSAGE if output
|
33
32
|
Output:
|
34
33
|
#{
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
34
|
+
SuperDiff::Test::OutputHelpers.divider("START") + output +
|
35
|
+
SuperDiff::Test::OutputHelpers.divider("END")
|
36
|
+
}
|
39
37
|
MESSAGE
|
40
|
-
end
|
41
38
|
|
42
39
|
message
|
43
40
|
end
|
@@ -66,16 +63,13 @@ Output:
|
|
66
63
|
Command #{formatted_command.inspect} timed out after #{timeout} seconds.
|
67
64
|
MESSAGE
|
68
65
|
|
69
|
-
if output
|
70
|
-
message << <<-MESSAGE
|
66
|
+
message << <<-MESSAGE if output
|
71
67
|
Output:
|
72
68
|
#{
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
}
|
69
|
+
SuperDiff::Test::OutputHelpers.divider("START") + output +
|
70
|
+
SuperDiff::Test::OutputHelpers.divider("END")
|
71
|
+
}
|
77
72
|
MESSAGE
|
78
|
-
end
|
79
73
|
|
80
74
|
message
|
81
75
|
end
|
@@ -96,26 +90,20 @@ Output:
|
|
96
90
|
end
|
97
91
|
|
98
92
|
attr_reader :status, :options, :env
|
99
|
-
attr_accessor :run_quickly, :run_successfully, :retries,
|
100
|
-
:timeout
|
93
|
+
attr_accessor :run_quickly, :run_successfully, :retries, :timeout
|
101
94
|
|
102
95
|
def initialize(*args)
|
103
96
|
@reader, @writer = IO.pipe
|
104
97
|
options = (args.last.is_a?(Hash) ? args.pop : {})
|
105
98
|
@args = args
|
106
|
-
@options = options.merge(
|
107
|
-
err: [:child, :out],
|
108
|
-
out: @writer,
|
109
|
-
)
|
99
|
+
@options = options.merge(err: %i[child out], out: @writer)
|
110
100
|
@env = extract_env_from(@options)
|
111
101
|
|
112
102
|
@process = ChildProcess.build(*command)
|
113
|
-
@env.each
|
114
|
-
@process.environment[key] = value
|
115
|
-
end
|
103
|
+
@env.each { |key, value| @process.environment[key] = value }
|
116
104
|
@process.io.stdout = @process.io.stderr = @writer
|
117
105
|
|
118
|
-
@wrapper = ->
|
106
|
+
@wrapper = ->(block) { block.call }
|
119
107
|
self.directory = Dir.pwd
|
120
108
|
@run_quickly = false
|
121
109
|
@run_successfully = false
|
@@ -137,43 +125,36 @@ Output:
|
|
137
125
|
end
|
138
126
|
|
139
127
|
def formatted_command
|
140
|
-
[formatted_env, Shellwords.join(command)].
|
141
|
-
reject(&:empty?).
|
142
|
-
join(" ")
|
128
|
+
[formatted_env, Shellwords.join(command)].reject(&:empty?).join(" ")
|
143
129
|
end
|
144
130
|
|
145
131
|
def run
|
146
132
|
possibly_running_quickly do
|
147
133
|
run_with_debugging
|
148
134
|
|
149
|
-
if run_successfully && !success?
|
150
|
-
fail!
|
151
|
-
end
|
135
|
+
fail! if run_successfully && !success?
|
152
136
|
end
|
153
137
|
|
154
138
|
self
|
155
139
|
end
|
156
140
|
|
157
141
|
def stop
|
158
|
-
if !writer.closed?
|
159
|
-
writer.close
|
160
|
-
end
|
142
|
+
writer.close if !writer.closed?
|
161
143
|
end
|
162
144
|
|
163
145
|
def output
|
164
|
-
@_output ||=
|
165
|
-
|
166
|
-
|
167
|
-
|
146
|
+
@_output ||=
|
147
|
+
begin
|
148
|
+
stop
|
149
|
+
reader.read
|
150
|
+
end
|
168
151
|
end
|
169
152
|
|
170
153
|
def elided_output
|
171
154
|
lines = output.split(/\n/)
|
172
155
|
new_lines = lines[0..4]
|
173
156
|
|
174
|
-
if lines.size > 10
|
175
|
-
new_lines << "(...#{lines.size - 10} more lines...)"
|
176
|
-
end
|
157
|
+
new_lines << "(...#{lines.size - 10} more lines...)" if lines.size > 10
|
177
158
|
|
178
159
|
new_lines << lines[-5..-1]
|
179
160
|
new_lines.join("\n")
|
@@ -189,10 +170,10 @@ Output:
|
|
189
170
|
|
190
171
|
def fail!
|
191
172
|
raise CommandFailedError.create(
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
173
|
+
command: formatted_command,
|
174
|
+
exit_status: exit_status,
|
175
|
+
output: output
|
176
|
+
)
|
196
177
|
end
|
197
178
|
|
198
179
|
def has_output?(expected_output)
|
@@ -210,9 +191,9 @@ Output:
|
|
210
191
|
private
|
211
192
|
|
212
193
|
def extract_env_from(options)
|
213
|
-
options
|
214
|
-
|
215
|
-
|
194
|
+
options
|
195
|
+
.delete(:env) { {} }
|
196
|
+
.reduce({}) { |hash, (key, value)| hash.merge(key.to_s => value) }
|
216
197
|
end
|
217
198
|
|
218
199
|
def command
|
@@ -239,9 +220,7 @@ Output:
|
|
239
220
|
run_with_wrapper
|
240
221
|
|
241
222
|
debug do
|
242
|
-
"\n" +
|
243
|
-
SuperDiff::Test::OutputHelpers.divider("START") +
|
244
|
-
output +
|
223
|
+
"\n" + SuperDiff::Test::OutputHelpers.divider("START") + output +
|
245
224
|
SuperDiff::Test::OutputHelpers.divider("END")
|
246
225
|
end
|
247
226
|
end
|
@@ -254,10 +233,10 @@ Output:
|
|
254
233
|
stop
|
255
234
|
|
256
235
|
raise CommandTimedOutError.create(
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
236
|
+
command: formatted_command,
|
237
|
+
timeout: timeout,
|
238
|
+
output: output
|
239
|
+
)
|
261
240
|
end
|
262
241
|
else
|
263
242
|
yield
|
@@ -269,8 +248,6 @@ Output:
|
|
269
248
|
end
|
270
249
|
|
271
250
|
def debug
|
272
|
-
if debugging_enabled?
|
273
|
-
puts yield
|
274
|
-
end
|
251
|
+
puts yield if debugging_enabled?
|
275
252
|
end
|
276
253
|
end
|
@@ -3,9 +3,7 @@ module SuperDiff
|
|
3
3
|
PROJECT_DIRECTORY = Pathname.new("../../..").expand_path(__dir__)
|
4
4
|
|
5
5
|
def as_both_colored_and_uncolored
|
6
|
-
[true, false].each
|
7
|
-
yield color_enabled
|
8
|
-
end
|
6
|
+
[true, false].each { |color_enabled| yield color_enabled }
|
9
7
|
end
|
10
8
|
|
11
9
|
def make_plain_test_program(
|
@@ -18,7 +16,7 @@ module SuperDiff
|
|
18
16
|
test,
|
19
17
|
color_enabled: color_enabled,
|
20
18
|
configuration: configuration,
|
21
|
-
preserve_as_whole_file: preserve_as_whole_file
|
19
|
+
preserve_as_whole_file: preserve_as_whole_file
|
22
20
|
)
|
23
21
|
end
|
24
22
|
|
@@ -34,10 +32,23 @@ module SuperDiff
|
|
34
32
|
TestPrograms::RSpecRails.new(test, color_enabled: color_enabled)
|
35
33
|
end
|
36
34
|
|
35
|
+
def make_rspec_rails_engine_program(
|
36
|
+
test,
|
37
|
+
color_enabled:,
|
38
|
+
combustion_initialize:
|
39
|
+
)
|
40
|
+
TestPrograms::RspecRailsEngine.new(
|
41
|
+
test,
|
42
|
+
color_enabled: color_enabled,
|
43
|
+
combustion_initialize: combustion_initialize
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
37
47
|
def build_expected_output(
|
38
48
|
color_enabled:,
|
39
49
|
snippet:,
|
40
50
|
expectation:,
|
51
|
+
key_enabled: true,
|
41
52
|
newline_before_expectation: false,
|
42
53
|
indentation: 7,
|
43
54
|
diff: nil
|
@@ -52,9 +63,7 @@ module SuperDiff
|
|
52
63
|
plain snippet
|
53
64
|
end
|
54
65
|
|
55
|
-
if diff || newline_before_expectation
|
56
|
-
newline
|
57
|
-
end
|
66
|
+
newline if diff || newline_before_expectation
|
58
67
|
|
59
68
|
indent by: indentation do
|
60
69
|
evaluate_block(&expectation)
|
@@ -64,32 +73,30 @@ module SuperDiff
|
|
64
73
|
|
65
74
|
white_line "Diff:"
|
66
75
|
|
67
|
-
|
76
|
+
if key_enabled
|
77
|
+
newline
|
68
78
|
|
69
|
-
|
70
|
-
blue "┌ (Key) ──────────────────────────┐"
|
71
|
-
end
|
79
|
+
line { blue "┌ (Key) ──────────────────────────┐" }
|
72
80
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
81
|
+
line do
|
82
|
+
blue "│ "
|
83
|
+
magenta "‹-› in expected, not in actual"
|
84
|
+
blue " │"
|
85
|
+
end
|
78
86
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
87
|
+
line do
|
88
|
+
blue "│ "
|
89
|
+
yellow "‹+› in actual, not in expected"
|
90
|
+
blue " │"
|
91
|
+
end
|
84
92
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
93
|
+
line do
|
94
|
+
blue "│ "
|
95
|
+
text "‹ › in both expected and actual"
|
96
|
+
blue " │"
|
97
|
+
end
|
90
98
|
|
91
|
-
|
92
|
-
blue "└─────────────────────────────────┘"
|
99
|
+
line { blue "└─────────────────────────────────┘" }
|
93
100
|
end
|
94
101
|
|
95
102
|
newline
|
@@ -32,31 +32,35 @@ module SuperDiff
|
|
32
32
|
"Expected output of test " +
|
33
33
|
(expect_output_to_contain_color? ? "to " : "not to ") +
|
34
34
|
"contain color, but " +
|
35
|
-
(expect_output_to_contain_color? ? "it did not" : "it did") +
|
36
|
-
"."
|
35
|
+
(expect_output_to_contain_color? ? "it did not" : "it did") + "."
|
37
36
|
else
|
38
37
|
message =
|
39
38
|
"Expected test to produce #{expect_output_to_contain_color? ? "colored" : "uncolored"} output, but it did not.\n\n" +
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
)
|
39
|
+
"Expected output to contain:\n\n" +
|
40
|
+
SuperDiff::Test::OutputHelpers.bookended(expected_output) + "\n" +
|
41
|
+
"Actual output:\n\n" +
|
42
|
+
SuperDiff::Test::OutputHelpers.bookended(actual_output)
|
43
|
+
|
44
|
+
if %w[1 true].include?(ENV["SHOW_DIFF"])
|
45
|
+
::RSpec::Matchers::ExpectedsForMultipleDiffs.from(
|
46
|
+
expected_output
|
47
|
+
).message_with_diff(
|
48
|
+
message,
|
49
|
+
::RSpec::Expectations.differ,
|
50
|
+
actual_output
|
51
|
+
)
|
54
52
|
else
|
55
53
|
message
|
56
54
|
end
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
58
|
+
def failure_message_when_negated
|
59
|
+
"Expected output of test not to produce output, but it did.\n\n" +
|
60
|
+
"Actual output:\n\n" +
|
61
|
+
SuperDiff::Test::OutputHelpers.bookended(actual_output)
|
62
|
+
end
|
63
|
+
|
60
64
|
private
|
61
65
|
|
62
66
|
attr_reader :expected_output, :program, :output_processor
|
@@ -75,15 +79,16 @@ module SuperDiff
|
|
75
79
|
end
|
76
80
|
|
77
81
|
def actual_output
|
78
|
-
@_actual_output ||=
|
79
|
-
|
82
|
+
@_actual_output ||=
|
83
|
+
begin
|
84
|
+
output = program.run.output.strip
|
80
85
|
|
81
|
-
|
82
|
-
|
83
|
-
|
86
|
+
if output_processor
|
87
|
+
output.gsub!(output_processor[0], output_processor[1])
|
88
|
+
end
|
84
89
|
|
85
|
-
|
86
|
-
|
90
|
+
output
|
91
|
+
end
|
87
92
|
end
|
88
93
|
|
89
94
|
def presence_of_color_matches?
|
@@ -57,15 +57,15 @@ module SuperDiff
|
|
57
57
|
else
|
58
58
|
CommandRunner.run(
|
59
59
|
Shellwords.join(command),
|
60
|
-
env: {
|
60
|
+
env: {
|
61
|
+
"DISABLE_PRY" => "true"
|
62
|
+
}
|
61
63
|
)
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
67
|
def command
|
66
|
-
if ENV["RAILS_ENV"]
|
67
|
-
raise "RAILS_ENV is being set somehow?!"
|
68
|
-
end
|
68
|
+
raise "RAILS_ENV is being set somehow?!" if ENV["RAILS_ENV"]
|
69
69
|
|
70
70
|
if zeus_running?
|
71
71
|
[
|
@@ -75,15 +75,10 @@ module SuperDiff
|
|
75
75
|
"--no-pry",
|
76
76
|
tempfile.to_s,
|
77
77
|
"--configuration",
|
78
|
-
JSON.generate(configuration)
|
78
|
+
JSON.generate(configuration)
|
79
79
|
]
|
80
80
|
else
|
81
|
-
[
|
82
|
-
"rspec",
|
83
|
-
"--options",
|
84
|
-
"/tmp/dummy-rspec-config",
|
85
|
-
tempfile.to_s,
|
86
|
-
]
|
81
|
+
["rspec", "--options", "/tmp/dummy-rspec-config", tempfile.to_s]
|
87
82
|
end
|
88
83
|
end
|
89
84
|
|
@@ -96,12 +91,13 @@ module SuperDiff
|
|
96
91
|
end
|
97
92
|
|
98
93
|
def tempfile
|
99
|
-
@_tempfile ||=
|
100
|
-
|
101
|
-
|
102
|
-
|
94
|
+
@_tempfile ||=
|
95
|
+
begin
|
96
|
+
TEMP_DIRECTORY.mkpath
|
97
|
+
TEMP_DIRECTORY
|
98
|
+
.join("integration_spec.rb")
|
99
|
+
.tap { |file| file.write(program) }
|
103
100
|
end
|
104
|
-
end
|
105
101
|
end
|
106
102
|
|
107
103
|
def program
|
@@ -116,7 +112,6 @@ module SuperDiff
|
|
116
112
|
color_enabled: #{color_enabled?.inspect},
|
117
113
|
configuration: #{configuration.inspect}
|
118
114
|
)
|
119
|
-
test_plan.boot
|
120
115
|
#{test_plan_prelude}
|
121
116
|
test_plan.#{test_plan_command}
|
122
117
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module IntegrationTests
|
3
|
+
module TestPrograms
|
4
|
+
class RspecRailsEngine < Base
|
5
|
+
def initialize(*args, combustion_initialize:, **options)
|
6
|
+
super(*args, **options)
|
7
|
+
@combustion_initialize = combustion_initialize
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def test_plan_prelude
|
13
|
+
<<~PRELUDE.strip
|
14
|
+
test_plan.boot_rails_engine(
|
15
|
+
combustion_initialize: #{combustion_initialize.inspect}
|
16
|
+
)
|
17
|
+
PRELUDE
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_plan_command
|
21
|
+
"run_rspec_rails_test"
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :combustion_initialize
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -11,9 +11,11 @@ end
|
|
11
11
|
|
12
12
|
RSpec.configure do |config|
|
13
13
|
config.before do
|
14
|
-
ActiveRecord::Base
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
ActiveRecord::Base
|
15
|
+
.connection
|
16
|
+
.create_table(:people, force: true) do |t|
|
17
|
+
t.string :name, null: false
|
18
|
+
t.integer :age, null: false
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
@@ -11,15 +11,14 @@ end
|
|
11
11
|
|
12
12
|
RSpec.configure do |config|
|
13
13
|
config.before do
|
14
|
-
ActiveRecord::Base
|
15
|
-
|
16
|
-
force: true
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
14
|
+
ActiveRecord::Base
|
15
|
+
.connection
|
16
|
+
.create_table(:shipping_addresses, force: true) do |t|
|
17
|
+
t.string :line_1, null: false, default: ""
|
18
|
+
t.string :line_2, null: false, default: ""
|
19
|
+
t.string :city, null: false, default: ""
|
20
|
+
t.string :state, null: false, default: ""
|
21
|
+
t.string :zip, null: false, default: ""
|
22
|
+
end
|
24
23
|
end
|
25
24
|
end
|
@@ -10,10 +10,8 @@ module SuperDiff
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def ==(other)
|
13
|
-
other.is_a?(self.class) &&
|
14
|
-
other.
|
15
|
-
other.shipping_address == shipping_address &&
|
16
|
-
other.phone == phone
|
13
|
+
other.is_a?(self.class) && other.name == name &&
|
14
|
+
other.shipping_address == shipping_address && other.phone == phone
|
17
15
|
end
|
18
16
|
|
19
17
|
def attributes_for_super_diff
|
@@ -20,12 +20,9 @@ module SuperDiff
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def ==(other)
|
23
|
-
other.is_a?(self.class) &&
|
24
|
-
other.
|
25
|
-
other.
|
26
|
-
other.inventory == inventory &&
|
27
|
-
other.shields == shields &&
|
28
|
-
other.health == health &&
|
23
|
+
other.is_a?(self.class) && other.handle == handle &&
|
24
|
+
other.character == character && other.inventory == inventory &&
|
25
|
+
other.shields == shields && other.health == health &&
|
29
26
|
other.ultimate == ultimate
|
30
27
|
end
|
31
28
|
end
|
@@ -12,22 +12,13 @@ module SuperDiff
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def ==(other)
|
15
|
-
other.is_a?(self.class) &&
|
16
|
-
other.
|
17
|
-
other.
|
18
|
-
other.city == city &&
|
19
|
-
other.state == state &&
|
20
|
-
other.zip == zip
|
15
|
+
other.is_a?(self.class) && other.line_1 == line_1 &&
|
16
|
+
other.line_2 == line_2 && other.city == city &&
|
17
|
+
other.state == state && other.zip == zip
|
21
18
|
end
|
22
19
|
|
23
20
|
def attributes_for_super_diff
|
24
|
-
{
|
25
|
-
line_1: line_1,
|
26
|
-
line_2: line_2,
|
27
|
-
city: city,
|
28
|
-
state: state,
|
29
|
-
zip: zip
|
30
|
-
}
|
21
|
+
{ line_1: line_1, line_2: line_2, city: city, state: state, zip: zip }
|
31
22
|
end
|
32
23
|
end
|
33
24
|
end
|