assert 2.19.0 → 2.19.5
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/Gemfile +4 -2
- data/assert.gemspec +11 -6
- data/bin/assert +1 -0
- data/lib/assert.rb +20 -6
- data/lib/assert/actual_value.rb +11 -6
- data/lib/assert/assert_runner.rb +38 -17
- data/lib/assert/assertions.rb +85 -50
- data/lib/assert/cli.rb +32 -70
- 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 +16 -18
- 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 +114 -62
- data/lib/assert/runner.rb +70 -51
- data/lib/assert/stub.rb +44 -3
- data/lib/assert/suite.rb +69 -28
- data/lib/assert/test.rb +43 -36
- 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 +71 -50
- data/test/unit/assert_tests.rb +42 -23
- data/test/unit/assertions/assert_block_tests.rb +12 -10
- data/test/unit/assertions/assert_changes_tests.rb +27 -21
- data/test/unit/assertions/assert_empty_tests.rb +16 -12
- data/test/unit/assertions/assert_equal_tests.rb +28 -26
- 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 +29 -20
- 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 +16 -9
- data/test/unit/config_helpers_tests.rb +17 -10
- 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 +39 -17
- 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 +39 -15
- data/test/unit/test_tests.rb +65 -50
- 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 +26 -11
- data/test/unit/assertions/assert_kind_of_tests.rb +0 -66
data/test/unit/macro_tests.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/macro"
|
3
5
|
|
4
6
|
class Assert::Macro
|
5
7
|
class UnitTests < Assert::Context
|
6
8
|
desc "Assert::Macro"
|
7
|
-
subject
|
9
|
+
subject{ unit_class }
|
8
10
|
|
9
|
-
let(:unit_class)
|
11
|
+
let(:unit_class){ Assert::Macro }
|
10
12
|
end
|
11
13
|
|
12
14
|
class InitTests < UnitTests
|
13
15
|
desc "when init"
|
14
|
-
subject
|
16
|
+
subject{ unit_class.new{} }
|
15
17
|
|
16
18
|
should "have an accessor for its (optional) name" do
|
17
19
|
assert_that(subject).responds_to(:name)
|
@@ -19,11 +21,11 @@ class Assert::Macro
|
|
19
21
|
end
|
20
22
|
|
21
23
|
should "default its name if no given" do
|
22
|
-
assert_that((unit_class.new
|
24
|
+
assert_that((unit_class.new{}).name).equals("run this macro")
|
23
25
|
end
|
24
26
|
|
25
27
|
should "initialize with a given name" do
|
26
|
-
assert_that((unit_class.new("test")
|
28
|
+
assert_that((unit_class.new("test"){}).name).equals("test")
|
27
29
|
end
|
28
30
|
|
29
31
|
should "be a Proc" do
|
@@ -31,7 +33,7 @@ class Assert::Macro
|
|
31
33
|
end
|
32
34
|
|
33
35
|
should "complain if you create a macro without a block" do
|
34
|
-
assert_that
|
36
|
+
assert_that{ unit_class.new }.raises(ArgumentError)
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
@@ -39,7 +41,7 @@ class Assert::Macro
|
|
39
41
|
desc "have_instance_methods macro: this class"
|
40
42
|
subject do
|
41
43
|
class ::InstExample
|
42
|
-
(1..6).each
|
44
|
+
(1..6).each{ |i| define_method("method_#{i}"){} }
|
43
45
|
end
|
44
46
|
::InstExample.new
|
45
47
|
end
|
@@ -60,7 +62,7 @@ class Assert::Macro
|
|
60
62
|
subject do
|
61
63
|
class ::ClassExample
|
62
64
|
class << self
|
63
|
-
(1..6).each
|
65
|
+
(1..6).each{ |i| define_method("method_#{i}"){} }
|
64
66
|
end
|
65
67
|
end
|
66
68
|
::ClassExample.new
|
@@ -81,7 +83,7 @@ class Assert::Macro
|
|
81
83
|
desc "have_readers macro: this class"
|
82
84
|
subject do
|
83
85
|
class ::ReaderExample
|
84
|
-
(1..6).each
|
86
|
+
(1..6).each{ |i| attr_reader "method_#{i}" }
|
85
87
|
end
|
86
88
|
::ReaderExample.new
|
87
89
|
end
|
@@ -101,7 +103,7 @@ class Assert::Macro
|
|
101
103
|
desc "have_writers macro: this class"
|
102
104
|
subject do
|
103
105
|
class ::WriterExample
|
104
|
-
(1..6).each
|
106
|
+
(1..6).each{ |i| attr_writer "method_#{i}" }
|
105
107
|
end
|
106
108
|
::WriterExample.new
|
107
109
|
end
|
@@ -121,7 +123,7 @@ class Assert::Macro
|
|
121
123
|
desc "have_accessors macro: this class"
|
122
124
|
subject do
|
123
125
|
class ::AccessorExample
|
124
|
-
(1..6).each
|
126
|
+
(1..6).each{ |i| attr_accessor "method_#{i}" }
|
125
127
|
end
|
126
128
|
::AccessorExample.new
|
127
129
|
end
|
data/test/unit/result_tests.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/result"
|
3
5
|
|
@@ -6,22 +8,23 @@ require "assert/file_line"
|
|
6
8
|
module Assert::Result
|
7
9
|
class UnitTests < Assert::Context
|
8
10
|
desc "Assert::Result"
|
9
|
-
subject
|
11
|
+
subject{ unit_class }
|
10
12
|
|
11
|
-
let(:unit_class)
|
13
|
+
let(:unit_class){ Assert::Result }
|
12
14
|
|
13
|
-
let(:test1)
|
15
|
+
let(:test1){ Factory.test("a test name") }
|
14
16
|
|
15
17
|
should have_imeths :types, :new
|
16
18
|
|
17
19
|
should "know its types" do
|
18
|
-
exp =
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
exp =
|
21
|
+
{
|
22
|
+
pass: Pass,
|
23
|
+
fail: Fail,
|
24
|
+
ignore: Ignore,
|
25
|
+
skip: Skip,
|
26
|
+
error: Error,
|
27
|
+
}
|
25
28
|
assert_that(subject.types).equals(exp)
|
26
29
|
|
27
30
|
assert_that(subject.types[Factory.string]).equals(Base)
|
@@ -29,26 +32,26 @@ module Assert::Result
|
|
29
32
|
|
30
33
|
should "create results from data hashes" do
|
31
34
|
type = Assert::Result.types.keys.sample
|
32
|
-
exp = Assert::Result.types[type].new(:
|
33
|
-
assert_that(Assert::Result.new(:
|
35
|
+
exp = Assert::Result.types[type].new(type: type)
|
36
|
+
assert_that(Assert::Result.new(type: type)).equals(exp)
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
37
40
|
class InitBaseTests < UnitTests
|
38
41
|
desc "Base when init"
|
39
|
-
subject
|
42
|
+
subject{ Base.new(given_data1) }
|
40
43
|
|
41
|
-
let(:given_data1)
|
44
|
+
let(:given_data1) do
|
42
45
|
{
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
46
|
+
type: Factory.string,
|
47
|
+
name: Factory.string,
|
48
|
+
test_name: Factory.string,
|
49
|
+
test_file_line: Assert::FileLine.new(Factory.string, Factory.integer),
|
50
|
+
message: Factory.string,
|
51
|
+
output: Factory.text,
|
52
|
+
backtrace: Backtrace.new(Factory.backtrace),
|
50
53
|
}
|
51
|
-
|
54
|
+
end
|
52
55
|
|
53
56
|
should have_cmeths :type, :name, :for_test
|
54
57
|
should have_imeths :type, :name, :test_name, :test_file_line
|
@@ -122,10 +125,11 @@ module Assert::Result
|
|
122
125
|
assert_that(subject.trace).equals(exp_trace)
|
123
126
|
|
124
127
|
# test that the first bt line is used if filtered is empty
|
125
|
-
assert_lib_path =
|
126
|
-
|
127
|
-
|
128
|
-
|
128
|
+
assert_lib_path =
|
129
|
+
File.join(ROOT_PATH, "lib/#{Factory.string}:#{Factory.integer}")
|
130
|
+
new_bt = (Factory.integer(3) + 1).times.map{ assert_lib_path }
|
131
|
+
exp_backtrace = Backtrace.new(new_bt)
|
132
|
+
exp_trace = exp_backtrace.first.to_s
|
129
133
|
subject.set_backtrace(new_bt)
|
130
134
|
assert_that(subject.backtrace).equals(exp_backtrace)
|
131
135
|
assert_that(subject.trace).equals(exp_trace)
|
@@ -169,8 +173,9 @@ module Assert::Result
|
|
169
173
|
assert_that(subject.line_num).equals(exp.line.to_i)
|
170
174
|
|
171
175
|
# test that the first bt line is used if filtered is empty
|
172
|
-
assert_lib_path =
|
173
|
-
|
176
|
+
assert_lib_path =
|
177
|
+
File.join(ROOT_PATH, "lib/#{Factory.string}:#{Factory.integer}")
|
178
|
+
new_bt = (Factory.integer(3) + 1).times.map{ assert_lib_path }
|
174
179
|
subject.set_backtrace(new_bt)
|
175
180
|
|
176
181
|
exp = new_bt.first.to_s
|
@@ -229,7 +234,7 @@ module Assert::Result
|
|
229
234
|
|
230
235
|
class InitPassTests < UnitTests
|
231
236
|
desc "Pass when init"
|
232
|
-
subject
|
237
|
+
subject{ Pass.new({}) }
|
233
238
|
|
234
239
|
should "know its type/name" do
|
235
240
|
assert_that(subject.type).equals(:pass)
|
@@ -240,7 +245,7 @@ module Assert::Result
|
|
240
245
|
|
241
246
|
class InitIgnoreTests < UnitTests
|
242
247
|
desc "Ignore when init"
|
243
|
-
subject
|
248
|
+
subject{ Ignore.new({}) }
|
244
249
|
|
245
250
|
should "know its type/name" do
|
246
251
|
assert_that(subject.type).equals(:ignore)
|
@@ -251,7 +256,7 @@ module Assert::Result
|
|
251
256
|
|
252
257
|
class InitHaltingTestResultErrorTests < UnitTests
|
253
258
|
desc "HaltingTestResultError when init"
|
254
|
-
subject
|
259
|
+
subject{ HaltingTestResultError.new }
|
255
260
|
|
256
261
|
should have_accessors :assert_with_bt
|
257
262
|
|
@@ -262,7 +267,7 @@ module Assert::Result
|
|
262
267
|
|
263
268
|
class InitTestFailureTests < UnitTests
|
264
269
|
desc "TestFailure when init"
|
265
|
-
subject
|
270
|
+
subject{ TestFailure.new }
|
266
271
|
|
267
272
|
should "be a halting test result error" do
|
268
273
|
assert_that(subject).is_kind_of(HaltingTestResultError)
|
@@ -271,7 +276,7 @@ module Assert::Result
|
|
271
276
|
|
272
277
|
class InitFailTests < UnitTests
|
273
278
|
desc "Fail when init"
|
274
|
-
subject
|
279
|
+
subject{ Fail.new({}) }
|
275
280
|
|
276
281
|
should "know its type/name" do
|
277
282
|
assert_that(subject.type).equals(:fail)
|
@@ -302,13 +307,14 @@ module Assert::Result
|
|
302
307
|
end
|
303
308
|
|
304
309
|
should "not allow creating for a test with non-TestFailure exceptions" do
|
305
|
-
assert_that
|
310
|
+
assert_that{ Fail.for_test(test1, RuntimeError.new) }
|
311
|
+
.raises(ArgumentError)
|
306
312
|
end
|
307
313
|
end
|
308
314
|
|
309
315
|
class InitTestSkippedTests < UnitTests
|
310
316
|
desc "TestSkipped when init"
|
311
|
-
subject
|
317
|
+
subject{ TestSkipped.new }
|
312
318
|
|
313
319
|
should "be a halting test result error" do
|
314
320
|
assert_that(subject).is_kind_of(HaltingTestResultError)
|
@@ -317,7 +323,7 @@ module Assert::Result
|
|
317
323
|
|
318
324
|
class InitSkipTests < UnitTests
|
319
325
|
desc "Skip when init"
|
320
|
-
subject
|
326
|
+
subject{ Skip.new({}) }
|
321
327
|
|
322
328
|
should "know its type/name" do
|
323
329
|
assert_that(subject.type).equals(:skip)
|
@@ -348,13 +354,14 @@ module Assert::Result
|
|
348
354
|
end
|
349
355
|
|
350
356
|
should "not allow creating for a test with non-TestSkipped exceptions" do
|
351
|
-
assert_that
|
357
|
+
assert_that{ Skip.for_test(test1, RuntimeError.new) }
|
358
|
+
.raises(ArgumentError)
|
352
359
|
end
|
353
360
|
end
|
354
361
|
|
355
362
|
class InitErrorTests < UnitTests
|
356
363
|
desc "Error when init"
|
357
|
-
subject
|
364
|
+
subject{ Error.new({}) }
|
358
365
|
|
359
366
|
should "know its class-level type/name" do
|
360
367
|
assert_that(subject.class.type).equals(:error)
|
@@ -375,13 +382,13 @@ module Assert::Result
|
|
375
382
|
end
|
376
383
|
|
377
384
|
should "not allow creating for a test without an exception" do
|
378
|
-
assert_that
|
385
|
+
assert_that{ Error.for_test(test1, Factory.string) }.raises(ArgumentError)
|
379
386
|
end
|
380
387
|
end
|
381
388
|
|
382
389
|
class InitBacktraceTests < UnitTests
|
383
390
|
desc "Backtrace when init"
|
384
|
-
subject
|
391
|
+
subject{ Backtrace.new(Factory.backtrace) }
|
385
392
|
|
386
393
|
should have_cmeths :parse, :to_s
|
387
394
|
should have_imeths :filtered
|
@@ -391,7 +398,8 @@ module Assert::Result
|
|
391
398
|
end
|
392
399
|
|
393
400
|
should "render as a string by joining on the newline" do
|
394
|
-
assert_that(Backtrace.to_s(subject))
|
401
|
+
assert_that(Backtrace.to_s(subject))
|
402
|
+
.equals(subject.join(Backtrace::DELIM))
|
395
403
|
end
|
396
404
|
|
397
405
|
should "be an Array" do
|
data/test/unit/runner_tests.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/runner"
|
3
5
|
|
@@ -10,9 +12,9 @@ require "assert/view"
|
|
10
12
|
class Assert::Runner
|
11
13
|
class UnitTests < Assert::Context
|
12
14
|
desc "Assert::Runner"
|
13
|
-
subject
|
15
|
+
subject{ unit_class }
|
14
16
|
|
15
|
-
let(:unit_class)
|
17
|
+
let(:unit_class){ Assert::Runner }
|
16
18
|
|
17
19
|
should "include the config helpers" do
|
18
20
|
assert_that(subject).includes(Assert::ConfigHelpers)
|
@@ -21,14 +23,14 @@ class Assert::Runner
|
|
21
23
|
|
22
24
|
class InitTests < UnitTests
|
23
25
|
desc "when init"
|
24
|
-
subject
|
26
|
+
subject{ unit_class.new(config1) }
|
25
27
|
|
26
28
|
setup do
|
27
29
|
config1.suite Assert::DefaultSuite.new(config1)
|
28
|
-
config1.view Assert::View.new(config1, StringIO.new("", "w+"))
|
30
|
+
config1.view Assert::View.new(config1, StringIO.new(+"", "w+"))
|
29
31
|
end
|
30
32
|
|
31
|
-
let(:config1)
|
33
|
+
let(:config1){ Factory.modes_off_config }
|
32
34
|
|
33
35
|
should have_readers :config
|
34
36
|
should have_imeths :runner, :run
|
@@ -47,10 +49,10 @@ class Assert::Runner
|
|
47
49
|
|
48
50
|
class RunTests < InitTests
|
49
51
|
desc "and run"
|
50
|
-
subject
|
52
|
+
subject{ runner_class1.new(config1) }
|
51
53
|
|
52
54
|
setup do
|
53
|
-
@view_output = ""
|
55
|
+
@view_output = +""
|
54
56
|
|
55
57
|
suite_class = Class.new(Assert::DefaultSuite){ include CallbackMixin }
|
56
58
|
view_class = Class.new(Assert::View){ include CallbackMixin }
|
@@ -62,9 +64,13 @@ class Assert::Runner
|
|
62
64
|
@result_count = subject.run
|
63
65
|
end
|
64
66
|
|
65
|
-
let(:runner_class1)
|
66
|
-
|
67
|
-
|
67
|
+
let(:runner_class1) do
|
68
|
+
Class.new(unit_class){ include CallbackMixin }
|
69
|
+
end
|
70
|
+
let(:ci1){ Factory.context_info(Factory.modes_off_context_class) }
|
71
|
+
# rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
|
72
|
+
let(:test1){ Factory.test("should pass", ci1){ assert(1 == 1) } }
|
73
|
+
# rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
|
68
74
|
|
69
75
|
should "return the fail+error result count as an integer exit code" do
|
70
76
|
assert_that(@result_count).equals(0)
|
@@ -73,7 +79,7 @@ class Assert::Runner
|
|
73
79
|
error_count = Factory.integer
|
74
80
|
Assert.stub(subject, :fail_result_count){ fail_count }
|
75
81
|
Assert.stub(subject, :error_result_count){ error_count }
|
76
|
-
Assert.stub(test1, :run){
|
82
|
+
Assert.stub(test1, :run){} # no-op
|
77
83
|
result_count = subject.run
|
78
84
|
|
79
85
|
assert_that(result_count).equals(fail_count + error_count)
|
@@ -83,7 +89,8 @@ class Assert::Runner
|
|
83
89
|
# itself
|
84
90
|
assert_that(subject.on_start_called).is_true
|
85
91
|
assert_that(subject.before_test_called).equals([test1])
|
86
|
-
assert_that(subject.on_result_called.last)
|
92
|
+
assert_that(subject.on_result_called.last)
|
93
|
+
.is_instance_of(Assert::Result::Pass)
|
87
94
|
assert_that(subject.after_test_called).equals([test1])
|
88
95
|
assert_that(subject.on_finish_called).is_true
|
89
96
|
|
@@ -91,7 +98,8 @@ class Assert::Runner
|
|
91
98
|
suite = config1.suite
|
92
99
|
assert_that(suite.on_start_called).is_true
|
93
100
|
assert_that(suite.before_test_called).equals([test1])
|
94
|
-
assert_that(suite.on_result_called.last)
|
101
|
+
assert_that(suite.on_result_called.last)
|
102
|
+
.is_instance_of(Assert::Result::Pass)
|
95
103
|
assert_that(suite.after_test_called).equals([test1])
|
96
104
|
assert_that(suite.on_finish_called).is_true
|
97
105
|
|
@@ -99,7 +107,8 @@ class Assert::Runner
|
|
99
107
|
view = config1.view
|
100
108
|
assert_that(view.on_start_called).is_true
|
101
109
|
assert_that(view.before_test_called).equals([test1])
|
102
|
-
assert_that(view.on_result_called.last)
|
110
|
+
assert_that(view.on_result_called.last)
|
111
|
+
.is_instance_of(Assert::Result::Pass)
|
103
112
|
assert_that(view.after_test_called).equals([test1])
|
104
113
|
assert_that(view.on_finish_called).is_true
|
105
114
|
end
|
@@ -116,7 +125,9 @@ class Assert::Runner
|
|
116
125
|
end
|
117
126
|
|
118
127
|
should "run only a single test if a single test is configured" do
|
119
|
-
|
128
|
+
# rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
|
129
|
+
test = Factory.test("should pass", ci1){ assert(1 == 1) }
|
130
|
+
# rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
|
120
131
|
config1.suite.clear_tests_to_run
|
121
132
|
config1.suite.on_test(test)
|
122
133
|
config1.single_test test.file_line.to_s
|
@@ -125,8 +136,11 @@ class Assert::Runner
|
|
125
136
|
assert_that(runner.before_test_called).equals([test])
|
126
137
|
end
|
127
138
|
|
128
|
-
should "not run any tests if a single test is configured but
|
129
|
-
|
139
|
+
should "not run any tests if a single test is configured but "\
|
140
|
+
"can't be found" do
|
141
|
+
# rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
|
142
|
+
test = Factory.test("should pass", ci1){ assert(1 == 1) }
|
143
|
+
# rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
|
130
144
|
config1.suite.clear_tests_to_run
|
131
145
|
config1.suite.on_test(test)
|
132
146
|
config1.single_test Factory.string
|
@@ -135,7 +149,8 @@ class Assert::Runner
|
|
135
149
|
assert_that(runner.before_test_called).is_nil
|
136
150
|
end
|
137
151
|
|
138
|
-
should "describe running only a single test if a single test is
|
152
|
+
should "describe running only a single test if a single test is "\
|
153
|
+
"configured" do
|
139
154
|
config1.suite.clear_tests_to_run
|
140
155
|
config1.suite.on_test(test1)
|
141
156
|
config1.single_test test1.file_line.to_s
|
data/test/unit/suite_tests.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/suite"
|
3
5
|
|
@@ -8,9 +10,9 @@ require "test/support/inherited_stuff"
|
|
8
10
|
class Assert::Suite
|
9
11
|
class UnitTests < Assert::Context
|
10
12
|
desc "Assert::Suite"
|
11
|
-
subject
|
13
|
+
subject{ unit_class }
|
12
14
|
|
13
|
-
let(:unit_class)
|
15
|
+
let(:unit_class){ Assert::Suite }
|
14
16
|
|
15
17
|
should "include the config helpers" do
|
16
18
|
assert_that(subject).includes(Assert::ConfigHelpers)
|
@@ -19,9 +21,9 @@ class Assert::Suite
|
|
19
21
|
|
20
22
|
class InitTests < UnitTests
|
21
23
|
desc "when init"
|
22
|
-
subject
|
24
|
+
subject{ unit_class.new(config1) }
|
23
25
|
|
24
|
-
let(:config1)
|
26
|
+
let(:config1){ Factory.modes_off_config }
|
25
27
|
|
26
28
|
should have_readers :config, :setups, :teardowns
|
27
29
|
should have_accessors :start_time, :end_time
|
@@ -72,8 +74,10 @@ class Assert::Suite
|
|
72
74
|
Assert.stub(subject, :result_count){ count }
|
73
75
|
|
74
76
|
assert_that(subject.run_time).equals(time)
|
75
|
-
assert_that(subject.test_rate)
|
76
|
-
|
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))
|
77
81
|
end
|
78
82
|
|
79
83
|
should "add setup procs" do
|
@@ -104,17 +108,37 @@ class Assert::Suite
|
|
104
108
|
tests1.each{ |test| subject.on_test(test) }
|
105
109
|
end
|
106
110
|
|
107
|
-
let(:ci1)
|
108
|
-
let(:tests1)
|
111
|
+
let(:ci1){ proc{ Factory.context_info(Factory.modes_off_context_class) } }
|
112
|
+
let(:tests1) do
|
113
|
+
# rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
|
109
114
|
[
|
110
|
-
Factory.test("should nothing", ci1.call)
|
111
|
-
|
112
|
-
Factory.test("should
|
113
|
-
|
114
|
-
|
115
|
-
|
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,
|
116
139
|
]
|
117
|
-
|
140
|
+
# rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
|
141
|
+
end
|
118
142
|
|
119
143
|
should "know its tests-to-run attrs" do
|
120
144
|
assert_that(subject.tests_to_run_count).equals(tests1.size)
|