assert 2.19.1 → 2.19.6
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -10,17 +10,17 @@ module Assert::Assertions
|
|
10
10
|
include Assert::Test::TestHelpers
|
11
11
|
|
12
12
|
desc "`assert_respond_to`"
|
13
|
-
subject
|
13
|
+
subject do
|
14
14
|
args = args1
|
15
15
|
Factory.test do
|
16
16
|
assert_respond_to(:abs, 1) # pass
|
17
17
|
assert_respond_to(*args) # fail
|
18
18
|
end
|
19
|
-
|
19
|
+
end
|
20
20
|
|
21
|
-
let(:desc1)
|
22
|
-
let(:args1)
|
23
|
-
let(:config1)
|
21
|
+
let(:desc1){ "assert respond to fail desc" }
|
22
|
+
let(:args1){ [:abs, "1", desc1] }
|
23
|
+
let(:config1){ subject.config }
|
24
24
|
|
25
25
|
should "produce results as expected" do
|
26
26
|
subject.run(&test_run_callback)
|
@@ -41,17 +41,17 @@ module Assert::Assertions
|
|
41
41
|
include Assert::Test::TestHelpers
|
42
42
|
|
43
43
|
desc "`assert_not_respond_to`"
|
44
|
-
subject
|
44
|
+
subject do
|
45
45
|
args = args1
|
46
46
|
Factory.test do
|
47
47
|
assert_not_respond_to(*args) # fail
|
48
48
|
assert_not_respond_to(:abs, "1") # pass
|
49
49
|
end
|
50
|
-
|
50
|
+
end
|
51
51
|
|
52
|
-
let(:desc1)
|
53
|
-
let(:args1)
|
54
|
-
let(:config1)
|
52
|
+
let(:desc1){ "assert not respond to fail desc" }
|
53
|
+
let(:args1){ [:abs, 1, desc1] }
|
54
|
+
let(:config1){ subject.config }
|
55
55
|
|
56
56
|
should "produce results as expected" do
|
57
57
|
subject.run(&test_run_callback)
|
@@ -10,20 +10,20 @@ module Assert::Assertions
|
|
10
10
|
include Assert::Test::TestHelpers
|
11
11
|
|
12
12
|
desc "`assert_same`"
|
13
|
-
subject
|
13
|
+
subject do
|
14
14
|
args = args1
|
15
15
|
object = object1
|
16
16
|
Factory.test do
|
17
17
|
assert_same(object, object) # pass
|
18
18
|
assert_same(*args) # fail
|
19
19
|
end
|
20
|
-
|
20
|
+
end
|
21
21
|
|
22
|
-
let(:class1)
|
23
|
-
let(:object1)
|
24
|
-
let(:desc1)
|
25
|
-
let(:args1)
|
26
|
-
let(:config1)
|
22
|
+
let(:class1){ Class.new }
|
23
|
+
let(:object1){ class1.new }
|
24
|
+
let(:desc1){ "assert same fail desc" }
|
25
|
+
let(:args1){ [object1, class1.new, desc1] }
|
26
|
+
let(:config1){ subject.config }
|
27
27
|
|
28
28
|
should "produce results as expected" do
|
29
29
|
subject.run(&test_run_callback)
|
@@ -46,7 +46,7 @@ module Assert::Assertions
|
|
46
46
|
include Assert::Test::TestHelpers
|
47
47
|
|
48
48
|
desc "`assert_not_same`"
|
49
|
-
subject
|
49
|
+
subject do
|
50
50
|
args = args1
|
51
51
|
object = object1
|
52
52
|
klass = class1
|
@@ -54,13 +54,13 @@ module Assert::Assertions
|
|
54
54
|
assert_not_same(*args) # fail
|
55
55
|
assert_not_same(object, klass.new) # pass
|
56
56
|
end
|
57
|
-
|
57
|
+
end
|
58
58
|
|
59
|
-
let(:class1)
|
60
|
-
let(:object1)
|
61
|
-
let(:desc1)
|
62
|
-
let(:args1)
|
63
|
-
let(:config1)
|
59
|
+
let(:class1){ Class.new }
|
60
|
+
let(:object1){ class1.new }
|
61
|
+
let(:desc1){ "assert not same fail desc" }
|
62
|
+
let(:args1){ [object1, object1, desc1] }
|
63
|
+
let(:config1){ subject.config }
|
64
64
|
|
65
65
|
should "produce results as expected" do
|
66
66
|
subject.run(&test_run_callback)
|
@@ -83,27 +83,27 @@ module Assert::Assertions
|
|
83
83
|
include Assert::Test::TestHelpers
|
84
84
|
|
85
85
|
desc "with objects that should use diff when showing"
|
86
|
-
let(:config1)
|
86
|
+
let(:config1) do
|
87
87
|
Factory.modes_off_config.tap do |config|
|
88
88
|
config.use_diff_proc(Assert::U.default_use_diff_proc)
|
89
89
|
config.run_diff_proc(Assert::U.syscmd_diff_proc)
|
90
90
|
end
|
91
|
-
|
91
|
+
end
|
92
92
|
|
93
|
-
let(:exp_obj1)
|
94
|
-
let(:act_obj1)
|
95
|
-
let(:exp_obj_show1)
|
96
|
-
let(:act_obj_show1)
|
93
|
+
let(:exp_obj1){ "I'm a\nstring" }
|
94
|
+
let(:act_obj1){ "I am a \nstring" }
|
95
|
+
let(:exp_obj_show1){ Assert::U.show_for_diff(exp_obj1, config1) }
|
96
|
+
let(:act_obj_show1){ Assert::U.show_for_diff(act_obj1, config1) }
|
97
97
|
end
|
98
98
|
|
99
99
|
class AssertSameDiffTests < DiffTests
|
100
100
|
desc "`assert_same`"
|
101
|
-
subject
|
101
|
+
subject do
|
102
102
|
exp_obj, act_obj = exp_obj1, act_obj1
|
103
103
|
Factory.test(config1) do
|
104
104
|
assert_same(exp_obj, act_obj)
|
105
105
|
end
|
106
|
-
|
106
|
+
end
|
107
107
|
|
108
108
|
should "include diff output in the fail messages" do
|
109
109
|
subject.run(&test_run_callback)
|
@@ -120,12 +120,12 @@ module Assert::Assertions
|
|
120
120
|
|
121
121
|
class AssertNotSameDiffTests < DiffTests
|
122
122
|
desc "`assert_not_same`"
|
123
|
-
subject
|
123
|
+
subject do
|
124
124
|
act_obj = act_obj1
|
125
125
|
Factory.test(config1) do
|
126
126
|
assert_not_same(act_obj, act_obj)
|
127
127
|
end
|
128
|
-
|
128
|
+
end
|
129
129
|
|
130
130
|
should "include diff output in the fail messages" do
|
131
131
|
subject.run(&test_run_callback)
|
@@ -10,17 +10,17 @@ module Assert::Assertions
|
|
10
10
|
include Assert::Test::TestHelpers
|
11
11
|
|
12
12
|
desc "`assert_true`"
|
13
|
-
subject
|
13
|
+
subject do
|
14
14
|
args = args1
|
15
15
|
Factory.test do
|
16
16
|
assert_true(true) # pass
|
17
17
|
assert_true(*args) # fail
|
18
18
|
end
|
19
|
-
|
19
|
+
end
|
20
20
|
|
21
|
-
let(:desc1)
|
22
|
-
let(:args1)
|
23
|
-
let(:config1)
|
21
|
+
let(:desc1){ "assert true fail desc" }
|
22
|
+
let(:args1){ ["whatever", desc1] }
|
23
|
+
let(:config1){ subject.config }
|
24
24
|
|
25
25
|
should "produce results as expected" do
|
26
26
|
subject.run(&test_run_callback)
|
@@ -29,7 +29,9 @@ module Assert::Assertions
|
|
29
29
|
assert_that(test_run_result_count(:pass)).equals(1)
|
30
30
|
assert_that(test_run_result_count(:fail)).equals(1)
|
31
31
|
|
32
|
-
exp =
|
32
|
+
exp =
|
33
|
+
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
|
34
|
+
"be true."
|
33
35
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
34
36
|
end
|
35
37
|
end
|
@@ -38,17 +40,17 @@ module Assert::Assertions
|
|
38
40
|
include Assert::Test::TestHelpers
|
39
41
|
|
40
42
|
desc "`assert_not_true`"
|
41
|
-
subject
|
43
|
+
subject do
|
42
44
|
args = args1
|
43
45
|
Factory.test do
|
44
46
|
assert_not_true(false) # pass
|
45
47
|
assert_not_true(*args) # fail
|
46
48
|
end
|
47
|
-
|
49
|
+
end
|
48
50
|
|
49
|
-
let(:desc1)
|
50
|
-
let(:args1)
|
51
|
-
let(:config1)
|
51
|
+
let(:desc1){ "assert not true fail desc" }
|
52
|
+
let(:args1){ [true, desc1] }
|
53
|
+
let(:config1){ subject.config }
|
52
54
|
|
53
55
|
should "produce results as expected" do
|
54
56
|
subject.run(&test_run_callback)
|
@@ -57,7 +59,9 @@ module Assert::Assertions
|
|
57
59
|
assert_that(test_run_result_count(:pass)).equals(1)
|
58
60
|
assert_that(test_run_result_count(:fail)).equals(1)
|
59
61
|
|
60
|
-
exp =
|
62
|
+
exp =
|
63
|
+
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
|
64
|
+
"not be true."
|
61
65
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
62
66
|
end
|
63
67
|
end
|
@@ -66,17 +70,17 @@ module Assert::Assertions
|
|
66
70
|
include Assert::Test::TestHelpers
|
67
71
|
|
68
72
|
desc "`assert_false`"
|
69
|
-
subject
|
73
|
+
subject do
|
70
74
|
args = args1
|
71
75
|
Factory.test do
|
72
76
|
assert_false(false) # pass
|
73
77
|
assert_false(*args) # fail
|
74
78
|
end
|
75
|
-
|
79
|
+
end
|
76
80
|
|
77
|
-
let(:desc1)
|
78
|
-
let(:args1)
|
79
|
-
let(:config1)
|
81
|
+
let(:desc1){ "assert false fail desc" }
|
82
|
+
let(:args1){ ["whatever", desc1] }
|
83
|
+
let(:config1){ subject.config }
|
80
84
|
|
81
85
|
should "produce results as expected" do
|
82
86
|
subject.run(&test_run_callback)
|
@@ -85,7 +89,9 @@ module Assert::Assertions
|
|
85
89
|
assert_that(test_run_result_count(:pass)).equals(1)
|
86
90
|
assert_that(test_run_result_count(:fail)).equals(1)
|
87
91
|
|
88
|
-
exp =
|
92
|
+
exp =
|
93
|
+
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
|
94
|
+
"be false."
|
89
95
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
90
96
|
end
|
91
97
|
end
|
@@ -94,17 +100,17 @@ module Assert::Assertions
|
|
94
100
|
include Assert::Test::TestHelpers
|
95
101
|
|
96
102
|
desc "`assert_not_false`"
|
97
|
-
subject
|
103
|
+
subject do
|
98
104
|
args = args1
|
99
105
|
Factory.test do
|
100
106
|
assert_not_false(true) # pass
|
101
107
|
assert_not_false(*args) # fail
|
102
108
|
end
|
103
|
-
|
109
|
+
end
|
104
110
|
|
105
|
-
let(:desc1)
|
106
|
-
let(:args1)
|
107
|
-
let(:config1)
|
111
|
+
let(:desc1){ "assert not false fail desc" }
|
112
|
+
let(:args1){ [false, desc1] }
|
113
|
+
let(:config1){ subject.config }
|
108
114
|
|
109
115
|
should "produce results as expected" do
|
110
116
|
subject.run(&test_run_callback)
|
@@ -113,7 +119,9 @@ module Assert::Assertions
|
|
113
119
|
assert_that(test_run_result_count(:pass)).equals(1)
|
114
120
|
assert_that(test_run_result_count(:fail)).equals(1)
|
115
121
|
|
116
|
-
exp =
|
122
|
+
exp =
|
123
|
+
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
|
124
|
+
"not be false."
|
117
125
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
118
126
|
end
|
119
127
|
end
|
@@ -8,21 +8,26 @@ module Assert::Assertions
|
|
8
8
|
include Assert::Test::TestHelpers
|
9
9
|
|
10
10
|
desc "Assert::Context"
|
11
|
-
subject
|
11
|
+
subject{ context_class1.new(test1, test1.config, proc{ |r| }) }
|
12
12
|
|
13
|
-
let(:context_class1)
|
14
|
-
let(:test1)
|
13
|
+
let(:context_class1){ Factory.modes_off_context_class }
|
14
|
+
let(:test1){ Factory.test }
|
15
15
|
|
16
16
|
should have_imeths :assert_block, :assert_not_block, :refute_block
|
17
17
|
should have_imeths :assert_empty, :assert_not_empty, :refute_empty
|
18
18
|
should have_imeths :assert_equal, :assert_not_equal, :refute_equal
|
19
|
-
should have_imeths :assert_file_exists, :assert_not_file_exists
|
19
|
+
should have_imeths :assert_file_exists, :assert_not_file_exists
|
20
|
+
should have_imeths :refute_file_exists
|
20
21
|
should have_imeths :assert_includes, :assert_not_includes
|
21
22
|
should have_imeths :assert_included, :assert_not_included
|
22
23
|
should have_imeths :refute_includes, :refute_included
|
23
|
-
should have_imeths :assert_instance_of, :assert_not_instance_of
|
24
|
+
should have_imeths :assert_instance_of, :assert_not_instance_of
|
25
|
+
should have_imeths :refute_instance_of
|
26
|
+
should have_imeths :assert_is_a, :assert_is_not_a, :assert_not_a
|
27
|
+
should have_imeths :refute_is_a
|
24
28
|
should have_imeths :assert_kind_of, :assert_not_kind_of, :refute_kind_of
|
25
|
-
should have_imeths :assert_match, :assert_not_match, :assert_no_match
|
29
|
+
should have_imeths :assert_match, :assert_not_match, :assert_no_match
|
30
|
+
should have_imeths :refute_match
|
26
31
|
should have_imeths :assert_nil, :assert_not_nil, :refute_nil
|
27
32
|
should have_imeths :assert_true, :assert_not_true, :refute_true
|
28
33
|
should have_imeths :assert_false, :assert_not_false, :refute_false
|
@@ -41,14 +46,14 @@ module Assert::Assertions
|
|
41
46
|
tests.each{ |test| test.run(&test_run_callback) }
|
42
47
|
end
|
43
48
|
|
44
|
-
let(:tests)
|
49
|
+
let(:tests) do
|
45
50
|
context_info = Factory.context_info(context_class1)
|
46
51
|
Assert::Assertions::IGNORED_ASSERTION_HELPERS.map do |helper|
|
47
52
|
Factory.test("ignored assertion helper #{helper}", context_info) do
|
48
|
-
|
53
|
+
send(helper, "doesn't matter")
|
49
54
|
end
|
50
55
|
end
|
51
|
-
|
56
|
+
end
|
52
57
|
|
53
58
|
should "have an ignored result for each helper in the constant" do
|
54
59
|
exp = Assert::Assertions::IGNORED_ASSERTION_HELPERS.size
|
@@ -8,9 +8,9 @@ require "assert/config"
|
|
8
8
|
module Assert::ConfigHelpers
|
9
9
|
class UnitTests < Assert::Context
|
10
10
|
desc "Assert::ConfigHelpers"
|
11
|
-
subject
|
11
|
+
subject{ unit_class }
|
12
12
|
|
13
|
-
let(:unit_class)
|
13
|
+
let(:unit_class) do
|
14
14
|
Class.new do
|
15
15
|
include Assert::ConfigHelpers
|
16
16
|
|
@@ -20,12 +20,12 @@ module Assert::ConfigHelpers
|
|
20
20
|
@config ||= [Assert.config, Assert::Config.new].sample
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
end
|
24
24
|
end
|
25
25
|
|
26
26
|
class InitTests < UnitTests
|
27
27
|
desc "when init"
|
28
|
-
subject
|
28
|
+
subject{ unit_class.new }
|
29
29
|
|
30
30
|
should have_imeths :runner, :suite, :view
|
31
31
|
should have_imeths :runner_seed, :single_test?, :single_test_file_line
|
@@ -51,10 +51,10 @@ module Assert::ConfigHelpers
|
|
51
51
|
end
|
52
52
|
|
53
53
|
should "know if it is in single test mode" do
|
54
|
-
Assert.stub(subject.config, :single_test?)
|
54
|
+
Assert.stub(subject.config, :single_test?){ true }
|
55
55
|
assert_that(subject.single_test?).is_true
|
56
56
|
|
57
|
-
Assert.stub(subject.config, :single_test?)
|
57
|
+
Assert.stub(subject.config, :single_test?){ false }
|
58
58
|
assert_that(subject.single_test?).is_false
|
59
59
|
end
|
60
60
|
|
@@ -119,7 +119,8 @@ module Assert::ConfigHelpers
|
|
119
119
|
|
120
120
|
result_rate = Factory.float
|
121
121
|
exp = format % result_rate
|
122
|
-
assert_that(subject.formatted_result_rate(result_rate, format))
|
122
|
+
assert_that(subject.formatted_result_rate(result_rate, format))
|
123
|
+
.equals(exp)
|
123
124
|
assert_that(subject.formatted_result_rate(result_rate)).equals(exp)
|
124
125
|
end
|
125
126
|
|
@@ -137,17 +138,21 @@ module Assert::ConfigHelpers
|
|
137
138
|
end
|
138
139
|
|
139
140
|
should "know whether to show test profile info" do
|
140
|
-
assert_that(subject.show_test_profile_info?)
|
141
|
+
assert_that(subject.show_test_profile_info?)
|
142
|
+
.equals(!!subject.config.profile)
|
141
143
|
end
|
142
144
|
|
143
145
|
should "know whether to show verbose info" do
|
144
|
-
assert_that(subject.show_test_verbose_info?)
|
146
|
+
assert_that(subject.show_test_verbose_info?)
|
147
|
+
.equals(!!subject.config.verbose)
|
145
148
|
end
|
146
149
|
|
147
150
|
should "know what result types occur in a suite's results" do
|
148
151
|
result_types = [:pass, :fail, :ignore, :skip, :error]
|
149
152
|
result_count = Factory.integer
|
150
|
-
Assert.stub(subject, "#{result_types.sample}_result_count")
|
153
|
+
Assert.stub(subject, "#{result_types.sample}_result_count") do
|
154
|
+
result_count
|
155
|
+
end
|
151
156
|
|
152
157
|
exp = result_types.select do |type_sym|
|
153
158
|
subject.send("#{type_sym}_result_count") > 0
|
data/test/unit/config_tests.rb
CHANGED
@@ -12,14 +12,14 @@ require "assert/runner"
|
|
12
12
|
class Assert::Config
|
13
13
|
class UnitTests < Assert::Context
|
14
14
|
desc "Assert::Config"
|
15
|
-
subject
|
15
|
+
subject{ unit_class }
|
16
16
|
|
17
|
-
let(:unit_class)
|
17
|
+
let(:unit_class){ Assert::Config }
|
18
18
|
end
|
19
19
|
|
20
20
|
class InitTests < UnitTests
|
21
21
|
desc "when init"
|
22
|
-
subject
|
22
|
+
subject{ unit_class.new }
|
23
23
|
|
24
24
|
should have_imeths :view, :suite, :runner
|
25
25
|
should have_imeths :test_dir, :test_helper, :test_file_suffixes
|
@@ -29,6 +29,7 @@ class Assert::Config
|
|
29
29
|
should have_imeths :verbose, :list, :debug
|
30
30
|
should have_imeths :apply, :single_test?
|
31
31
|
should have_imeths :single_test_file_line, :single_test_file_path
|
32
|
+
should have_imeths :env_runner_seed, :random_runner_seed
|
32
33
|
|
33
34
|
should "default the view, suite, and runner" do
|
34
35
|
assert_that(subject.view).is_kind_of(Assert::DefaultView)
|
@@ -63,19 +64,42 @@ class Assert::Config
|
|
63
64
|
assert_that(subject.debug).is_false
|
64
65
|
end
|
65
66
|
|
67
|
+
should "prefer a SEED env var, if present, for the runner seed value" do
|
68
|
+
orig_env_seed = ENV["SEED"]
|
69
|
+
new_env_seed = Factory.integer
|
70
|
+
ENV["SEED"] = new_env_seed.to_s
|
71
|
+
|
72
|
+
config = unit_class.new
|
73
|
+
assert_that(config.env_runner_seed).equals(new_env_seed.to_s)
|
74
|
+
assert_that(config.runner_seed).equals(config.env_runner_seed.to_i)
|
75
|
+
|
76
|
+
ENV["SEED"] = orig_env_seed
|
77
|
+
end
|
78
|
+
|
79
|
+
should "fallback to a random runner seed value if no SEED env var" do
|
80
|
+
orig_env_seed = ENV["SEED"]
|
81
|
+
ENV["SEED"] = nil
|
82
|
+
|
83
|
+
config = unit_class.new
|
84
|
+
assert_that(config.random_runner_seed).is_not_nil
|
85
|
+
assert_that(config.runner_seed).equals(config.random_runner_seed.to_i)
|
86
|
+
|
87
|
+
ENV["SEED"] = orig_env_seed
|
88
|
+
end
|
89
|
+
|
66
90
|
should "apply settings given from a hash" do
|
67
91
|
assert subject.halt_on_fail
|
68
|
-
subject.apply(:
|
92
|
+
subject.apply(halt_on_fail: false)
|
69
93
|
assert_that(subject.halt_on_fail).is_false
|
70
94
|
|
71
95
|
assert_that(Assert::Config.new.halt_on_fail).is_true
|
72
|
-
assert_that(Assert::Config.new(:
|
96
|
+
assert_that(Assert::Config.new(halt_on_fail: false).halt_on_fail).is_false
|
73
97
|
end
|
74
98
|
|
75
99
|
should "know if it is in single test mode" do
|
76
100
|
assert_that(subject.single_test?).is_false
|
77
101
|
|
78
|
-
subject.apply(:
|
102
|
+
subject.apply(single_test: Factory.string)
|
79
103
|
assert_that(subject.single_test?).is_true
|
80
104
|
end
|
81
105
|
|
@@ -84,7 +108,7 @@ class Assert::Config
|
|
84
108
|
assert_that(subject.single_test_file_line).equals(exp)
|
85
109
|
|
86
110
|
file_line_path = "#{Factory.path}_tests.rb:#{Factory.integer}"
|
87
|
-
subject.apply(:
|
111
|
+
subject.apply(single_test: file_line_path)
|
88
112
|
|
89
113
|
exp = Assert::FileLine.parse(File.expand_path(file_line_path, Dir.pwd))
|
90
114
|
assert_that(subject.single_test_file_line).equals(exp)
|
@@ -96,8 +120,9 @@ class Assert::Config
|
|
96
120
|
|
97
121
|
path = "#{Factory.path}_tests.rb"
|
98
122
|
file_line_path = "#{path}:#{Factory.integer}"
|
99
|
-
subject.apply(:
|
100
|
-
assert_that(subject.single_test_file_path)
|
123
|
+
subject.apply(single_test: file_line_path)
|
124
|
+
assert_that(subject.single_test_file_path)
|
125
|
+
.equals(File.expand_path(path, Dir.pwd))
|
101
126
|
end
|
102
127
|
end
|
103
128
|
end
|