assert 2.19.1 → 2.19.6
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/assert.gemspec +10 -7
- data/lib/assert.rb +18 -6
- data/lib/assert/actual_value.rb +8 -6
- data/lib/assert/assert_runner.rb +36 -17
- data/lib/assert/assertions.rb +83 -50
- data/lib/assert/cli.rb +30 -70
- data/lib/assert/clirb.rb +55 -0
- data/lib/assert/config.rb +20 -8
- data/lib/assert/config_helpers.rb +55 -22
- data/lib/assert/context.rb +14 -18
- data/lib/assert/context/let_dsl.rb +5 -2
- data/lib/assert/context/setup_dsl.rb +21 -16
- data/lib/assert/context/subject_dsl.rb +6 -7
- data/lib/assert/context/suite_dsl.rb +2 -1
- data/lib/assert/context/test_dsl.rb +55 -19
- data/lib/assert/default_suite.rb +25 -15
- data/lib/assert/default_view.rb +47 -30
- data/lib/assert/file_line.rb +6 -6
- data/lib/assert/macro.rb +1 -1
- data/lib/assert/macros/methods.rb +71 -45
- data/lib/assert/result.rb +111 -62
- data/lib/assert/runner.rb +68 -51
- data/lib/assert/stub.rb +42 -3
- data/lib/assert/suite.rb +67 -28
- data/lib/assert/test.rb +40 -35
- data/lib/assert/utils.rb +19 -10
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view.rb +44 -18
- data/lib/assert/view_helpers.rb +100 -92
- data/test/helper.rb +3 -1
- data/test/support/factory.rb +38 -21
- data/test/system/stub_tests.rb +180 -144
- data/test/system/test_tests.rb +86 -60
- data/test/unit/actual_value_tests.rb +69 -50
- data/test/unit/assert_tests.rb +39 -22
- data/test/unit/assertions/assert_block_tests.rb +10 -10
- data/test/unit/assertions/assert_changes_tests.rb +25 -21
- data/test/unit/assertions/assert_empty_tests.rb +14 -12
- data/test/unit/assertions/assert_equal_tests.rb +26 -26
- data/test/unit/assertions/assert_file_exists_tests.rb +15 -13
- data/test/unit/assertions/assert_includes_tests.rb +10 -10
- data/test/unit/assertions/assert_instance_of_tests.rb +14 -14
- data/test/unit/assertions/assert_is_a_tests.rb +128 -0
- data/test/unit/assertions/assert_match_tests.rb +10 -10
- data/test/unit/assertions/assert_nil_tests.rb +16 -12
- data/test/unit/assertions/assert_raises_tests.rb +27 -20
- data/test/unit/assertions/assert_respond_to_tests.rb +10 -10
- data/test/unit/assertions/assert_same_tests.rb +24 -24
- data/test/unit/assertions/assert_true_false_tests.rb +32 -24
- data/test/unit/assertions_tests.rb +14 -9
- data/test/unit/config_helpers_tests.rb +15 -10
- data/test/unit/config_tests.rb +34 -9
- data/test/unit/context/setup_dsl_tests.rb +24 -14
- data/test/unit/context/subject_dsl_tests.rb +3 -3
- data/test/unit/context/suite_dsl_tests.rb +4 -4
- data/test/unit/context/test_dsl_tests.rb +37 -17
- data/test/unit/context_info_tests.rb +4 -4
- data/test/unit/context_tests.rb +110 -54
- data/test/unit/default_suite_tests.rb +10 -6
- data/test/unit/factory_tests.rb +2 -2
- data/test/unit/file_line_tests.rb +7 -7
- data/test/unit/macro_tests.rb +11 -11
- data/test/unit/result_tests.rb +47 -41
- data/test/unit/runner_tests.rb +29 -16
- data/test/unit/suite_tests.rb +37 -15
- data/test/unit/test_tests.rb +63 -50
- data/test/unit/utils_tests.rb +48 -35
- data/test/unit/view_helpers_tests.rb +21 -14
- data/test/unit/view_tests.rb +5 -5
- metadata +26 -11
- data/test/unit/assertions/assert_kind_of_tests.rb +0 -68
data/test/unit/suite_tests.rb
CHANGED
@@ -10,9 +10,9 @@ require "test/support/inherited_stuff"
|
|
10
10
|
class Assert::Suite
|
11
11
|
class UnitTests < Assert::Context
|
12
12
|
desc "Assert::Suite"
|
13
|
-
subject
|
13
|
+
subject{ unit_class }
|
14
14
|
|
15
|
-
let(:unit_class)
|
15
|
+
let(:unit_class){ Assert::Suite }
|
16
16
|
|
17
17
|
should "include the config helpers" do
|
18
18
|
assert_that(subject).includes(Assert::ConfigHelpers)
|
@@ -21,9 +21,9 @@ class Assert::Suite
|
|
21
21
|
|
22
22
|
class InitTests < UnitTests
|
23
23
|
desc "when init"
|
24
|
-
subject
|
24
|
+
subject{ unit_class.new(config1) }
|
25
25
|
|
26
|
-
let(:config1)
|
26
|
+
let(:config1){ Factory.modes_off_config }
|
27
27
|
|
28
28
|
should have_readers :config, :setups, :teardowns
|
29
29
|
should have_accessors :start_time, :end_time
|
@@ -74,8 +74,10 @@ class Assert::Suite
|
|
74
74
|
Assert.stub(subject, :result_count){ count }
|
75
75
|
|
76
76
|
assert_that(subject.run_time).equals(time)
|
77
|
-
assert_that(subject.test_rate)
|
78
|
-
|
77
|
+
assert_that(subject.test_rate)
|
78
|
+
.equals((subject.test_count / subject.run_time))
|
79
|
+
assert_that(subject.result_rate)
|
80
|
+
.equals((subject.result_count / subject.run_time))
|
79
81
|
end
|
80
82
|
|
81
83
|
should "add setup procs" do
|
@@ -106,17 +108,37 @@ class Assert::Suite
|
|
106
108
|
tests1.each{ |test| subject.on_test(test) }
|
107
109
|
end
|
108
110
|
|
109
|
-
let(:ci1)
|
110
|
-
let(:tests1)
|
111
|
+
let(:ci1){ proc{ Factory.context_info(Factory.modes_off_context_class) } }
|
112
|
+
let(:tests1) do
|
113
|
+
# rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
|
111
114
|
[
|
112
|
-
Factory.test("should nothing", ci1.call)
|
113
|
-
|
114
|
-
Factory.test("should
|
115
|
-
|
116
|
-
|
117
|
-
|
115
|
+
Factory.test("should nothing", ci1.call) do
|
116
|
+
end,
|
117
|
+
Factory.test("should pass", ci1.call) do
|
118
|
+
assert(1 == 1)
|
119
|
+
refute(1 == 0)
|
120
|
+
end,
|
121
|
+
Factory.test("should fail", ci1.call) do
|
122
|
+
ignore
|
123
|
+
assert(1 == 0)
|
124
|
+
refute(1 == 1)
|
125
|
+
end,
|
126
|
+
Factory.test("should ignore", ci1.call) do
|
127
|
+
ignore
|
128
|
+
end,
|
129
|
+
Factory.test("should skip", ci1.call) do
|
130
|
+
skip
|
131
|
+
ignore
|
132
|
+
assert(1 == 1)
|
133
|
+
end,
|
134
|
+
Factory.test("should error", ci1.call) do
|
135
|
+
raise Exception
|
136
|
+
ignore # rubocop:disable Lint/UnreachableCode
|
137
|
+
assert(1 == 1)
|
138
|
+
end,
|
118
139
|
]
|
119
|
-
|
140
|
+
# rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
|
141
|
+
end
|
120
142
|
|
121
143
|
should "know its tests-to-run attrs" do
|
122
144
|
assert_that(subject.tests_to_run_count).equals(tests1.size)
|
data/test/unit/test_tests.rb
CHANGED
@@ -10,14 +10,16 @@ require "assert/result"
|
|
10
10
|
class Assert::Test
|
11
11
|
class UnitTests < Assert::Context
|
12
12
|
desc "Assert::Test"
|
13
|
-
subject
|
13
|
+
subject{ unit_class }
|
14
14
|
|
15
|
-
let(:unit_class)
|
15
|
+
let(:unit_class){ Assert::Test }
|
16
16
|
|
17
|
-
let(:context_class1)
|
18
|
-
|
19
|
-
|
20
|
-
let(:
|
17
|
+
let(:context_class1) do
|
18
|
+
Factory.modes_off_context_class{ desc "context class" }
|
19
|
+
end
|
20
|
+
let(:context_info1){ Factory.context_info(context_class1) }
|
21
|
+
let(:config1){ Factory.modes_off_config }
|
22
|
+
let(:test_code1){ proc{ assert(true) } }
|
21
23
|
|
22
24
|
should have_imeths :name_file_line_context_data, :for_block
|
23
25
|
|
@@ -50,24 +52,26 @@ class Assert::Test
|
|
50
52
|
|
51
53
|
class InitWithDataTests < UnitTests
|
52
54
|
desc "when init with data"
|
53
|
-
subject
|
55
|
+
subject{ unit_class.new(meta_data1.merge(run_data1)) }
|
54
56
|
|
55
|
-
let(:file_line1)
|
56
|
-
|
57
|
+
let(:file_line1) do
|
58
|
+
Assert::FileLine.new(Factory.string, Factory.integer.to_s)
|
59
|
+
end
|
60
|
+
let(:meta_data1) do
|
57
61
|
{
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
+
file_line: file_line1.to_s,
|
63
|
+
name: Factory.string,
|
64
|
+
output: Factory.string,
|
65
|
+
run_time: Factory.float(1.0),
|
62
66
|
}
|
63
|
-
|
64
|
-
let(:run_data1)
|
67
|
+
end
|
68
|
+
let(:run_data1) do
|
65
69
|
{
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
70
|
+
context_info: context_info1,
|
71
|
+
config: config1,
|
72
|
+
code: test_code1,
|
69
73
|
}
|
70
|
-
|
74
|
+
end
|
71
75
|
|
72
76
|
should have_imeths :file_line, :file_name, :line_num
|
73
77
|
should have_imeths :name, :output, :run_time
|
@@ -107,9 +111,12 @@ class Assert::Test
|
|
107
111
|
end
|
108
112
|
|
109
113
|
should "have a custom inspect that only shows limited attributes" do
|
110
|
-
attrs =
|
111
|
-
|
112
|
-
|
114
|
+
attrs =
|
115
|
+
[:name, :context_info]
|
116
|
+
.map{ |method|
|
117
|
+
"@#{method}=#{subject.send(method).inspect}"
|
118
|
+
}
|
119
|
+
.join(" ")
|
113
120
|
exp = "#<#{subject.class}:#{"0x0%x" % (subject.object_id << 1)} #{attrs}>"
|
114
121
|
assert_that(subject.inspect).equals(exp)
|
115
122
|
end
|
@@ -118,13 +125,13 @@ class Assert::Test
|
|
118
125
|
class PassFailIgnoreHandlingTests < UnitTests
|
119
126
|
include Assert::Test::TestHelpers
|
120
127
|
|
121
|
-
subject
|
128
|
+
subject do
|
122
129
|
Factory.test("pass fail ignore test", context_info1) do
|
123
130
|
ignore("something")
|
124
131
|
assert(true)
|
125
132
|
assert(false)
|
126
133
|
end
|
127
|
-
|
134
|
+
end
|
128
135
|
|
129
136
|
setup do
|
130
137
|
subject.context_class.setup do
|
@@ -184,7 +191,7 @@ class Assert::Test
|
|
184
191
|
end
|
185
192
|
|
186
193
|
should "capture fails in the context setup" do
|
187
|
-
test = Factory.test("setup halt-on-fail test", context_info1){
|
194
|
+
test = Factory.test("setup halt-on-fail test", context_info1){}
|
188
195
|
test.context_class.setup{ raise Assert::Result::TestFailure }
|
189
196
|
test.run(&test_run_callback)
|
190
197
|
|
@@ -192,7 +199,7 @@ class Assert::Test
|
|
192
199
|
end
|
193
200
|
|
194
201
|
should "capture fails in the context teardown" do
|
195
|
-
test = Factory.test("teardown halt-on-fail test", context_info1){
|
202
|
+
test = Factory.test("teardown halt-on-fail test", context_info1){}
|
196
203
|
test.context_class.teardown{ raise Assert::Result::TestFailure }
|
197
204
|
test.run(&test_run_callback)
|
198
205
|
|
@@ -201,11 +208,13 @@ class Assert::Test
|
|
201
208
|
|
202
209
|
private
|
203
210
|
|
204
|
-
def assert_failed(
|
211
|
+
def assert_failed(_test)
|
205
212
|
with_backtrace(caller) do
|
206
|
-
assert_that(test_run_result_count)
|
213
|
+
assert_that(test_run_result_count)
|
214
|
+
.equals(1, "too many/few fail results")
|
207
215
|
test_run_results.each do |result|
|
208
|
-
assert_that(result)
|
216
|
+
assert_that(result)
|
217
|
+
.is_kind_of(Assert::Result::Fail, "not a fail result")
|
209
218
|
end
|
210
219
|
end
|
211
220
|
end
|
@@ -222,7 +231,7 @@ class Assert::Test
|
|
222
231
|
end
|
223
232
|
|
224
233
|
should "capture skips in the context setup" do
|
225
|
-
test = Factory.test("setup skip test", context_info1){
|
234
|
+
test = Factory.test("setup skip test", context_info1){}
|
226
235
|
test.context_class.setup{ skip }
|
227
236
|
test.run(&test_run_callback)
|
228
237
|
|
@@ -230,7 +239,7 @@ class Assert::Test
|
|
230
239
|
end
|
231
240
|
|
232
241
|
should "capture skips in the context teardown" do
|
233
|
-
test = Factory.test("teardown skip test", context_info1){
|
242
|
+
test = Factory.test("teardown skip test", context_info1){}
|
234
243
|
test.context_class.teardown{ skip }
|
235
244
|
test.run(&test_run_callback)
|
236
245
|
|
@@ -239,11 +248,13 @@ class Assert::Test
|
|
239
248
|
|
240
249
|
private
|
241
250
|
|
242
|
-
def assert_skipped(
|
251
|
+
def assert_skipped(_test)
|
243
252
|
with_backtrace(caller) do
|
244
|
-
assert_that(test_run_result_count)
|
253
|
+
assert_that(test_run_result_count)
|
254
|
+
.equals(1, "too many/few skip results")
|
245
255
|
test_run_results.each do |result|
|
246
|
-
assert_that(result)
|
256
|
+
assert_that(result)
|
257
|
+
.is_kind_of(Assert::Result::Skip, "not a skip result")
|
247
258
|
end
|
248
259
|
end
|
249
260
|
end
|
@@ -262,7 +273,7 @@ class Assert::Test
|
|
262
273
|
end
|
263
274
|
|
264
275
|
should "capture errors in the context setup" do
|
265
|
-
test = Factory.test("setup error test", context_info1){
|
276
|
+
test = Factory.test("setup error test", context_info1){}
|
266
277
|
test.context_class.setup{ raise "an error" }
|
267
278
|
test.run(&test_run_callback)
|
268
279
|
|
@@ -270,7 +281,7 @@ class Assert::Test
|
|
270
281
|
end
|
271
282
|
|
272
283
|
should "capture errors in the context teardown" do
|
273
|
-
test = Factory.test("teardown error test", context_info1){
|
284
|
+
test = Factory.test("teardown error test", context_info1){}
|
274
285
|
test.context_class.teardown{ raise "an error" }
|
275
286
|
test.run(&test_run_callback)
|
276
287
|
|
@@ -279,11 +290,13 @@ class Assert::Test
|
|
279
290
|
|
280
291
|
private
|
281
292
|
|
282
|
-
def assert_errored(
|
293
|
+
def assert_errored(_test)
|
283
294
|
with_backtrace(caller) do
|
284
|
-
assert_that(test_run_result_count)
|
295
|
+
assert_that(test_run_result_count)
|
296
|
+
.equals(1, "too many/few error results")
|
285
297
|
test_run_results.each do |result|
|
286
|
-
assert_that(result)
|
298
|
+
assert_that(result)
|
299
|
+
.is_kind_of(Assert::Result::Error, "not an error result")
|
287
300
|
end
|
288
301
|
end
|
289
302
|
end
|
@@ -295,27 +308,27 @@ class Assert::Test
|
|
295
308
|
raise SignalException, "USR1"
|
296
309
|
end
|
297
310
|
|
298
|
-
assert_that
|
311
|
+
assert_that{ test.run }.raises(SignalException)
|
299
312
|
end
|
300
313
|
|
301
314
|
should "raises signal exceptions in the context setup" do
|
302
|
-
test = Factory.test("setup signal test", context_info1){
|
315
|
+
test = Factory.test("setup signal test", context_info1){}
|
303
316
|
test.context_class.setup{ raise SignalException, "INT" }
|
304
317
|
|
305
|
-
assert_that
|
318
|
+
assert_that{ test.run }.raises(SignalException)
|
306
319
|
end
|
307
320
|
|
308
321
|
should "raises signal exceptions in the context teardown" do
|
309
|
-
test = Factory.test("teardown signal test", context_info1){
|
322
|
+
test = Factory.test("teardown signal test", context_info1){}
|
310
323
|
test.context_class.teardown{ raise SignalException, "TERM" }
|
311
324
|
|
312
|
-
assert_that
|
325
|
+
assert_that{ test.run }.raises(SignalException)
|
313
326
|
end
|
314
327
|
end
|
315
328
|
|
316
329
|
class ComparingTests < UnitTests
|
317
330
|
desc "<=> another test"
|
318
|
-
subject
|
331
|
+
subject{ Factory.test("mmm") }
|
319
332
|
|
320
333
|
should "return 1 with a test named 'aaa' (greater than it)" do
|
321
334
|
assert_that(subject <=> Factory.test("aaa")).equals(1)
|
@@ -332,14 +345,14 @@ class Assert::Test
|
|
332
345
|
|
333
346
|
class CaptureOutTests < UnitTests
|
334
347
|
desc "when capturing std out"
|
335
|
-
subject
|
348
|
+
subject do
|
336
349
|
Factory.test("stdout", capture_config1) do
|
337
350
|
puts "std out from the test"
|
338
351
|
assert true
|
339
352
|
end
|
340
|
-
|
353
|
+
end
|
341
354
|
|
342
|
-
let(:capture_config1)
|
355
|
+
let(:capture_config1){ Assert::Config.new(capture_output: true) }
|
343
356
|
|
344
357
|
should "capture any io from the test" do
|
345
358
|
subject.run
|
@@ -349,12 +362,12 @@ class Assert::Test
|
|
349
362
|
|
350
363
|
class FullCaptureOutTests < CaptureOutTests
|
351
364
|
desc "across setup, teardown, and meth calls"
|
352
|
-
subject
|
365
|
+
subject do
|
353
366
|
Factory.test("fullstdouttest", capture_config1) do
|
354
367
|
puts "std out from the test"
|
355
368
|
assert a_method_an_assert_calls
|
356
369
|
end
|
357
|
-
|
370
|
+
end
|
358
371
|
|
359
372
|
setup do
|
360
373
|
subject.context_class.setup{ puts "std out from the setup" }
|
data/test/unit/utils_tests.rb
CHANGED
@@ -9,37 +9,40 @@ require "assert/config"
|
|
9
9
|
module Assert::Utils
|
10
10
|
class UnitTests < Assert::Context
|
11
11
|
desc "Assert::Utils"
|
12
|
-
subject
|
12
|
+
subject{ unit_class }
|
13
13
|
|
14
|
-
let(:unit_class)
|
14
|
+
let(:unit_class){ Assert::Utils }
|
15
15
|
|
16
|
-
let(:objs1)
|
16
|
+
let(:objs1){ [1, "hi there", {}, [:a, :b]] }
|
17
17
|
|
18
18
|
should have_imeths :show, :show_for_diff
|
19
19
|
should have_imeths :tempfile
|
20
|
-
should have_imeths :stdlib_pp_proc, :default_use_diff_proc
|
20
|
+
should have_imeths :stdlib_pp_proc, :default_use_diff_proc
|
21
|
+
should have_imeths :syscmd_diff_proc
|
21
22
|
should have_imeths :git_changed_proc
|
22
23
|
end
|
23
24
|
|
24
25
|
class ShowTests < UnitTests
|
25
26
|
desc "`show`"
|
26
27
|
|
27
|
-
let(:pp_config1)
|
28
|
+
let(:pp_config1) do
|
28
29
|
Assert::Config.new({
|
29
|
-
:
|
30
|
-
:
|
30
|
+
pp_objects: true,
|
31
|
+
pp_proc: Proc.new{ |_input| "herp derp" },
|
31
32
|
})
|
32
|
-
|
33
|
+
end
|
33
34
|
|
34
35
|
should "use `inspect` to show objs when `pp_objects` setting is false" do
|
35
36
|
objs1.each do |obj|
|
36
|
-
assert_that(subject.show(obj, Factory.modes_off_config))
|
37
|
+
assert_that(subject.show(obj, Factory.modes_off_config))
|
38
|
+
.equals(obj.inspect)
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
42
|
should "use `pp_proc` to show objs when `pp_objects` setting is true" do
|
41
43
|
objs1.each do |obj|
|
42
|
-
assert_that(subject.show(obj, pp_config1))
|
44
|
+
assert_that(subject.show(obj, pp_config1))
|
45
|
+
.equals(pp_config1.pp_proc.call(obj))
|
43
46
|
end
|
44
47
|
end
|
45
48
|
end
|
@@ -47,24 +50,27 @@ module Assert::Utils
|
|
47
50
|
class ShowForDiffTests < ShowTests
|
48
51
|
desc "`show_for_diff`"
|
49
52
|
|
50
|
-
let(:w_newlines1)
|
51
|
-
let(:w_obj_id1)
|
53
|
+
let(:w_newlines1){ { string: "herp derp, derp herp\nherpderpedia" } }
|
54
|
+
let(:w_obj_id1){ Class.new.new }
|
52
55
|
|
53
56
|
should "call show, escaping newlines" do
|
54
57
|
exp_out = "{:string=>\"herp derp, derp herp\nherpderpedia\"}"
|
55
|
-
assert_that(subject.show_for_diff(w_newlines1, Factory.modes_off_config))
|
58
|
+
assert_that(subject.show_for_diff(w_newlines1, Factory.modes_off_config))
|
59
|
+
.equals(exp_out)
|
56
60
|
end
|
57
61
|
|
58
62
|
should "make any obj ids generic" do
|
59
63
|
exp_out = "#<#<Class:0xXXXXXX>:0xXXXXXX>"
|
60
|
-
assert_that(subject.show_for_diff(w_obj_id1, Factory.modes_off_config))
|
64
|
+
assert_that(subject.show_for_diff(w_obj_id1, Factory.modes_off_config))
|
65
|
+
.equals(exp_out)
|
61
66
|
end
|
62
67
|
end
|
63
68
|
|
64
69
|
class TempfileTests < UnitTests
|
65
70
|
desc "`tempfile`"
|
66
71
|
|
67
|
-
should "require tempfile, open a tempfile, write the given content,
|
72
|
+
should "require tempfile, open a tempfile, write the given content, "\
|
73
|
+
"and yield it" do
|
68
74
|
subject.tempfile("a-name", "some-content") do |tmpfile|
|
69
75
|
assert_that((require "tempfile")).equals(false)
|
70
76
|
assert tmpfile
|
@@ -94,8 +100,10 @@ module Assert::Utils
|
|
94
100
|
class DefaultUseDiffProcTests < UnitTests
|
95
101
|
desc "`default_use_diff_proc`"
|
96
102
|
|
97
|
-
let(:longer1)
|
98
|
-
|
103
|
+
let(:longer1) do
|
104
|
+
"i am a really long string output; use diff when working with me"
|
105
|
+
end
|
106
|
+
let(:newlines1){ "i have\n newlines" }
|
99
107
|
|
100
108
|
should "be true if either output has newlines or is bigger than 29 chars" do
|
101
109
|
proc = subject.default_use_diff_proc
|
@@ -112,28 +120,33 @@ module Assert::Utils
|
|
112
120
|
class SyscmdDiffProc < UnitTests
|
113
121
|
desc "`syscmd_diff_proc`"
|
114
122
|
|
115
|
-
let(:diff_a_file1)
|
116
|
-
let(:diff_b_file1)
|
117
|
-
let(:diff_a1)
|
118
|
-
let(:diff_b1)
|
119
|
-
|
120
|
-
should "use the diff syscmd to output the diff between the exp/act
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
let(:diff_a_file1){ File.join(ROOT_PATH, "test/support/diff_a.txt") }
|
124
|
+
let(:diff_b_file1){ File.join(ROOT_PATH, "test/support/diff_b.txt") }
|
125
|
+
let(:diff_a1){ File.read(diff_a_file1) }
|
126
|
+
let(:diff_b1){ File.read(diff_b_file1) }
|
127
|
+
|
128
|
+
should "use the diff syscmd to output the diff between the exp/act "\
|
129
|
+
"show output" do
|
130
|
+
exp_diff_out =
|
131
|
+
`diff --unified=-1 #{diff_a_file1} #{diff_b_file1}`.strip.tap do |out|
|
132
|
+
out.sub!(/^\-\-\- .+/, "--- expected")
|
133
|
+
out.sub!(/^\+\+\+ .+/, "+++ actual")
|
134
|
+
end
|
135
|
+
|
136
|
+
assert_that(subject.syscmd_diff_proc.call(diff_a1, diff_b1))
|
137
|
+
.equals(exp_diff_out)
|
127
138
|
end
|
128
139
|
|
129
140
|
should "allow you to specify a custom syscmd" do
|
130
141
|
cust_syscmd = "diff"
|
131
|
-
exp_diff_out =
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
142
|
+
exp_diff_out =
|
143
|
+
`#{cust_syscmd} #{diff_a_file1} #{diff_b_file1}`.strip.tap do |out|
|
144
|
+
out.sub!(/^\-\-\- .+/, "--- expected")
|
145
|
+
out.sub!(/^\+\+\+ .+/, "+++ actual")
|
146
|
+
end
|
147
|
+
|
148
|
+
assert_that(subject.syscmd_diff_proc(cust_syscmd).call(diff_a1, diff_b1))
|
149
|
+
.equals(exp_diff_out)
|
137
150
|
end
|
138
151
|
end
|
139
152
|
end
|