assert 2.17.0 → 2.18.4
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 +2 -2
- data/README.md +66 -41
- data/assert.gemspec +2 -3
- data/lib/assert.rb +0 -10
- data/lib/assert/actual_value.rb +127 -0
- data/lib/assert/assert_runner.rb +0 -3
- data/lib/assert/assertions.rb +10 -23
- data/lib/assert/cli.rb +30 -46
- data/lib/assert/config.rb +0 -4
- data/lib/assert/config_helpers.rb +0 -4
- data/lib/assert/context.rb +18 -9
- data/lib/assert/context/let_dsl.rb +13 -0
- data/lib/assert/context/method_missing.rb +19 -0
- data/lib/assert/context/setup_dsl.rb +0 -4
- data/lib/assert/context/subject_dsl.rb +23 -28
- data/lib/assert/context/suite_dsl.rb +0 -4
- data/lib/assert/context/test_dsl.rb +0 -4
- data/lib/assert/context_info.rb +0 -4
- data/lib/assert/default_runner.rb +0 -4
- data/lib/assert/default_suite.rb +0 -5
- data/lib/assert/default_view.rb +0 -4
- data/lib/assert/factory.rb +0 -3
- data/lib/assert/file_line.rb +0 -4
- data/lib/assert/macro.rb +0 -3
- data/lib/assert/macros/methods.rb +4 -10
- data/lib/assert/result.rb +2 -17
- data/lib/assert/runner.rb +0 -3
- data/lib/assert/stub.rb +15 -1
- data/lib/assert/suite.rb +0 -4
- data/lib/assert/test.rb +2 -7
- data/lib/assert/utils.rb +0 -4
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view.rb +0 -3
- data/lib/assert/view_helpers.rb +0 -11
- data/log/{.gitkeep → .keep} +0 -0
- data/test/helper.rb +23 -29
- data/test/support/factory.rb +14 -0
- data/test/support/inherited_stuff.rb +0 -2
- data/test/system/stub_tests.rb +332 -352
- data/test/system/test_tests.rb +98 -124
- data/test/unit/actual_value_tests.rb +335 -0
- data/test/unit/assert_tests.rb +121 -46
- data/test/unit/assertions/assert_block_tests.rb +30 -35
- data/test/unit/assertions/assert_empty_tests.rb +33 -35
- data/test/unit/assertions/assert_equal_tests.rb +75 -83
- data/test/unit/assertions/assert_file_exists_tests.rb +32 -36
- data/test/unit/assertions/assert_includes_tests.rb +38 -41
- data/test/unit/assertions/assert_instance_of_tests.rb +34 -37
- data/test/unit/assertions/assert_kind_of_tests.rb +34 -37
- data/test/unit/assertions/assert_match_tests.rb +34 -37
- data/test/unit/assertions/assert_nil_tests.rb +30 -35
- data/test/unit/assertions/assert_raises_tests.rb +54 -60
- data/test/unit/assertions/assert_respond_to_tests.rb +36 -39
- data/test/unit/assertions/assert_same_tests.rb +86 -88
- data/test/unit/assertions/assert_true_false_tests.rb +60 -66
- data/test/unit/assertions_tests.rb +14 -17
- data/test/unit/config_helpers_tests.rb +41 -39
- data/test/unit/config_tests.rb +38 -37
- data/test/unit/context/let_dsl_tests.rb +10 -0
- data/test/unit/context/setup_dsl_tests.rb +68 -87
- data/test/unit/context/subject_dsl_tests.rb +15 -49
- data/test/unit/context/suite_dsl_tests.rb +15 -20
- data/test/unit/context/test_dsl_tests.rb +50 -57
- data/test/unit/context_info_tests.rb +23 -18
- data/test/unit/context_tests.rb +183 -194
- data/test/unit/default_runner_tests.rb +1 -7
- data/test/unit/default_suite_tests.rb +57 -56
- data/test/unit/factory_tests.rb +5 -6
- data/test/unit/file_line_tests.rb +33 -39
- data/test/unit/macro_tests.rb +14 -18
- data/test/unit/result_tests.rb +159 -196
- data/test/unit/runner_tests.rb +64 -71
- data/test/unit/suite_tests.rb +58 -59
- data/test/unit/test_tests.rb +125 -136
- data/test/unit/utils_tests.rb +43 -54
- data/test/unit/view_helpers_tests.rb +54 -58
- data/test/unit/view_tests.rb +22 -27
- metadata +15 -10
- data/tmp/.gitkeep +0 -0
@@ -2,84 +2,67 @@ require "assert"
|
|
2
2
|
require "assert/context/setup_dsl"
|
3
3
|
|
4
4
|
module Assert::Context::SetupDSL
|
5
|
-
|
6
5
|
class UnitTests < Assert::Context
|
7
6
|
desc "Assert::Context::SetupDSL"
|
8
|
-
subject{
|
7
|
+
subject { Factory.modes_off_context_class }
|
9
8
|
|
9
|
+
let(:block1) { ::Proc.new {} }
|
10
10
|
end
|
11
11
|
|
12
12
|
class SetupTeardownOnceMethodsTests < UnitTests
|
13
13
|
desc "once methods"
|
14
|
-
setup do
|
15
|
-
block = @block = ::Proc.new{ something_once = true }
|
16
|
-
@context_class = Factory.modes_off_context_class do
|
17
|
-
setup_once(&block)
|
18
|
-
teardown_once(&block)
|
19
|
-
end
|
20
|
-
end
|
21
14
|
|
22
15
|
should "add the block to the suite" do
|
23
|
-
|
24
|
-
|
25
|
-
end
|
16
|
+
subject.setup_once(&block1)
|
17
|
+
subject.teardown_once(&block1)
|
26
18
|
|
19
|
+
assert_that(subject.suite.send(:setups)).includes(block1)
|
20
|
+
assert_that(subject.suite.send(:teardowns)).includes(block1)
|
21
|
+
end
|
27
22
|
end
|
28
23
|
|
29
24
|
class SetupTeardownMethodsTests < UnitTests
|
30
25
|
desc "methods"
|
31
|
-
setup do
|
32
|
-
block = @block = ::Proc.new{ something = true }
|
33
|
-
@context_class = Factory.modes_off_context_class do
|
34
|
-
setup(&block)
|
35
|
-
teardown(&block)
|
36
|
-
end
|
37
|
-
end
|
38
26
|
|
39
27
|
should "add the block to the context" do
|
40
|
-
|
41
|
-
|
42
|
-
end
|
28
|
+
subject.setup(&block1)
|
29
|
+
subject.teardown(&block1)
|
43
30
|
|
31
|
+
assert_that(subject.send(:setups)).includes(block1)
|
32
|
+
assert_that(subject.send(:teardowns)).includes(block1)
|
33
|
+
end
|
44
34
|
end
|
45
35
|
|
46
36
|
class SetupTeardownWithMethodNameTests < UnitTests
|
47
37
|
desc "methods given a method name"
|
48
|
-
|
49
|
-
|
50
|
-
@context_class = Factory.modes_off_context_class do
|
51
|
-
setup(method_name)
|
52
|
-
teardown(method_name)
|
53
|
-
end
|
54
|
-
end
|
38
|
+
|
39
|
+
let(:method_name1) { :something_amazing }
|
55
40
|
|
56
41
|
should "add the method name to the context" do
|
57
|
-
|
58
|
-
|
42
|
+
subject.setup(method_name1)
|
43
|
+
subject.teardown(method_name1)
|
44
|
+
|
45
|
+
assert_that(subject.send(:setups)).includes(method_name1)
|
46
|
+
assert_that(subject.send(:teardowns)).includes(method_name1)
|
59
47
|
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class ParentContextClassTests < UnitTests
|
51
|
+
subject { Factory.modes_off_context_class(parent_class1) }
|
60
52
|
|
53
|
+
let(:parent_class1) { Factory.modes_off_context_class }
|
61
54
|
end
|
62
55
|
|
63
|
-
class SetupTeardownMultipleTests <
|
56
|
+
class SetupTeardownMultipleTests < ParentContextClassTests
|
64
57
|
desc "with multiple calls"
|
65
|
-
setup do
|
66
|
-
parent_setup_block = ::Proc.new{ self.setup_status = "the setup" }
|
67
|
-
parent_teardown_block = ::Proc.new{ self.teardown_status += "the teardown" }
|
68
|
-
@parent_class = Factory.modes_off_context_class do
|
69
|
-
setup(&parent_setup_block)
|
70
|
-
teardown(&parent_teardown_block)
|
71
|
-
end
|
72
58
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
setup(:setup_something)
|
78
|
-
teardown(:teardown_something)
|
79
|
-
teardown(&context_teardown_block)
|
80
|
-
end
|
59
|
+
let(:parent_setup_block1) { ::Proc.new { self.setup_status = "the setup" } }
|
60
|
+
let(:parent_teardown_block1) { ::Proc.new { self.teardown_status += "the teardown" } }
|
61
|
+
let(:context_setup_block1) { ::Proc.new { self.setup_status += " has been run" } }
|
62
|
+
let(:context_teardown_block1) { ::Proc.new { self.teardown_status += "has been run " } }
|
81
63
|
|
82
|
-
|
64
|
+
let(:test_status_class) {
|
65
|
+
Class.new do
|
83
66
|
attr_accessor :setup_status, :teardown_status
|
84
67
|
define_method(:setup_something) do
|
85
68
|
self.setup_status += " with something"
|
@@ -88,60 +71,58 @@ module Assert::Context::SetupDSL
|
|
88
71
|
self.teardown_status = "with something "
|
89
72
|
end
|
90
73
|
end
|
91
|
-
|
74
|
+
}
|
92
75
|
|
93
|
-
should "run
|
94
|
-
|
95
|
-
|
76
|
+
should "run its parent and its own blocks in the correct order" do
|
77
|
+
parent_class1.setup(&parent_setup_block1)
|
78
|
+
parent_class1.teardown(&parent_teardown_block1)
|
79
|
+
subject.setup(&context_setup_block1)
|
80
|
+
subject.setup(:setup_something)
|
81
|
+
subject.teardown(:teardown_something)
|
82
|
+
subject.teardown(&context_teardown_block1)
|
96
83
|
|
97
|
-
subject.send("
|
98
|
-
|
99
|
-
end
|
84
|
+
subject.send("run_setups", obj = test_status_class.new)
|
85
|
+
assert_that(obj.setup_status).equals("the setup has been run with something")
|
100
86
|
|
87
|
+
subject.send("run_teardowns", obj = test_status_class.new)
|
88
|
+
assert_that(obj.teardown_status).equals("with something has been run the teardown")
|
89
|
+
end
|
101
90
|
end
|
102
91
|
|
103
|
-
class AroundMethodTests <
|
92
|
+
class AroundMethodTests < ParentContextClassTests
|
104
93
|
desc "with multiple `around` calls"
|
105
|
-
setup do
|
106
|
-
@parent_class = Factory.modes_off_context_class do
|
107
|
-
around do |block|
|
108
|
-
self.out_status ||= ""
|
109
|
-
self.out_status += "p-around start, "
|
110
|
-
block.call
|
111
|
-
self.out_status += "p-around end."
|
112
|
-
end
|
113
|
-
end
|
114
94
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
block.call
|
124
|
-
self.out_status += "c-around2 end, "
|
125
|
-
end
|
95
|
+
let(:test_status_class) { Class.new { attr_accessor :out_status } }
|
96
|
+
|
97
|
+
should "run its parent and its own blocks in the correct order" do
|
98
|
+
parent_class1.around do |block|
|
99
|
+
self.out_status ||= ""
|
100
|
+
self.out_status += "p-around start, "
|
101
|
+
block.call
|
102
|
+
self.out_status += "p-around end."
|
126
103
|
end
|
127
104
|
|
128
|
-
|
129
|
-
|
105
|
+
subject.around do |block|
|
106
|
+
self.out_status += "c-around1 start, "
|
107
|
+
block.call
|
108
|
+
self.out_status += "c-around1 end, "
|
109
|
+
end
|
110
|
+
subject.around do |block|
|
111
|
+
self.out_status += "c-around2 start, "
|
112
|
+
block.call
|
113
|
+
self.out_status += "c-around2 end, "
|
130
114
|
end
|
131
|
-
end
|
132
115
|
|
133
|
-
|
134
|
-
obj = @test_status_class.new
|
116
|
+
obj = test_status_class.new
|
135
117
|
subject.send("run_arounds", obj) do
|
136
118
|
obj.instance_eval{ self.out_status += "TEST, " }
|
137
119
|
end
|
138
120
|
|
139
|
-
exp =
|
140
|
-
|
141
|
-
|
142
|
-
|
121
|
+
exp =
|
122
|
+
"p-around start, c-around1 start, c-around2 start, "\
|
123
|
+
"TEST, "\
|
124
|
+
"c-around2 end, c-around1 end, p-around end."
|
125
|
+
assert_that(obj.out_status).equals(exp)
|
143
126
|
end
|
144
|
-
|
145
127
|
end
|
146
|
-
|
147
128
|
end
|
@@ -2,77 +2,43 @@ require "assert"
|
|
2
2
|
require "assert/context/subject_dsl"
|
3
3
|
|
4
4
|
module Assert::Context::SubjectDSL
|
5
|
-
|
6
5
|
class UnitTests < Assert::Context
|
7
6
|
desc "Assert::Context::SubjectDSL"
|
8
|
-
subject{
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
class DescriptionsTests < UnitTests
|
13
|
-
desc "`descriptions` method"
|
14
|
-
setup do
|
15
|
-
descs = @descs = ["something amazing", "it really is"]
|
16
|
-
@context_class = Factory.modes_off_context_class do
|
17
|
-
descs.each{ |text| desc text }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
should "return a collection containing any descriptions defined on the class" do
|
22
|
-
assert_equal @descs, subject.send(:descriptions)
|
23
|
-
end
|
7
|
+
subject { Factory.modes_off_context_class(parent_class1) }
|
24
8
|
|
9
|
+
let(:parent_class1) { Factory.modes_off_context_class }
|
10
|
+
let(:subject_block1) { Proc.new {} }
|
25
11
|
end
|
26
12
|
|
27
13
|
class DescriptionTests < UnitTests
|
28
14
|
desc "`description` method"
|
29
|
-
setup do
|
30
|
-
parent_text = @parent_desc = "parent description"
|
31
|
-
@parent_class = Factory.modes_off_context_class do
|
32
|
-
desc parent_text
|
33
|
-
end
|
34
|
-
text = @desc = "and the description for this context"
|
35
|
-
@context_class = Factory.modes_off_context_class(@parent_class) do
|
36
|
-
desc text
|
37
|
-
end
|
38
|
-
end
|
39
15
|
|
40
16
|
should "return a string of all the inherited descriptions" do
|
41
|
-
|
42
|
-
|
43
|
-
end
|
17
|
+
parent_class1.desc("parent description")
|
18
|
+
subject.desc("and the description for this context")
|
44
19
|
|
20
|
+
exp = "parent description and the description for this context"
|
21
|
+
assert_that(subject.description).equals(exp)
|
22
|
+
end
|
45
23
|
end
|
46
24
|
|
47
25
|
class SubjectFromLocalTests < UnitTests
|
48
26
|
desc "`subject` method using local context"
|
49
|
-
setup do
|
50
|
-
subject_block = @subject_block = ::Proc.new{ @something }
|
51
|
-
@context_class = Factory.modes_off_context_class do
|
52
|
-
subject(&subject_block)
|
53
|
-
end
|
54
|
-
end
|
55
27
|
|
56
28
|
should "set the subject block on the context class" do
|
57
|
-
|
58
|
-
end
|
29
|
+
subject.subject(&subject_block1)
|
59
30
|
|
31
|
+
assert_that(subject.subject).equals(subject_block1)
|
32
|
+
end
|
60
33
|
end
|
61
34
|
|
62
35
|
class SubjectFromParentTests < UnitTests
|
63
36
|
desc "`subject` method using parent context"
|
64
|
-
setup do
|
65
|
-
parent_block = @parent_block = ::Proc.new{ @something }
|
66
|
-
@parent_class = Factory.modes_off_context_class do
|
67
|
-
subject(&parent_block)
|
68
|
-
end
|
69
|
-
@context_class = Factory.modes_off_context_class(@parent_class)
|
70
|
-
end
|
71
37
|
|
72
|
-
should "default to
|
73
|
-
|
74
|
-
end
|
38
|
+
should "default to its parents subject block" do
|
39
|
+
parent_class1.subject(&subject_block1)
|
75
40
|
|
41
|
+
assert_that(subject.subject).equals(subject_block1)
|
42
|
+
end
|
76
43
|
end
|
77
|
-
|
78
44
|
end
|
@@ -4,44 +4,39 @@ require "assert/context/suite_dsl"
|
|
4
4
|
require "assert/suite"
|
5
5
|
|
6
6
|
module Assert::Context::SuiteDSL
|
7
|
-
|
8
7
|
class UnitTests < Assert::Context
|
9
8
|
desc "Assert::Context::SuiteDSL"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
subject{ @context_class }
|
9
|
+
subject { Factory.context_class(parent_class1) }
|
10
|
+
|
11
|
+
let(:parent_class1) { Factory.context_class }
|
12
|
+
let(:custom_suite1) { Factory.modes_off_suite }
|
15
13
|
|
16
14
|
should "use `Assert.suite` by default" do
|
17
|
-
|
15
|
+
assert_that(subject.suite).equals(Assert.suite)
|
18
16
|
end
|
19
17
|
|
20
18
|
should "use any given custom suite" do
|
21
|
-
subject.suite(
|
22
|
-
|
19
|
+
subject.suite(custom_suite1)
|
20
|
+
assert_that(subject.suite).equals(custom_suite1)
|
23
21
|
end
|
24
|
-
|
25
22
|
end
|
26
23
|
|
27
24
|
class SuiteFromParentTests < UnitTests
|
28
25
|
desc "`suite` method using parent context"
|
26
|
+
|
29
27
|
setup do
|
30
|
-
|
31
|
-
@parent_class.suite(@custom_suite)
|
32
|
-
@context_class = Factory.context_class(@parent_class)
|
28
|
+
parent_class1.suite(custom_suite1)
|
33
29
|
end
|
34
30
|
|
35
|
-
|
36
|
-
|
31
|
+
let(:custom_suite2) { Factory.modes_off_suite }
|
32
|
+
|
33
|
+
should "default to its parent's suite" do
|
34
|
+
assert_that(subject.suite).equals(custom_suite1)
|
37
35
|
end
|
38
36
|
|
39
37
|
should "use any given custom suite" do
|
40
|
-
|
41
|
-
subject.suite(
|
42
|
-
assert_equal another_suite, subject.suite
|
38
|
+
subject.suite(custom_suite2)
|
39
|
+
assert_that(subject.suite).equals(custom_suite2)
|
43
40
|
end
|
44
|
-
|
45
41
|
end
|
46
|
-
|
47
42
|
end
|
@@ -2,151 +2,146 @@ require "assert"
|
|
2
2
|
require "assert/context/test_dsl"
|
3
3
|
|
4
4
|
module Assert::Context::TestDSL
|
5
|
-
|
6
5
|
class UnitTests < Assert::Context
|
7
6
|
desc "Assert::Context::TestDSL"
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
7
|
+
|
8
|
+
let(:test_desc1) { "be true" }
|
9
|
+
let(:test_block1) { Proc.new{ assert(true) } }
|
12
10
|
|
13
11
|
should "build a test using `test` with a desc and code block" do
|
14
|
-
d, b =
|
12
|
+
d, b = test_desc1, test_block1
|
15
13
|
context, test = build_eval_context{ test(d, &b) }
|
16
14
|
|
17
|
-
|
15
|
+
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
assert_that(test).is_kind_of(Assert::Test)
|
18
|
+
assert_that(test.name).equals(test_desc1)
|
19
|
+
assert_that(test.code).equals(test_block1)
|
22
20
|
end
|
23
21
|
|
24
22
|
should "build a test using `should` with a desc and code block" do
|
25
|
-
d, b =
|
23
|
+
d, b = test_desc1, test_block1
|
26
24
|
context, test = build_eval_context{ should(d, &b) }
|
27
25
|
|
28
|
-
|
26
|
+
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
assert_that(test).is_kind_of(Assert::Test)
|
29
|
+
assert_that(test.name).equals("should #{test_desc1}")
|
30
|
+
assert_that(test.code).equals(test_block1)
|
33
31
|
end
|
34
32
|
|
35
33
|
should "build a test that skips with no msg when `test_eventually` called" do
|
36
|
-
d, b =
|
34
|
+
d, b = test_desc1, test_block1
|
37
35
|
context, test = build_eval_context{ test_eventually(d, &b) }
|
38
36
|
err = capture_err(Assert::Result::TestSkipped) do
|
39
37
|
context.instance_eval(&test.code)
|
40
38
|
end
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
41
|
+
assert_that(err.message).equals("TODO")
|
42
|
+
assert_that(err.backtrace.size).equals(1)
|
45
43
|
end
|
46
44
|
|
47
45
|
should "build a test that skips with no msg when `should_eventually` called" do
|
48
|
-
d, b =
|
46
|
+
d, b = test_desc1, test_block1
|
49
47
|
context, test = build_eval_context{ should_eventually(d, &b) }
|
50
48
|
err = capture_err(Assert::Result::TestSkipped) do
|
51
49
|
context.instance_eval(&test.code)
|
52
50
|
end
|
53
51
|
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
53
|
+
assert_that(err.message).equals("TODO")
|
54
|
+
assert_that(err.backtrace.size).equals(1)
|
57
55
|
end
|
58
56
|
|
59
57
|
should "skip with the msg \"TODO\" when `test` called with no block" do
|
60
|
-
d =
|
58
|
+
d = test_desc1
|
61
59
|
context, test = build_eval_context { test(d) } # no block passed
|
62
60
|
err = capture_err(Assert::Result::TestSkipped) do
|
63
61
|
context.instance_eval(&test.code)
|
64
62
|
end
|
65
63
|
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
65
|
+
assert_that(err.message).equals("TODO")
|
66
|
+
assert_that(err.backtrace.size).equals(1)
|
69
67
|
end
|
70
68
|
|
71
69
|
should "skip with the msg \"TODO\" when `should` called with no block" do
|
72
|
-
d =
|
70
|
+
d = test_desc1
|
73
71
|
context, test = build_eval_context { should(d) } # no block passed
|
74
72
|
err = capture_err(Assert::Result::TestSkipped) do
|
75
73
|
context.instance_eval(&test.code)
|
76
74
|
end
|
77
75
|
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
77
|
+
assert_that(err.message).equals("TODO")
|
78
|
+
assert_that(err.backtrace.size).equals(1)
|
81
79
|
end
|
82
80
|
|
83
81
|
should "skip with the msg \"TODO\" when `test_eventually` called with no block" do
|
84
|
-
d =
|
82
|
+
d = test_desc1
|
85
83
|
context, test = build_eval_context{ test_eventually(d) } # no block given
|
86
84
|
err = capture_err(Assert::Result::TestSkipped) do
|
87
85
|
context.instance_eval(&test.code)
|
88
86
|
end
|
89
87
|
|
90
|
-
|
91
|
-
|
92
|
-
|
88
|
+
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
89
|
+
assert_that(err.message).equals("TODO")
|
90
|
+
assert_that(err.backtrace.size).equals(1)
|
93
91
|
end
|
94
92
|
|
95
93
|
should "skip with the msg \"TODO\" when `should_eventually` called with no block" do
|
96
|
-
d =
|
94
|
+
d = test_desc1
|
97
95
|
context, test = build_eval_context{ should_eventually(d) } # no block given
|
98
96
|
err = capture_err(Assert::Result::TestSkipped) do
|
99
97
|
context.instance_eval(&test.code)
|
100
98
|
end
|
101
99
|
|
102
|
-
|
103
|
-
|
104
|
-
|
100
|
+
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
101
|
+
assert_that(err.message).equals("TODO")
|
102
|
+
assert_that(err.backtrace.size).equals(1)
|
105
103
|
end
|
106
104
|
|
107
105
|
should "build a test from a macro using `test`" do
|
108
|
-
d, b =
|
106
|
+
d, b = test_desc1, test_block1
|
109
107
|
m = Assert::Macro.new{ test(d, &b); test(d, &b) }
|
110
108
|
context_class = Factory.modes_off_context_class{ test(m) }
|
111
109
|
|
112
|
-
|
110
|
+
assert_that(context_class.suite.tests_to_run_count).equals(2)
|
113
111
|
end
|
114
112
|
|
115
113
|
should "build a test from a macro using `should`" do
|
116
|
-
d, b =
|
114
|
+
d, b = test_desc1, test_block1
|
117
115
|
m = Assert::Macro.new{ should(d, &b); should(d, &b) }
|
118
116
|
context_class = Factory.modes_off_context_class{ should(m) }
|
119
117
|
|
120
|
-
|
118
|
+
assert_that(context_class.suite.tests_to_run_count).equals(2)
|
121
119
|
end
|
122
120
|
|
123
121
|
should "build a test that skips from a macro using `test_eventually`" do
|
124
|
-
d, b =
|
122
|
+
d, b = test_desc1, test_block1
|
125
123
|
m = Assert::Macro.new{ test(d, &b); test(d, &b) }
|
126
124
|
context, test = build_eval_context{ test_eventually(m) }
|
127
125
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
126
|
+
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
127
|
+
assert_that(-> { context.instance_eval(&test.code) }).
|
128
|
+
raises(Assert::Result::TestSkipped)
|
132
129
|
end
|
133
130
|
|
134
131
|
should "build a test that skips from a macro using `should_eventually`" do
|
135
|
-
d, b =
|
132
|
+
d, b = test_desc1, test_block1
|
136
133
|
m = Assert::Macro.new{ should(d, &b); should(d, &b) }
|
137
134
|
context, test = build_eval_context{ should_eventually(m) }
|
138
135
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
end
|
143
|
-
|
136
|
+
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
137
|
+
assert_that(-> { context.instance_eval(&test.code) }).
|
138
|
+
raises(Assert::Result::TestSkipped)
|
144
139
|
end
|
145
140
|
|
146
141
|
private
|
147
142
|
|
148
143
|
def build_eval_context(&build_block)
|
149
|
-
context_class = Factory.modes_off_context_class
|
144
|
+
context_class = Factory.modes_off_context_class(&build_block)
|
150
145
|
test = context_class.suite.sorted_tests_to_run.to_a.last
|
151
146
|
[context_class.new(test, test.config, proc{ |r| }), test]
|
152
147
|
end
|
@@ -158,7 +153,5 @@ module Assert::Context::TestDSL
|
|
158
153
|
e
|
159
154
|
end
|
160
155
|
end
|
161
|
-
|
162
156
|
end
|
163
|
-
|
164
157
|
end
|