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
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/config_helpers"
|
3
5
|
|
@@ -6,9 +8,9 @@ require "assert/config"
|
|
6
8
|
module Assert::ConfigHelpers
|
7
9
|
class UnitTests < Assert::Context
|
8
10
|
desc "Assert::ConfigHelpers"
|
9
|
-
subject
|
11
|
+
subject{ unit_class }
|
10
12
|
|
11
|
-
let(:unit_class)
|
13
|
+
let(:unit_class) do
|
12
14
|
Class.new do
|
13
15
|
include Assert::ConfigHelpers
|
14
16
|
|
@@ -18,12 +20,12 @@ module Assert::ConfigHelpers
|
|
18
20
|
@config ||= [Assert.config, Assert::Config.new].sample
|
19
21
|
end
|
20
22
|
end
|
21
|
-
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
class InitTests < UnitTests
|
25
27
|
desc "when init"
|
26
|
-
subject
|
28
|
+
subject{ unit_class.new }
|
27
29
|
|
28
30
|
should have_imeths :runner, :suite, :view
|
29
31
|
should have_imeths :runner_seed, :single_test?, :single_test_file_line
|
@@ -117,7 +119,8 @@ module Assert::ConfigHelpers
|
|
117
119
|
|
118
120
|
result_rate = Factory.float
|
119
121
|
exp = format % result_rate
|
120
|
-
assert_that(subject.formatted_result_rate(result_rate, format))
|
122
|
+
assert_that(subject.formatted_result_rate(result_rate, format))
|
123
|
+
.equals(exp)
|
121
124
|
assert_that(subject.formatted_result_rate(result_rate)).equals(exp)
|
122
125
|
end
|
123
126
|
|
@@ -135,17 +138,21 @@ module Assert::ConfigHelpers
|
|
135
138
|
end
|
136
139
|
|
137
140
|
should "know whether to show test profile info" do
|
138
|
-
assert_that(subject.show_test_profile_info?)
|
141
|
+
assert_that(subject.show_test_profile_info?)
|
142
|
+
.equals(!!subject.config.profile)
|
139
143
|
end
|
140
144
|
|
141
145
|
should "know whether to show verbose info" do
|
142
|
-
assert_that(subject.show_test_verbose_info?)
|
146
|
+
assert_that(subject.show_test_verbose_info?)
|
147
|
+
.equals(!!subject.config.verbose)
|
143
148
|
end
|
144
149
|
|
145
150
|
should "know what result types occur in a suite's results" do
|
146
151
|
result_types = [:pass, :fail, :ignore, :skip, :error]
|
147
152
|
result_count = Factory.integer
|
148
|
-
Assert.stub(subject, "#{result_types.sample}_result_count")
|
153
|
+
Assert.stub(subject, "#{result_types.sample}_result_count") do
|
154
|
+
result_count
|
155
|
+
end
|
149
156
|
|
150
157
|
exp = result_types.select do |type_sym|
|
151
158
|
subject.send("#{type_sym}_result_count") > 0
|
data/test/unit/config_tests.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/config"
|
3
5
|
|
@@ -10,14 +12,14 @@ require "assert/runner"
|
|
10
12
|
class Assert::Config
|
11
13
|
class UnitTests < Assert::Context
|
12
14
|
desc "Assert::Config"
|
13
|
-
subject
|
15
|
+
subject{ unit_class }
|
14
16
|
|
15
|
-
let(:unit_class)
|
17
|
+
let(:unit_class){ Assert::Config }
|
16
18
|
end
|
17
19
|
|
18
20
|
class InitTests < UnitTests
|
19
21
|
desc "when init"
|
20
|
-
subject
|
22
|
+
subject{ unit_class.new }
|
21
23
|
|
22
24
|
should have_imeths :view, :suite, :runner
|
23
25
|
should have_imeths :test_dir, :test_helper, :test_file_suffixes
|
@@ -27,6 +29,7 @@ class Assert::Config
|
|
27
29
|
should have_imeths :verbose, :list, :debug
|
28
30
|
should have_imeths :apply, :single_test?
|
29
31
|
should have_imeths :single_test_file_line, :single_test_file_path
|
32
|
+
should have_imeths :env_runner_seed, :random_runner_seed
|
30
33
|
|
31
34
|
should "default the view, suite, and runner" do
|
32
35
|
assert_that(subject.view).is_kind_of(Assert::DefaultView)
|
@@ -61,19 +64,42 @@ class Assert::Config
|
|
61
64
|
assert_that(subject.debug).is_false
|
62
65
|
end
|
63
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
|
+
|
64
90
|
should "apply settings given from a hash" do
|
65
91
|
assert subject.halt_on_fail
|
66
|
-
subject.apply(:
|
92
|
+
subject.apply(halt_on_fail: false)
|
67
93
|
assert_that(subject.halt_on_fail).is_false
|
68
94
|
|
69
95
|
assert_that(Assert::Config.new.halt_on_fail).is_true
|
70
|
-
assert_that(Assert::Config.new(:
|
96
|
+
assert_that(Assert::Config.new(halt_on_fail: false).halt_on_fail).is_false
|
71
97
|
end
|
72
98
|
|
73
99
|
should "know if it is in single test mode" do
|
74
100
|
assert_that(subject.single_test?).is_false
|
75
101
|
|
76
|
-
subject.apply(:
|
102
|
+
subject.apply(single_test: Factory.string)
|
77
103
|
assert_that(subject.single_test?).is_true
|
78
104
|
end
|
79
105
|
|
@@ -82,7 +108,7 @@ class Assert::Config
|
|
82
108
|
assert_that(subject.single_test_file_line).equals(exp)
|
83
109
|
|
84
110
|
file_line_path = "#{Factory.path}_tests.rb:#{Factory.integer}"
|
85
|
-
subject.apply(:
|
111
|
+
subject.apply(single_test: file_line_path)
|
86
112
|
|
87
113
|
exp = Assert::FileLine.parse(File.expand_path(file_line_path, Dir.pwd))
|
88
114
|
assert_that(subject.single_test_file_line).equals(exp)
|
@@ -94,8 +120,9 @@ class Assert::Config
|
|
94
120
|
|
95
121
|
path = "#{Factory.path}_tests.rb"
|
96
122
|
file_line_path = "#{path}:#{Factory.integer}"
|
97
|
-
subject.apply(:
|
98
|
-
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))
|
99
126
|
end
|
100
127
|
end
|
101
128
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/context/setup_dsl"
|
3
5
|
|
4
6
|
module Assert::Context::SetupDSL
|
5
7
|
class UnitTests < Assert::Context
|
6
8
|
desc "Assert::Context::SetupDSL"
|
7
|
-
subject
|
9
|
+
subject{ Factory.modes_off_context_class }
|
8
10
|
|
9
|
-
let(:block1)
|
11
|
+
let(:block1){ ::Proc.new{} }
|
10
12
|
end
|
11
13
|
|
12
14
|
class SetupTeardownOnceMethodsTests < UnitTests
|
@@ -36,7 +38,7 @@ module Assert::Context::SetupDSL
|
|
36
38
|
class SetupTeardownWithMethodNameTests < UnitTests
|
37
39
|
desc "methods given a method name"
|
38
40
|
|
39
|
-
let(:method_name1)
|
41
|
+
let(:method_name1){ :something_amazing }
|
40
42
|
|
41
43
|
should "add the method name to the context" do
|
42
44
|
subject.setup(method_name1)
|
@@ -48,20 +50,28 @@ module Assert::Context::SetupDSL
|
|
48
50
|
end
|
49
51
|
|
50
52
|
class ParentContextClassTests < UnitTests
|
51
|
-
subject
|
53
|
+
subject{ Factory.modes_off_context_class(parent_class1) }
|
52
54
|
|
53
|
-
let(:parent_class1)
|
55
|
+
let(:parent_class1){ Factory.modes_off_context_class }
|
54
56
|
end
|
55
57
|
|
56
58
|
class SetupTeardownMultipleTests < ParentContextClassTests
|
57
59
|
desc "with multiple calls"
|
58
60
|
|
59
|
-
let(:parent_setup_block1)
|
60
|
-
|
61
|
-
|
62
|
-
let(:
|
61
|
+
let(:parent_setup_block1) do
|
62
|
+
::Proc.new{ self.setup_status = "the setup" }
|
63
|
+
end
|
64
|
+
let(:parent_teardown_block1) do
|
65
|
+
::Proc.new{ self.teardown_status += "the teardown" }
|
66
|
+
end
|
67
|
+
let(:context_setup_block1) do
|
68
|
+
::Proc.new{ self.setup_status += " has been run" }
|
69
|
+
end
|
70
|
+
let(:context_teardown_block1) do
|
71
|
+
::Proc.new{ self.teardown_status += "has been run " }
|
72
|
+
end
|
63
73
|
|
64
|
-
let(:test_status_class)
|
74
|
+
let(:test_status_class) do
|
65
75
|
Class.new do
|
66
76
|
attr_accessor :setup_status, :teardown_status
|
67
77
|
define_method(:setup_something) do
|
@@ -71,7 +81,7 @@ module Assert::Context::SetupDSL
|
|
71
81
|
self.teardown_status = "with something "
|
72
82
|
end
|
73
83
|
end
|
74
|
-
|
84
|
+
end
|
75
85
|
|
76
86
|
should "run its parent and its own blocks in the correct order" do
|
77
87
|
parent_class1.setup(&parent_setup_block1)
|
@@ -82,17 +92,19 @@ module Assert::Context::SetupDSL
|
|
82
92
|
subject.teardown(&context_teardown_block1)
|
83
93
|
|
84
94
|
subject.send("run_setups", obj = test_status_class.new)
|
85
|
-
assert_that(obj.setup_status)
|
95
|
+
assert_that(obj.setup_status)
|
96
|
+
.equals("the setup has been run with something")
|
86
97
|
|
87
98
|
subject.send("run_teardowns", obj = test_status_class.new)
|
88
|
-
assert_that(obj.teardown_status)
|
99
|
+
assert_that(obj.teardown_status)
|
100
|
+
.equals("with something has been run the teardown")
|
89
101
|
end
|
90
102
|
end
|
91
103
|
|
92
104
|
class AroundMethodTests < ParentContextClassTests
|
93
105
|
desc "with multiple `around` calls"
|
94
106
|
|
95
|
-
let(:test_status_class)
|
107
|
+
let(:test_status_class){ Class.new{ attr_accessor :out_status } }
|
96
108
|
|
97
109
|
should "run its parent and its own blocks in the correct order" do
|
98
110
|
parent_class1.around do |block|
|
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/context/subject_dsl"
|
3
5
|
|
4
6
|
module Assert::Context::SubjectDSL
|
5
7
|
class UnitTests < Assert::Context
|
6
8
|
desc "Assert::Context::SubjectDSL"
|
7
|
-
subject
|
9
|
+
subject{ Factory.modes_off_context_class(parent_class1) }
|
8
10
|
|
9
|
-
let(:parent_class1)
|
10
|
-
let(:subject_block1)
|
11
|
+
let(:parent_class1){ Factory.modes_off_context_class }
|
12
|
+
let(:subject_block1){ Proc.new{} }
|
11
13
|
end
|
12
14
|
|
13
15
|
class DescriptionTests < UnitTests
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/context/suite_dsl"
|
3
5
|
|
@@ -6,10 +8,10 @@ require "assert/suite"
|
|
6
8
|
module Assert::Context::SuiteDSL
|
7
9
|
class UnitTests < Assert::Context
|
8
10
|
desc "Assert::Context::SuiteDSL"
|
9
|
-
subject
|
11
|
+
subject{ Factory.context_class(parent_class1) }
|
10
12
|
|
11
|
-
let(:parent_class1)
|
12
|
-
let(:custom_suite1)
|
13
|
+
let(:parent_class1){ Factory.context_class }
|
14
|
+
let(:custom_suite1){ Factory.modes_off_suite }
|
13
15
|
|
14
16
|
should "use `Assert.suite` by default" do
|
15
17
|
assert_that(subject.suite).equals(Assert.suite)
|
@@ -28,7 +30,7 @@ module Assert::Context::SuiteDSL
|
|
28
30
|
parent_class1.suite(custom_suite1)
|
29
31
|
end
|
30
32
|
|
31
|
-
let(:custom_suite2)
|
33
|
+
let(:custom_suite2){ Factory.modes_off_suite }
|
32
34
|
|
33
35
|
should "default to its parent's suite" do
|
34
36
|
assert_that(subject.suite).equals(custom_suite1)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/context/test_dsl"
|
3
5
|
|
@@ -5,8 +7,8 @@ module Assert::Context::TestDSL
|
|
5
7
|
class UnitTests < Assert::Context
|
6
8
|
desc "Assert::Context::TestDSL"
|
7
9
|
|
8
|
-
let(:test_desc1)
|
9
|
-
let(:test_block1)
|
10
|
+
let(:test_desc1){ "be true" }
|
11
|
+
let(:test_block1){ Proc.new{ assert(true) } }
|
10
12
|
|
11
13
|
should "build a test using `test` with a desc and code block" do
|
12
14
|
d, b = test_desc1, test_block1
|
@@ -30,7 +32,8 @@ module Assert::Context::TestDSL
|
|
30
32
|
assert_that(test.code).equals(test_block1)
|
31
33
|
end
|
32
34
|
|
33
|
-
should "build a test that skips with no msg when `test_eventually`
|
35
|
+
should "build a test that skips with no msg when `test_eventually` "\
|
36
|
+
"called" do
|
34
37
|
d, b = test_desc1, test_block1
|
35
38
|
context, test = build_eval_context{ test_eventually(d, &b) }
|
36
39
|
err = capture_err(Assert::Result::TestSkipped) do
|
@@ -42,7 +45,8 @@ module Assert::Context::TestDSL
|
|
42
45
|
assert_that(err.backtrace.size).equals(1)
|
43
46
|
end
|
44
47
|
|
45
|
-
should "build a test that skips with no msg when `should_eventually`
|
48
|
+
should "build a test that skips with no msg when `should_eventually` "\
|
49
|
+
"called" do
|
46
50
|
d, b = test_desc1, test_block1
|
47
51
|
context, test = build_eval_context{ should_eventually(d, &b) }
|
48
52
|
err = capture_err(Assert::Result::TestSkipped) do
|
@@ -56,7 +60,7 @@ module Assert::Context::TestDSL
|
|
56
60
|
|
57
61
|
should "skip with the msg \"TODO\" when `test` called with no block" do
|
58
62
|
d = test_desc1
|
59
|
-
context, test = build_eval_context
|
63
|
+
context, test = build_eval_context{ test(d) } # no block passed
|
60
64
|
err = capture_err(Assert::Result::TestSkipped) do
|
61
65
|
context.instance_eval(&test.code)
|
62
66
|
end
|
@@ -68,7 +72,7 @@ module Assert::Context::TestDSL
|
|
68
72
|
|
69
73
|
should "skip with the msg \"TODO\" when `should` called with no block" do
|
70
74
|
d = test_desc1
|
71
|
-
context, test = build_eval_context
|
75
|
+
context, test = build_eval_context{ should(d) } # no block passed
|
72
76
|
err = capture_err(Assert::Result::TestSkipped) do
|
73
77
|
context.instance_eval(&test.code)
|
74
78
|
end
|
@@ -78,7 +82,8 @@ module Assert::Context::TestDSL
|
|
78
82
|
assert_that(err.backtrace.size).equals(1)
|
79
83
|
end
|
80
84
|
|
81
|
-
should "skip with the msg \"TODO\" when `test_eventually` called with
|
85
|
+
should "skip with the msg \"TODO\" when `test_eventually` called with "\
|
86
|
+
"no block" do
|
82
87
|
d = test_desc1
|
83
88
|
context, test = build_eval_context{ test_eventually(d) } # no block given
|
84
89
|
err = capture_err(Assert::Result::TestSkipped) do
|
@@ -90,9 +95,10 @@ module Assert::Context::TestDSL
|
|
90
95
|
assert_that(err.backtrace.size).equals(1)
|
91
96
|
end
|
92
97
|
|
93
|
-
should "skip with the msg \"TODO\" when `should_eventually` called with
|
98
|
+
should "skip with the msg \"TODO\" when `should_eventually` called with "\
|
99
|
+
"no block" do
|
94
100
|
d = test_desc1
|
95
|
-
context, test = build_eval_context{ should_eventually(d) }
|
101
|
+
context, test = build_eval_context{ should_eventually(d) }
|
96
102
|
err = capture_err(Assert::Result::TestSkipped) do
|
97
103
|
context.instance_eval(&test.code)
|
98
104
|
end
|
@@ -104,7 +110,11 @@ module Assert::Context::TestDSL
|
|
104
110
|
|
105
111
|
should "build a test from a macro using `test`" do
|
106
112
|
d, b = test_desc1, test_block1
|
107
|
-
m =
|
113
|
+
m =
|
114
|
+
Assert::Macro.new do
|
115
|
+
test(d, &b)
|
116
|
+
test(d, &b)
|
117
|
+
end
|
108
118
|
context_class = Factory.modes_off_context_class{ test(m) }
|
109
119
|
|
110
120
|
assert_that(context_class.suite.tests_to_run_count).equals(2)
|
@@ -112,7 +122,11 @@ module Assert::Context::TestDSL
|
|
112
122
|
|
113
123
|
should "build a test from a macro using `should`" do
|
114
124
|
d, b = test_desc1, test_block1
|
115
|
-
m =
|
125
|
+
m =
|
126
|
+
Assert::Macro.new do
|
127
|
+
should(d, &b)
|
128
|
+
should(d, &b)
|
129
|
+
end
|
116
130
|
context_class = Factory.modes_off_context_class{ should(m) }
|
117
131
|
|
118
132
|
assert_that(context_class.suite.tests_to_run_count).equals(2)
|
@@ -120,22 +134,32 @@ module Assert::Context::TestDSL
|
|
120
134
|
|
121
135
|
should "build a test that skips from a macro using `test_eventually`" do
|
122
136
|
d, b = test_desc1, test_block1
|
123
|
-
m =
|
137
|
+
m =
|
138
|
+
Assert::Macro.new do
|
139
|
+
test(d, &b)
|
140
|
+
test(d, &b)
|
141
|
+
end
|
124
142
|
context, test = build_eval_context{ test_eventually(m) }
|
125
143
|
|
126
144
|
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
127
|
-
assert_that
|
128
|
-
|
145
|
+
assert_that{
|
146
|
+
context.instance_eval(&test.code)
|
147
|
+
}.raises(Assert::Result::TestSkipped)
|
129
148
|
end
|
130
149
|
|
131
150
|
should "build a test that skips from a macro using `should_eventually`" do
|
132
151
|
d, b = test_desc1, test_block1
|
133
|
-
m =
|
152
|
+
m =
|
153
|
+
Assert::Macro.new do
|
154
|
+
should(d, &b)
|
155
|
+
should(d, &b)
|
156
|
+
end
|
134
157
|
context, test = build_eval_context{ should_eventually(m) }
|
135
158
|
|
136
159
|
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
137
|
-
assert_that
|
138
|
-
|
160
|
+
assert_that{
|
161
|
+
context.instance_eval(&test.code)
|
162
|
+
}.raises(Assert::Result::TestSkipped)
|
139
163
|
end
|
140
164
|
|
141
165
|
private
|
@@ -149,8 +173,8 @@ module Assert::Context::TestDSL
|
|
149
173
|
def capture_err(err_class, &block)
|
150
174
|
begin
|
151
175
|
block.call
|
152
|
-
rescue err_class =>
|
153
|
-
|
176
|
+
rescue err_class => ex
|
177
|
+
ex
|
154
178
|
end
|
155
179
|
end
|
156
180
|
end
|