assert 2.18.3 → 2.19.3
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 -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 +9 -7
- data/lib/assert/config_helpers.rb +57 -22
- data/lib/assert/context.rb +33 -49
- data/lib/assert/context/let_dsl.rb +10 -4
- 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 +26 -25
- 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 +272 -250
- data/test/system/test_tests.rb +89 -73
- data/test/unit/actual_value_tests.rb +103 -46
- data/test/unit/assert_tests.rb +49 -39
- data/test/unit/assertions/assert_block_tests.rb +14 -14
- data/test/unit/assertions/assert_changes_tests.rb +103 -0
- data/test/unit/assertions/assert_empty_tests.rb +18 -16
- data/test/unit/assertions/assert_equal_tests.rb +48 -32
- data/test/unit/assertions/assert_file_exists_tests.rb +19 -17
- data/test/unit/assertions/assert_includes_tests.rb +14 -14
- data/test/unit/assertions/assert_instance_of_tests.rb +18 -18
- data/test/unit/assertions/assert_is_a_tests.rb +128 -0
- data/test/unit/assertions/assert_match_tests.rb +14 -14
- data/test/unit/assertions/assert_nil_tests.rb +20 -16
- data/test/unit/assertions/assert_raises_tests.rb +36 -27
- data/test/unit/assertions/assert_respond_to_tests.rb +14 -14
- data/test/unit/assertions/assert_same_tests.rb +28 -32
- data/test/unit/assertions/assert_true_false_tests.rb +38 -32
- data/test/unit/assertions_tests.rb +25 -18
- data/test/unit/config_helpers_tests.rb +20 -9
- data/test/unit/config_tests.rb +16 -8
- data/test/unit/context/let_dsl_tests.rb +2 -0
- data/test/unit/context/setup_dsl_tests.rb +27 -15
- data/test/unit/context/subject_dsl_tests.rb +5 -4
- data/test/unit/context/suite_dsl_tests.rb +6 -5
- data/test/unit/context/test_dsl_tests.rb +43 -19
- data/test/unit/context_info_tests.rb +12 -3
- data/test/unit/context_tests.rb +166 -116
- data/test/unit/default_runner_tests.rb +2 -0
- data/test/unit/default_suite_tests.rb +17 -5
- data/test/unit/factory_tests.rb +5 -1
- data/test/unit/file_line_tests.rb +14 -12
- data/test/unit/macro_tests.rb +17 -10
- data/test/unit/result_tests.rb +72 -75
- data/test/unit/runner_tests.rb +38 -23
- data/test/unit/suite_tests.rb +48 -30
- data/test/unit/test_tests.rb +88 -102
- data/test/unit/utils_tests.rb +53 -36
- data/test/unit/view_helpers_tests.rb +25 -17
- data/test/unit/view_tests.rb +8 -5
- metadata +40 -9
- data/test/unit/assertions/assert_kind_of_tests.rb +0 -68
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/config_helpers"
|
3
5
|
|
@@ -6,20 +8,24 @@ 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(:
|
13
|
+
let(:unit_class) do
|
12
14
|
Class.new do
|
13
15
|
include Assert::ConfigHelpers
|
14
16
|
|
15
17
|
def config
|
16
18
|
# use the assert config since it has tests, contexts, etc
|
17
|
-
# also
|
19
|
+
# also use a fresh config that is empty
|
18
20
|
@config ||= [Assert.config, Assert::Config.new].sample
|
19
21
|
end
|
20
22
|
end
|
21
|
-
|
22
|
-
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class InitTests < UnitTests
|
27
|
+
desc "when init"
|
28
|
+
subject{ unit_class.new }
|
23
29
|
|
24
30
|
should have_imeths :runner, :suite, :view
|
25
31
|
should have_imeths :runner_seed, :single_test?, :single_test_file_line
|
@@ -113,7 +119,8 @@ module Assert::ConfigHelpers
|
|
113
119
|
|
114
120
|
result_rate = Factory.float
|
115
121
|
exp = format % result_rate
|
116
|
-
assert_that(subject.formatted_result_rate(result_rate, format))
|
122
|
+
assert_that(subject.formatted_result_rate(result_rate, format))
|
123
|
+
.equals(exp)
|
117
124
|
assert_that(subject.formatted_result_rate(result_rate)).equals(exp)
|
118
125
|
end
|
119
126
|
|
@@ -131,17 +138,21 @@ module Assert::ConfigHelpers
|
|
131
138
|
end
|
132
139
|
|
133
140
|
should "know whether to show test profile info" do
|
134
|
-
assert_that(subject.show_test_profile_info?)
|
141
|
+
assert_that(subject.show_test_profile_info?)
|
142
|
+
.equals(!!subject.config.profile)
|
135
143
|
end
|
136
144
|
|
137
145
|
should "know whether to show verbose info" do
|
138
|
-
assert_that(subject.show_test_verbose_info?)
|
146
|
+
assert_that(subject.show_test_verbose_info?)
|
147
|
+
.equals(!!subject.config.verbose)
|
139
148
|
end
|
140
149
|
|
141
150
|
should "know what result types occur in a suite's results" do
|
142
151
|
result_types = [:pass, :fail, :ignore, :skip, :error]
|
143
152
|
result_count = Factory.integer
|
144
|
-
Assert.stub(subject, "#{result_types.sample}_result_count")
|
153
|
+
Assert.stub(subject, "#{result_types.sample}_result_count") do
|
154
|
+
result_count
|
155
|
+
end
|
145
156
|
|
146
157
|
exp = result_types.select do |type_sym|
|
147
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,9 +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 }
|
16
|
+
|
17
|
+
let(:unit_class){ Assert::Config }
|
18
|
+
end
|
14
19
|
|
15
|
-
|
20
|
+
class InitTests < UnitTests
|
21
|
+
desc "when init"
|
22
|
+
subject{ unit_class.new }
|
16
23
|
|
17
24
|
should have_imeths :view, :suite, :runner
|
18
25
|
should have_imeths :test_dir, :test_helper, :test_file_suffixes
|
@@ -58,17 +65,17 @@ class Assert::Config
|
|
58
65
|
|
59
66
|
should "apply settings given from a hash" do
|
60
67
|
assert subject.halt_on_fail
|
61
|
-
subject.apply(:
|
68
|
+
subject.apply(halt_on_fail: false)
|
62
69
|
assert_that(subject.halt_on_fail).is_false
|
63
70
|
|
64
71
|
assert_that(Assert::Config.new.halt_on_fail).is_true
|
65
|
-
assert_that(Assert::Config.new(:
|
72
|
+
assert_that(Assert::Config.new(halt_on_fail: false).halt_on_fail).is_false
|
66
73
|
end
|
67
74
|
|
68
75
|
should "know if it is in single test mode" do
|
69
76
|
assert_that(subject.single_test?).is_false
|
70
77
|
|
71
|
-
subject.apply(:
|
78
|
+
subject.apply(single_test: Factory.string)
|
72
79
|
assert_that(subject.single_test?).is_true
|
73
80
|
end
|
74
81
|
|
@@ -77,7 +84,7 @@ class Assert::Config
|
|
77
84
|
assert_that(subject.single_test_file_line).equals(exp)
|
78
85
|
|
79
86
|
file_line_path = "#{Factory.path}_tests.rb:#{Factory.integer}"
|
80
|
-
subject.apply(:
|
87
|
+
subject.apply(single_test: file_line_path)
|
81
88
|
|
82
89
|
exp = Assert::FileLine.parse(File.expand_path(file_line_path, Dir.pwd))
|
83
90
|
assert_that(subject.single_test_file_line).equals(exp)
|
@@ -89,8 +96,9 @@ class Assert::Config
|
|
89
96
|
|
90
97
|
path = "#{Factory.path}_tests.rb"
|
91
98
|
file_line_path = "#{path}:#{Factory.integer}"
|
92
|
-
subject.apply(:
|
93
|
-
assert_that(subject.single_test_file_path)
|
99
|
+
subject.apply(single_test: file_line_path)
|
100
|
+
assert_that(subject.single_test_file_path)
|
101
|
+
.equals(File.expand_path(path, Dir.pwd))
|
94
102
|
end
|
95
103
|
end
|
96
104
|
end
|
@@ -1,13 +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)
|
10
|
-
let(:context_class1) { Factory.modes_off_context_class }
|
11
|
+
let(:block1){ ::Proc.new{} }
|
11
12
|
end
|
12
13
|
|
13
14
|
class SetupTeardownOnceMethodsTests < UnitTests
|
@@ -37,7 +38,7 @@ module Assert::Context::SetupDSL
|
|
37
38
|
class SetupTeardownWithMethodNameTests < UnitTests
|
38
39
|
desc "methods given a method name"
|
39
40
|
|
40
|
-
let(:method_name1)
|
41
|
+
let(:method_name1){ :something_amazing }
|
41
42
|
|
42
43
|
should "add the method name to the context" do
|
43
44
|
subject.setup(method_name1)
|
@@ -49,19 +50,28 @@ module Assert::Context::SetupDSL
|
|
49
50
|
end
|
50
51
|
|
51
52
|
class ParentContextClassTests < UnitTests
|
52
|
-
|
53
|
-
|
53
|
+
subject{ Factory.modes_off_context_class(parent_class1) }
|
54
|
+
|
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,14 +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(:
|
11
|
-
let(:subject_block1) { Proc.new {} }
|
11
|
+
let(:parent_class1){ Factory.modes_off_context_class }
|
12
|
+
let(:subject_block1){ Proc.new{} }
|
12
13
|
end
|
13
14
|
|
14
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,11 +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(:
|
13
|
-
let(:custom_suite1) { Factory.modes_off_suite }
|
13
|
+
let(:parent_class1){ Factory.context_class }
|
14
|
+
let(:custom_suite1){ Factory.modes_off_suite }
|
14
15
|
|
15
16
|
should "use `Assert.suite` by default" do
|
16
17
|
assert_that(subject.suite).equals(Assert.suite)
|
@@ -29,7 +30,7 @@ module Assert::Context::SuiteDSL
|
|
29
30
|
parent_class1.suite(custom_suite1)
|
30
31
|
end
|
31
32
|
|
32
|
-
let(:custom_suite2)
|
33
|
+
let(:custom_suite2){ Factory.modes_off_suite }
|
33
34
|
|
34
35
|
should "default to its parent's suite" do
|
35
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
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/context_info"
|
3
5
|
|
@@ -6,13 +8,20 @@ require "assert/context"
|
|
6
8
|
class Assert::ContextInfo
|
7
9
|
class UnitTests < Assert::Context
|
8
10
|
desc "Assert::ContextInfo"
|
11
|
+
subject{ unit_class }
|
12
|
+
|
13
|
+
let(:unit_class){ Assert::ContextInfo }
|
14
|
+
end
|
15
|
+
|
16
|
+
class InitTests < UnitTests
|
17
|
+
desc "when init"
|
18
|
+
subject{ unit_class.new(context1, nil, @caller.first) }
|
19
|
+
|
9
20
|
setup do
|
10
21
|
@caller = caller
|
11
22
|
end
|
12
|
-
subject { info1 }
|
13
23
|
|
14
|
-
let(:context1)
|
15
|
-
let(:info1) { Assert::ContextInfo.new(context1, nil, @caller.first) }
|
24
|
+
let(:context1){ Assert::Context }
|
16
25
|
|
17
26
|
should have_readers :called_from, :klass, :file
|
18
27
|
should have_imeths :test_name
|