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