super_diff 0.5.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +46 -20
- data/lib/super_diff.rb +46 -7
- data/lib/super_diff/active_record.rb +7 -7
- data/lib/super_diff/active_record/differs/active_record_relation.rb +3 -13
- data/lib/super_diff/active_record/object_inspection.rb +2 -6
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +16 -0
- data/lib/super_diff/active_record/object_inspection/{inspectors → inspection_tree_builders}/active_record_model.rb +19 -20
- data/lib/super_diff/active_record/object_inspection/{inspectors → inspection_tree_builders}/active_record_relation.rb +9 -8
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +10 -0
- data/lib/super_diff/active_record/operation_tree_flatteners/active_record_relation.rb +17 -0
- data/lib/super_diff/active_record/operation_trees/active_record_relation.rb +8 -7
- data/lib/super_diff/active_support.rb +8 -8
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +3 -13
- data/lib/super_diff/active_support/object_inspection.rb +2 -6
- data/lib/super_diff/active_support/object_inspection/{inspectors.rb → inspection_tree_builders.rb} +2 -2
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +37 -0
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +17 -0
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +10 -0
- data/lib/super_diff/active_support/operation_tree_flatteners/hash_with_indifferent_access.rb +17 -0
- data/lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb +4 -7
- data/lib/super_diff/colorized_document_extensions.rb +9 -6
- data/lib/super_diff/configuration.rb +102 -19
- data/lib/super_diff/csi.rb +1 -1
- data/lib/super_diff/csi/four_bit_color.rb +0 -2
- data/lib/super_diff/diff_formatters/collection.rb +2 -2
- data/lib/super_diff/diff_formatters/multiline_string.rb +4 -4
- data/lib/super_diff/differs/array.rb +1 -1
- data/lib/super_diff/differs/base.rb +3 -21
- data/lib/super_diff/differs/custom_object.rb +1 -1
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/hash.rb +1 -1
- data/lib/super_diff/differs/main.rb +1 -7
- data/lib/super_diff/differs/multiline_string.rb +1 -1
- data/lib/super_diff/differs/time_like.rb +1 -1
- data/lib/super_diff/equality_matchers/array.rb +4 -4
- data/lib/super_diff/equality_matchers/default.rb +4 -4
- data/lib/super_diff/equality_matchers/hash.rb +4 -4
- data/lib/super_diff/equality_matchers/multiline_string.rb +4 -4
- data/lib/super_diff/equality_matchers/primitive.rb +6 -9
- data/lib/super_diff/equality_matchers/singleline_string.rb +4 -4
- data/lib/super_diff/gem_version.rb +45 -0
- data/lib/super_diff/helpers.rb +52 -2
- data/lib/super_diff/line.rb +83 -0
- data/lib/super_diff/object_inspection.rb +12 -9
- data/lib/super_diff/object_inspection/inspection_tree.rb +183 -81
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +44 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +38 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/base.rb +27 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +37 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +63 -0
- data/lib/super_diff/object_inspection/{inspectors → inspection_tree_builders}/defaults.rb +1 -2
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +46 -0
- data/lib/super_diff/object_inspection/{inspectors → inspection_tree_builders}/main.rb +5 -10
- data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +21 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +64 -0
- data/lib/super_diff/object_inspection/nodes.rb +33 -32
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +97 -0
- data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +27 -0
- data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +27 -0
- data/lib/super_diff/object_inspection/nodes/as_single_line.rb +33 -0
- data/lib/super_diff/object_inspection/nodes/base.rb +55 -20
- data/lib/super_diff/object_inspection/nodes/inspection.rb +47 -7
- data/lib/super_diff/object_inspection/nodes/nesting.rb +16 -5
- data/lib/super_diff/object_inspection/nodes/only_when.rb +54 -0
- data/lib/super_diff/object_inspection/nodes/text.rb +16 -2
- data/lib/super_diff/object_inspection/nodes/when_empty.rb +21 -6
- data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +20 -5
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +27 -0
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +27 -0
- data/lib/super_diff/object_inspection/prefix_for_next_node.rb +6 -0
- data/lib/super_diff/object_inspection/prelude_for_next_node.rb +6 -0
- data/lib/super_diff/operation_tree_builders/array.rb +7 -10
- data/lib/super_diff/operation_tree_builders/base.rb +6 -6
- data/lib/super_diff/operation_tree_builders/custom_object.rb +5 -2
- data/lib/super_diff/operation_tree_builders/default_object.rb +1 -1
- data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/operation_tree_builders/hash.rb +1 -8
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +2 -6
- data/lib/super_diff/operation_tree_builders/time_like.rb +2 -2
- data/lib/super_diff/operation_tree_flatteners.rb +20 -0
- data/lib/super_diff/operation_tree_flatteners/array.rb +15 -0
- data/lib/super_diff/operation_tree_flatteners/base.rb +54 -0
- data/lib/super_diff/operation_tree_flatteners/collection.rb +139 -0
- data/lib/super_diff/operation_tree_flatteners/custom_object.rb +28 -0
- data/lib/super_diff/operation_tree_flatteners/default_object.rb +32 -0
- data/lib/super_diff/operation_tree_flatteners/hash.rb +41 -0
- data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +17 -0
- data/lib/super_diff/operation_trees/array.rb +4 -7
- data/lib/super_diff/operation_trees/base.rb +39 -16
- data/lib/super_diff/operation_trees/custom_object.rb +4 -8
- data/lib/super_diff/operation_trees/default_object.rb +28 -13
- data/lib/super_diff/operation_trees/hash.rb +4 -7
- data/lib/super_diff/operation_trees/main.rb +1 -1
- data/lib/super_diff/operation_trees/multiline_string.rb +4 -7
- data/lib/super_diff/operations/binary_operation.rb +1 -6
- data/lib/super_diff/operations/unary_operation.rb +2 -30
- data/lib/super_diff/recursion_guard.rb +3 -3
- data/lib/super_diff/rspec.rb +41 -13
- data/lib/super_diff/rspec/differs/collection_including.rb +4 -2
- data/lib/super_diff/rspec/differs/hash_including.rb +4 -2
- 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/raise_error.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +5 -5
- data/lib/super_diff/rspec/monkey_patches.rb +353 -306
- data/lib/super_diff/rspec/object_inspection.rb +4 -1
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +44 -0
- data/lib/super_diff/rspec/object_inspection/{inspectors → inspection_tree_builders}/collection_containing_exactly.rb +9 -8
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +34 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +103 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +36 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +26 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +26 -0
- data/lib/super_diff/rspec/object_inspection/{inspectors → inspection_tree_builders}/object_having_attributes.rb +10 -12
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/primitive.rb +10 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +33 -0
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +12 -4
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +10 -3
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +10 -3
- data/lib/super_diff/tiered_lines.rb +4 -0
- data/lib/super_diff/tiered_lines_elider.rb +490 -0
- data/lib/super_diff/tiered_lines_formatter.rb +79 -0
- data/lib/super_diff/version.rb +1 -1
- data/spec/examples.txt +407 -5
- data/spec/integration/rails/active_support_spec.rb +19 -0
- 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 +113 -107
- data/spec/integration/rspec/eq_matcher_spec.rb +223 -277
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +138 -129
- 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 +126 -119
- data/spec/integration/rspec/match_matcher_spec.rb +362 -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 +5 -5
- data/spec/spec_helper.rb +33 -13
- data/spec/support/command_runner.rb +15 -25
- data/spec/support/helpers.rb +21 -0
- data/spec/support/integration/helpers.rb +8 -2
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +4 -4
- data/spec/support/integration/test_programs/base.rb +38 -10
- data/spec/support/integration/test_programs/rspec_active_record.rb +1 -1
- data/spec/support/integration/test_programs/rspec_active_support.rb +17 -0
- data/spec/support/integration/test_programs/rspec_rails.rb +1 -1
- data/spec/support/shared_examples/active_record.rb +109 -108
- data/spec/support/shared_examples/active_support.rb +65 -0
- data/spec/support/shared_examples/elided_diffs.rb +914 -0
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +196 -232
- data/spec/support/unit/helpers.rb +15 -0
- data/spec/support/unit/matchers/match_output.rb +41 -0
- data/spec/unit/active_record/object_inspection_spec.rb +273 -0
- data/spec/unit/equality_matchers/main_spec.rb +445 -465
- data/spec/unit/helpers_spec.rb +61 -0
- data/spec/unit/operation_tree_flatteners/array_spec.rb +604 -0
- data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +667 -0
- data/spec/unit/operation_tree_flatteners/default_object_spec.rb +687 -0
- data/spec/unit/operation_tree_flatteners/hash_spec.rb +632 -0
- data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +121 -0
- data/spec/unit/rspec/object_inspection_spec.rb +446 -0
- data/spec/unit/super_diff_spec.rb +1958 -0
- data/spec/unit/tiered_lines_elider_spec.rb +6356 -0
- data/spec/unit/tiered_lines_formatter_spec.rb +193 -0
- data/super_diff.gemspec +1 -1
- metadata +95 -50
- data/lib/super_diff/active_record/diff_formatters.rb +0 -10
- data/lib/super_diff/active_record/diff_formatters/active_record_relation.rb +0 -23
- data/lib/super_diff/active_record/object_inspection/inspectors.rb +0 -16
- data/lib/super_diff/active_support/diff_formatters.rb +0 -10
- data/lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb +0 -36
- data/lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb +0 -28
- data/lib/super_diff/diff_formatters.rb +0 -14
- data/lib/super_diff/diff_formatters/array.rb +0 -21
- data/lib/super_diff/diff_formatters/base.rb +0 -33
- data/lib/super_diff/diff_formatters/custom_object.rb +0 -30
- data/lib/super_diff/diff_formatters/default_object.rb +0 -46
- data/lib/super_diff/diff_formatters/defaults.rb +0 -10
- data/lib/super_diff/diff_formatters/hash.rb +0 -34
- data/lib/super_diff/diff_formatters/main.rb +0 -41
- data/lib/super_diff/object_inspection/inspectors.rb +0 -23
- data/lib/super_diff/object_inspection/inspectors/array.rb +0 -32
- data/lib/super_diff/object_inspection/inspectors/base.rb +0 -36
- data/lib/super_diff/object_inspection/inspectors/custom_object.rb +0 -37
- data/lib/super_diff/object_inspection/inspectors/default_object.rb +0 -61
- data/lib/super_diff/object_inspection/inspectors/hash.rb +0 -32
- data/lib/super_diff/object_inspection/inspectors/primitive.rb +0 -28
- data/lib/super_diff/object_inspection/inspectors/string.rb +0 -23
- data/lib/super_diff/object_inspection/inspectors/time_like.rb +0 -23
- data/lib/super_diff/object_inspection/nodes/break.rb +0 -15
- data/lib/super_diff/object_inspection/nodes/when_multiline.rb +0 -22
- data/lib/super_diff/object_inspection/nodes/when_singleline.rb +0 -24
- data/lib/super_diff/rspec/object_inspection/inspectors.rb +0 -40
- data/lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb +0 -28
- data/lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb +0 -31
- data/lib/super_diff/rspec/object_inspection/inspectors/instance_of.rb +0 -23
- data/lib/super_diff/rspec/object_inspection/inspectors/kind_of.rb +0 -23
- data/lib/super_diff/rspec/object_inspection/inspectors/primitive.rb +0 -13
- data/lib/super_diff/rspec/object_inspection/inspectors/value_within.rb +0 -29
- data/spec/support/object_id.rb +0 -27
- data/spec/support/ruby_versions.rb +0 -11
- data/spec/unit/object_inspection_spec.rb +0 -1168
@@ -23,7 +23,7 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
23
23
|
red_line "Here is the next line."
|
24
24
|
plain_line " This part is indented, for whatever reason. It just kinda keeps"
|
25
25
|
plain_line " going until we finish saying whatever it is we want to say."
|
26
|
-
}
|
26
|
+
},
|
27
27
|
)
|
28
28
|
|
29
29
|
expect(program).
|
@@ -50,10 +50,10 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
50
50
|
snippet: %|expect(:anything).to fail_with_paragraphed_failure_message|,
|
51
51
|
newline_before_expectation: true,
|
52
52
|
expectation: proc {
|
53
|
-
red_line
|
53
|
+
red_line "This is a message that spans multiple paragraphs."
|
54
54
|
newline
|
55
55
|
plain_line "Here is the next paragraph."
|
56
|
-
}
|
56
|
+
},
|
57
57
|
)
|
58
58
|
|
59
59
|
expect(program).
|
@@ -81,7 +81,7 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
81
81
|
expectation: proc {
|
82
82
|
red_line "This is a message that spans multiple lines."
|
83
83
|
red_line "Here is the next line."
|
84
|
-
}
|
84
|
+
},
|
85
85
|
)
|
86
86
|
|
87
87
|
expect(program).
|
@@ -142,7 +142,7 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
142
142
|
red_line "Here is the next line."
|
143
143
|
plain_line " This part is indented, for whatever reason. It just kinda keeps"
|
144
144
|
plain_line " going until we finish saying whatever it is we want to say."
|
145
|
-
}
|
145
|
+
},
|
146
146
|
)
|
147
147
|
|
148
148
|
expect(program).
|
@@ -171,8 +171,8 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
171
171
|
expectation: proc {
|
172
172
|
red_line "This is a message that spans multiple paragraphs."
|
173
173
|
newline
|
174
|
-
plain_line
|
175
|
-
}
|
174
|
+
plain_line "Here is the next paragraph."
|
175
|
+
},
|
176
176
|
)
|
177
177
|
|
178
178
|
expect(program).
|
@@ -228,7 +228,7 @@ RSpec.describe "Integration with a third-party matcher", type: :integration do
|
|
228
228
|
snippet: %|expect(:anything).not_to pass_with_singleline_failure_message|,
|
229
229
|
expectation: proc {
|
230
230
|
red_line "This is a message that spans only one line."
|
231
|
-
}
|
231
|
+
},
|
232
232
|
)
|
233
233
|
|
234
234
|
expect(program).
|
@@ -21,7 +21,7 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
|
|
21
21
|
expectation: proc {
|
22
22
|
red_line "RuntimeError:"
|
23
23
|
indent by: 2 do
|
24
|
-
red_line
|
24
|
+
red_line "Some kind of error or whatever"
|
25
25
|
newline
|
26
26
|
plain_line "This is another line"
|
27
27
|
end
|
@@ -95,7 +95,7 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
|
|
95
95
|
indent by: 5 do
|
96
96
|
line do
|
97
97
|
plain "1.1) "
|
98
|
-
bold
|
98
|
+
bold "Failure/Error: "
|
99
99
|
plain snippet
|
100
100
|
end
|
101
101
|
|
@@ -106,7 +106,7 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
|
|
106
106
|
indent by: 2 do
|
107
107
|
red_line "Some kind of error or whatever"
|
108
108
|
newline
|
109
|
-
line
|
109
|
+
line "This is another line"
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
@@ -116,7 +116,7 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
|
|
116
116
|
indent by: 5 do
|
117
117
|
line do
|
118
118
|
plain "1.2) "
|
119
|
-
bold
|
119
|
+
bold "Failure/Error: "
|
120
120
|
plain snippet
|
121
121
|
end
|
122
122
|
|
@@ -127,7 +127,7 @@ RSpec.describe "Integration with RSpec and unhandled errors", type: :integration
|
|
127
127
|
indent by: 2 do
|
128
128
|
red_line "Some kind of error or whatever"
|
129
129
|
newline
|
130
|
-
line
|
130
|
+
line "This is another line"
|
131
131
|
end
|
132
132
|
end
|
133
133
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "pp"
|
2
|
+
|
1
3
|
begin
|
2
4
|
require "pry-byebug"
|
3
5
|
rescue LoadError
|
@@ -8,6 +10,8 @@ begin
|
|
8
10
|
rescue LoadError
|
9
11
|
end
|
10
12
|
|
13
|
+
require "climate_control"
|
14
|
+
|
11
15
|
#---
|
12
16
|
|
13
17
|
require_relative "../support/current_bundle"
|
@@ -18,28 +22,28 @@ SuperDiff::CurrentBundle.instance.assert_appraisal!
|
|
18
22
|
|
19
23
|
begin
|
20
24
|
require "active_record"
|
25
|
+
|
21
26
|
active_record_available = true
|
22
|
-
rescue LoadError
|
23
|
-
active_record_available = false
|
24
|
-
end
|
25
27
|
|
26
|
-
if active_record_available
|
27
28
|
ActiveRecord::Base.establish_connection(
|
28
29
|
adapter: "sqlite3",
|
29
30
|
database: ":memory:",
|
30
31
|
)
|
31
|
-
|
32
|
-
|
33
|
-
else
|
34
|
-
require "super_diff/rspec"
|
32
|
+
rescue LoadError
|
33
|
+
active_record_available = false
|
35
34
|
end
|
36
35
|
|
37
|
-
Dir.glob(File.expand_path("support/**/*.rb", __dir__)).
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
Dir.glob(File.expand_path("support/**/*.rb", __dir__)).
|
37
|
+
sort.
|
38
|
+
reject do |file|
|
39
|
+
file.include?("/models/active_record/") && !active_record_available
|
40
|
+
end.
|
41
|
+
each do |file|
|
42
|
+
require file
|
43
|
+
end
|
41
44
|
|
42
45
|
RSpec.configure do |config|
|
46
|
+
config.include(SuperDiff::UnitTests, type: :unit)
|
43
47
|
config.include(SuperDiff::IntegrationTests, type: :integration)
|
44
48
|
|
45
49
|
config.expect_with :rspec do |expectations|
|
@@ -65,6 +69,22 @@ RSpec.configure do |config|
|
|
65
69
|
|
66
70
|
config.order = :random
|
67
71
|
Kernel.srand config.seed
|
72
|
+
|
73
|
+
if ENV["CI"] == "true"
|
74
|
+
config.color_mode = :on
|
75
|
+
end
|
68
76
|
end
|
69
77
|
|
70
|
-
require "
|
78
|
+
require "warnings_logger"
|
79
|
+
$VERBOSE = true
|
80
|
+
WarningsLogger.configure do |config|
|
81
|
+
config.project_name = "super_diff"
|
82
|
+
config.project_directory = Pathname.new("..").expand_path(__dir__)
|
83
|
+
end
|
84
|
+
WarningsLogger.enable
|
85
|
+
|
86
|
+
if active_record_available
|
87
|
+
require "super_diff/rspec-rails"
|
88
|
+
else
|
89
|
+
require "super_diff/rspec"
|
90
|
+
end
|
@@ -5,24 +5,6 @@ require "shellwords"
|
|
5
5
|
require "timeout"
|
6
6
|
|
7
7
|
class CommandRunner
|
8
|
-
module OutputHelpers
|
9
|
-
def self.bookended(text)
|
10
|
-
divider("START") + text + "\n" + divider("END")
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.divider(title = "")
|
14
|
-
total_length = 72
|
15
|
-
start_length = 3
|
16
|
-
|
17
|
-
string = ""
|
18
|
-
string << ("-" * start_length)
|
19
|
-
string << title
|
20
|
-
string << "-" * (total_length - start_length - title.length)
|
21
|
-
string << "\n"
|
22
|
-
string
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
8
|
class CommandFailedError < StandardError
|
27
9
|
def self.create(command:, exit_status:, output:, message: nil)
|
28
10
|
allocate.tap do |error|
|
@@ -49,7 +31,11 @@ Command #{command.inspect} failed, exiting with status #{exit_status}.
|
|
49
31
|
if output
|
50
32
|
message << <<-MESSAGE
|
51
33
|
Output:
|
52
|
-
#{
|
34
|
+
#{
|
35
|
+
SuperDiff::Test::OutputHelpers.divider("START") +
|
36
|
+
output +
|
37
|
+
SuperDiff::Test::OutputHelpers.divider("END")
|
38
|
+
}
|
53
39
|
MESSAGE
|
54
40
|
end
|
55
41
|
|
@@ -83,7 +69,11 @@ Command #{formatted_command.inspect} timed out after #{timeout} seconds.
|
|
83
69
|
if output
|
84
70
|
message << <<-MESSAGE
|
85
71
|
Output:
|
86
|
-
#{
|
72
|
+
#{
|
73
|
+
SuperDiff::Test::OutputHelpers.divider("START") +
|
74
|
+
output +
|
75
|
+
SuperDiff::Test::OutputHelpers.divider("END")
|
76
|
+
}
|
87
77
|
MESSAGE
|
88
78
|
end
|
89
79
|
|
@@ -120,9 +110,9 @@ Output:
|
|
120
110
|
@env = extract_env_from(@options)
|
121
111
|
|
122
112
|
@process = ChildProcess.build(*command)
|
123
|
-
|
124
|
-
|
125
|
-
|
113
|
+
@env.each do |key, value|
|
114
|
+
@process.environment[key] = value
|
115
|
+
end
|
126
116
|
@process.io.stdout = @process.io.stderr = @writer
|
127
117
|
|
128
118
|
@wrapper = -> (block) { block.call }
|
@@ -250,9 +240,9 @@ Output:
|
|
250
240
|
|
251
241
|
debug do
|
252
242
|
"\n" +
|
253
|
-
OutputHelpers.divider("START") +
|
243
|
+
SuperDiff::Test::OutputHelpers.divider("START") +
|
254
244
|
output +
|
255
|
-
OutputHelpers.divider("END")
|
245
|
+
SuperDiff::Test::OutputHelpers.divider("END")
|
256
246
|
end
|
257
247
|
end
|
258
248
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SuperDiff
|
2
|
+
module Test
|
3
|
+
module OutputHelpers
|
4
|
+
def self.bookended(text)
|
5
|
+
divider("START") + text + "\n" + divider("END")
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.divider(title = "")
|
9
|
+
total_length = 72
|
10
|
+
start_length = 3
|
11
|
+
|
12
|
+
string = ""
|
13
|
+
string << ("-" * start_length)
|
14
|
+
string << title
|
15
|
+
string << "-" * (total_length - start_length - title.length)
|
16
|
+
string << "\n"
|
17
|
+
string
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -11,21 +11,27 @@ module SuperDiff
|
|
11
11
|
def make_plain_test_program(
|
12
12
|
test,
|
13
13
|
color_enabled:,
|
14
|
+
configuration: {},
|
14
15
|
preserve_as_whole_file: false
|
15
16
|
)
|
16
17
|
TestPrograms::Plain.new(
|
17
18
|
test,
|
18
19
|
color_enabled: color_enabled,
|
20
|
+
configuration: configuration,
|
19
21
|
preserve_as_whole_file: preserve_as_whole_file,
|
20
22
|
)
|
21
23
|
end
|
22
24
|
|
23
25
|
def make_rspec_active_record_program(test, color_enabled:)
|
24
|
-
TestPrograms::
|
26
|
+
TestPrograms::RSpecActiveRecord.new(test, color_enabled: color_enabled)
|
27
|
+
end
|
28
|
+
|
29
|
+
def make_rspec_active_support_program(test, color_enabled:)
|
30
|
+
TestPrograms::RSpecActiveSupport.new(test, color_enabled: color_enabled)
|
25
31
|
end
|
26
32
|
|
27
33
|
def make_rspec_rails_test_program(test, color_enabled:)
|
28
|
-
TestPrograms::
|
34
|
+
TestPrograms::RSpecRails.new(test, color_enabled: color_enabled)
|
29
35
|
end
|
30
36
|
|
31
37
|
def build_expected_output(
|
@@ -12,7 +12,7 @@ module SuperDiff
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def removing_object_ids
|
15
|
-
first_replacing(/#<([\w:]+):0x[a-
|
15
|
+
first_replacing(/#<([\w:]+):0x[a-f0-9]+/, '#<\1')
|
16
16
|
self
|
17
17
|
end
|
18
18
|
|
@@ -36,12 +36,12 @@ module SuperDiff
|
|
36
36
|
"."
|
37
37
|
else
|
38
38
|
message =
|
39
|
-
"Expected test to produce output, but it did not.\n\n" +
|
39
|
+
"Expected test to produce #{expect_output_to_contain_color? ? "colored" : "uncolored"} output, but it did not.\n\n" +
|
40
40
|
"Expected output to contain:\n\n" +
|
41
|
-
|
41
|
+
SuperDiff::Test::OutputHelpers.bookended(expected_output) +
|
42
42
|
"\n" +
|
43
43
|
"Actual output:\n\n" +
|
44
|
-
|
44
|
+
SuperDiff::Test::OutputHelpers.bookended(actual_output)
|
45
45
|
|
46
46
|
if ["1", "true"].include?(ENV["SHOW_DIFF"])
|
47
47
|
::RSpec::Matchers::ExpectedsForMultipleDiffs.
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require "attr_extras/explicit"
|
2
|
+
require "json"
|
3
|
+
|
1
4
|
module SuperDiff
|
2
5
|
module IntegrationTests
|
3
6
|
module TestPrograms
|
@@ -7,11 +10,15 @@ module SuperDiff
|
|
7
10
|
PROJECT_DIRECTORY = Pathname.new("../../../..").expand_path(__dir__)
|
8
11
|
TEMP_DIRECTORY = PROJECT_DIRECTORY.join("tmp")
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
def initialize(
|
14
|
+
code,
|
15
|
+
color_enabled:,
|
16
|
+
configuration: {},
|
17
|
+
preserve_as_whole_file: false
|
18
|
+
)
|
13
19
|
@code = code.strip
|
14
20
|
@color_enabled = color_enabled
|
21
|
+
@configuration = configuration
|
15
22
|
@preserve_as_whole_file = preserve_as_whole_file
|
16
23
|
end
|
17
24
|
|
@@ -31,15 +38,27 @@ module SuperDiff
|
|
31
38
|
|
32
39
|
private
|
33
40
|
|
34
|
-
|
35
|
-
|
41
|
+
attr_reader :code, :configuration
|
42
|
+
|
43
|
+
def color_enabled?
|
44
|
+
@color_enabled
|
45
|
+
end
|
46
|
+
|
47
|
+
def preserve_as_whole_file?
|
48
|
+
@preserve_as_whole_file
|
49
|
+
end
|
36
50
|
|
37
51
|
def result_of_command
|
38
52
|
@_result_of_command ||=
|
39
53
|
if zeus_running?
|
40
|
-
Bundler.with_unbundled_env
|
54
|
+
Bundler.with_unbundled_env do
|
55
|
+
CommandRunner.run(Shellwords.join(command))
|
56
|
+
end
|
41
57
|
else
|
42
|
-
CommandRunner.run(
|
58
|
+
CommandRunner.run(
|
59
|
+
Shellwords.join(command),
|
60
|
+
env: { 'DISABLE_PRY' => 'true' },
|
61
|
+
)
|
43
62
|
end
|
44
63
|
end
|
45
64
|
|
@@ -49,7 +68,15 @@ module SuperDiff
|
|
49
68
|
end
|
50
69
|
|
51
70
|
if zeus_running?
|
52
|
-
[
|
71
|
+
[
|
72
|
+
"zeus",
|
73
|
+
test_plan_command,
|
74
|
+
color_option,
|
75
|
+
"--no-pry",
|
76
|
+
tempfile.to_s,
|
77
|
+
"--configuration",
|
78
|
+
JSON.generate(configuration),
|
79
|
+
]
|
53
80
|
else
|
54
81
|
[
|
55
82
|
"rspec",
|
@@ -65,7 +92,7 @@ module SuperDiff
|
|
65
92
|
end
|
66
93
|
|
67
94
|
def color_option
|
68
|
-
color_enabled ? "--color" : "--no-color"
|
95
|
+
color_enabled? ? "--color" : "--no-color"
|
69
96
|
end
|
70
97
|
|
71
98
|
def tempfile
|
@@ -86,7 +113,8 @@ module SuperDiff
|
|
86
113
|
|
87
114
|
test_plan = TestPlan.new(
|
88
115
|
using_outside_of_zeus: true,
|
89
|
-
color_enabled: #{color_enabled
|
116
|
+
color_enabled: #{color_enabled?.inspect},
|
117
|
+
configuration: #{configuration.inspect}
|
90
118
|
)
|
91
119
|
test_plan.boot
|
92
120
|
#{test_plan_prelude}
|
@@ -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
|