assert 2.19.1 → 2.19.6
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/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
@@ -6,9 +6,9 @@ require "assert/context/setup_dsl"
|
|
6
6
|
module Assert::Context::SetupDSL
|
7
7
|
class UnitTests < Assert::Context
|
8
8
|
desc "Assert::Context::SetupDSL"
|
9
|
-
subject
|
9
|
+
subject{ Factory.modes_off_context_class }
|
10
10
|
|
11
|
-
let(:block1)
|
11
|
+
let(:block1){ ::Proc.new{} }
|
12
12
|
end
|
13
13
|
|
14
14
|
class SetupTeardownOnceMethodsTests < UnitTests
|
@@ -38,7 +38,7 @@ module Assert::Context::SetupDSL
|
|
38
38
|
class SetupTeardownWithMethodNameTests < UnitTests
|
39
39
|
desc "methods given a method name"
|
40
40
|
|
41
|
-
let(:method_name1)
|
41
|
+
let(:method_name1){ :something_amazing }
|
42
42
|
|
43
43
|
should "add the method name to the context" do
|
44
44
|
subject.setup(method_name1)
|
@@ -50,20 +50,28 @@ module Assert::Context::SetupDSL
|
|
50
50
|
end
|
51
51
|
|
52
52
|
class ParentContextClassTests < UnitTests
|
53
|
-
subject
|
53
|
+
subject{ Factory.modes_off_context_class(parent_class1) }
|
54
54
|
|
55
|
-
let(:parent_class1)
|
55
|
+
let(:parent_class1){ Factory.modes_off_context_class }
|
56
56
|
end
|
57
57
|
|
58
58
|
class SetupTeardownMultipleTests < ParentContextClassTests
|
59
59
|
desc "with multiple calls"
|
60
60
|
|
61
|
-
let(:parent_setup_block1)
|
62
|
-
|
63
|
-
|
64
|
-
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
|
65
73
|
|
66
|
-
let(:test_status_class)
|
74
|
+
let(:test_status_class) do
|
67
75
|
Class.new do
|
68
76
|
attr_accessor :setup_status, :teardown_status
|
69
77
|
define_method(:setup_something) do
|
@@ -73,7 +81,7 @@ module Assert::Context::SetupDSL
|
|
73
81
|
self.teardown_status = "with something "
|
74
82
|
end
|
75
83
|
end
|
76
|
-
|
84
|
+
end
|
77
85
|
|
78
86
|
should "run its parent and its own blocks in the correct order" do
|
79
87
|
parent_class1.setup(&parent_setup_block1)
|
@@ -84,17 +92,19 @@ module Assert::Context::SetupDSL
|
|
84
92
|
subject.teardown(&context_teardown_block1)
|
85
93
|
|
86
94
|
subject.send("run_setups", obj = test_status_class.new)
|
87
|
-
assert_that(obj.setup_status)
|
95
|
+
assert_that(obj.setup_status)
|
96
|
+
.equals("the setup has been run with something")
|
88
97
|
|
89
98
|
subject.send("run_teardowns", obj = test_status_class.new)
|
90
|
-
assert_that(obj.teardown_status)
|
99
|
+
assert_that(obj.teardown_status)
|
100
|
+
.equals("with something has been run the teardown")
|
91
101
|
end
|
92
102
|
end
|
93
103
|
|
94
104
|
class AroundMethodTests < ParentContextClassTests
|
95
105
|
desc "with multiple `around` calls"
|
96
106
|
|
97
|
-
let(:test_status_class)
|
107
|
+
let(:test_status_class){ Class.new{ attr_accessor :out_status } }
|
98
108
|
|
99
109
|
should "run its parent and its own blocks in the correct order" do
|
100
110
|
parent_class1.around do |block|
|
@@ -6,10 +6,10 @@ require "assert/context/subject_dsl"
|
|
6
6
|
module Assert::Context::SubjectDSL
|
7
7
|
class UnitTests < Assert::Context
|
8
8
|
desc "Assert::Context::SubjectDSL"
|
9
|
-
subject
|
9
|
+
subject{ Factory.modes_off_context_class(parent_class1) }
|
10
10
|
|
11
|
-
let(:parent_class1)
|
12
|
-
let(:subject_block1)
|
11
|
+
let(:parent_class1){ Factory.modes_off_context_class }
|
12
|
+
let(:subject_block1){ Proc.new{} }
|
13
13
|
end
|
14
14
|
|
15
15
|
class DescriptionTests < UnitTests
|
@@ -8,10 +8,10 @@ require "assert/suite"
|
|
8
8
|
module Assert::Context::SuiteDSL
|
9
9
|
class UnitTests < Assert::Context
|
10
10
|
desc "Assert::Context::SuiteDSL"
|
11
|
-
subject
|
11
|
+
subject{ Factory.context_class(parent_class1) }
|
12
12
|
|
13
|
-
let(:parent_class1)
|
14
|
-
let(:custom_suite1)
|
13
|
+
let(:parent_class1){ Factory.context_class }
|
14
|
+
let(:custom_suite1){ Factory.modes_off_suite }
|
15
15
|
|
16
16
|
should "use `Assert.suite` by default" do
|
17
17
|
assert_that(subject.suite).equals(Assert.suite)
|
@@ -30,7 +30,7 @@ module Assert::Context::SuiteDSL
|
|
30
30
|
parent_class1.suite(custom_suite1)
|
31
31
|
end
|
32
32
|
|
33
|
-
let(:custom_suite2)
|
33
|
+
let(:custom_suite2){ Factory.modes_off_suite }
|
34
34
|
|
35
35
|
should "default to its parent's suite" do
|
36
36
|
assert_that(subject.suite).equals(custom_suite1)
|
@@ -7,8 +7,8 @@ module Assert::Context::TestDSL
|
|
7
7
|
class UnitTests < Assert::Context
|
8
8
|
desc "Assert::Context::TestDSL"
|
9
9
|
|
10
|
-
let(:test_desc1)
|
11
|
-
let(:test_block1)
|
10
|
+
let(:test_desc1){ "be true" }
|
11
|
+
let(:test_block1){ Proc.new{ assert(true) } }
|
12
12
|
|
13
13
|
should "build a test using `test` with a desc and code block" do
|
14
14
|
d, b = test_desc1, test_block1
|
@@ -32,7 +32,8 @@ module Assert::Context::TestDSL
|
|
32
32
|
assert_that(test.code).equals(test_block1)
|
33
33
|
end
|
34
34
|
|
35
|
-
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
|
36
37
|
d, b = test_desc1, test_block1
|
37
38
|
context, test = build_eval_context{ test_eventually(d, &b) }
|
38
39
|
err = capture_err(Assert::Result::TestSkipped) do
|
@@ -44,7 +45,8 @@ module Assert::Context::TestDSL
|
|
44
45
|
assert_that(err.backtrace.size).equals(1)
|
45
46
|
end
|
46
47
|
|
47
|
-
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
|
48
50
|
d, b = test_desc1, test_block1
|
49
51
|
context, test = build_eval_context{ should_eventually(d, &b) }
|
50
52
|
err = capture_err(Assert::Result::TestSkipped) do
|
@@ -58,7 +60,7 @@ module Assert::Context::TestDSL
|
|
58
60
|
|
59
61
|
should "skip with the msg \"TODO\" when `test` called with no block" do
|
60
62
|
d = test_desc1
|
61
|
-
context, test = build_eval_context
|
63
|
+
context, test = build_eval_context{ test(d) } # no block passed
|
62
64
|
err = capture_err(Assert::Result::TestSkipped) do
|
63
65
|
context.instance_eval(&test.code)
|
64
66
|
end
|
@@ -70,7 +72,7 @@ module Assert::Context::TestDSL
|
|
70
72
|
|
71
73
|
should "skip with the msg \"TODO\" when `should` called with no block" do
|
72
74
|
d = test_desc1
|
73
|
-
context, test = build_eval_context
|
75
|
+
context, test = build_eval_context{ should(d) } # no block passed
|
74
76
|
err = capture_err(Assert::Result::TestSkipped) do
|
75
77
|
context.instance_eval(&test.code)
|
76
78
|
end
|
@@ -80,7 +82,8 @@ module Assert::Context::TestDSL
|
|
80
82
|
assert_that(err.backtrace.size).equals(1)
|
81
83
|
end
|
82
84
|
|
83
|
-
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
|
84
87
|
d = test_desc1
|
85
88
|
context, test = build_eval_context{ test_eventually(d) } # no block given
|
86
89
|
err = capture_err(Assert::Result::TestSkipped) do
|
@@ -92,9 +95,10 @@ module Assert::Context::TestDSL
|
|
92
95
|
assert_that(err.backtrace.size).equals(1)
|
93
96
|
end
|
94
97
|
|
95
|
-
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
|
96
100
|
d = test_desc1
|
97
|
-
context, test = build_eval_context{ should_eventually(d) }
|
101
|
+
context, test = build_eval_context{ should_eventually(d) }
|
98
102
|
err = capture_err(Assert::Result::TestSkipped) do
|
99
103
|
context.instance_eval(&test.code)
|
100
104
|
end
|
@@ -106,7 +110,11 @@ module Assert::Context::TestDSL
|
|
106
110
|
|
107
111
|
should "build a test from a macro using `test`" do
|
108
112
|
d, b = test_desc1, test_block1
|
109
|
-
m =
|
113
|
+
m =
|
114
|
+
Assert::Macro.new do
|
115
|
+
test(d, &b)
|
116
|
+
test(d, &b)
|
117
|
+
end
|
110
118
|
context_class = Factory.modes_off_context_class{ test(m) }
|
111
119
|
|
112
120
|
assert_that(context_class.suite.tests_to_run_count).equals(2)
|
@@ -114,7 +122,11 @@ module Assert::Context::TestDSL
|
|
114
122
|
|
115
123
|
should "build a test from a macro using `should`" do
|
116
124
|
d, b = test_desc1, test_block1
|
117
|
-
m =
|
125
|
+
m =
|
126
|
+
Assert::Macro.new do
|
127
|
+
should(d, &b)
|
128
|
+
should(d, &b)
|
129
|
+
end
|
118
130
|
context_class = Factory.modes_off_context_class{ should(m) }
|
119
131
|
|
120
132
|
assert_that(context_class.suite.tests_to_run_count).equals(2)
|
@@ -122,22 +134,30 @@ module Assert::Context::TestDSL
|
|
122
134
|
|
123
135
|
should "build a test that skips from a macro using `test_eventually`" do
|
124
136
|
d, b = test_desc1, test_block1
|
125
|
-
m =
|
137
|
+
m =
|
138
|
+
Assert::Macro.new do
|
139
|
+
test(d, &b)
|
140
|
+
test(d, &b)
|
141
|
+
end
|
126
142
|
context, test = build_eval_context{ test_eventually(m) }
|
127
143
|
|
128
144
|
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
129
|
-
assert_that
|
145
|
+
assert_that{
|
130
146
|
context.instance_eval(&test.code)
|
131
147
|
}.raises(Assert::Result::TestSkipped)
|
132
148
|
end
|
133
149
|
|
134
150
|
should "build a test that skips from a macro using `should_eventually`" do
|
135
151
|
d, b = test_desc1, test_block1
|
136
|
-
m =
|
152
|
+
m =
|
153
|
+
Assert::Macro.new do
|
154
|
+
should(d, &b)
|
155
|
+
should(d, &b)
|
156
|
+
end
|
137
157
|
context, test = build_eval_context{ should_eventually(m) }
|
138
158
|
|
139
159
|
assert_that(context.class.suite.tests_to_run_count).equals(1)
|
140
|
-
assert_that
|
160
|
+
assert_that{
|
141
161
|
context.instance_eval(&test.code)
|
142
162
|
}.raises(Assert::Result::TestSkipped)
|
143
163
|
end
|
@@ -153,8 +173,8 @@ module Assert::Context::TestDSL
|
|
153
173
|
def capture_err(err_class, &block)
|
154
174
|
begin
|
155
175
|
block.call
|
156
|
-
rescue err_class =>
|
157
|
-
|
176
|
+
rescue err_class => ex
|
177
|
+
ex
|
158
178
|
end
|
159
179
|
end
|
160
180
|
end
|
@@ -8,20 +8,20 @@ require "assert/context"
|
|
8
8
|
class Assert::ContextInfo
|
9
9
|
class UnitTests < Assert::Context
|
10
10
|
desc "Assert::ContextInfo"
|
11
|
-
subject
|
11
|
+
subject{ unit_class }
|
12
12
|
|
13
|
-
let(:unit_class)
|
13
|
+
let(:unit_class){ Assert::ContextInfo }
|
14
14
|
end
|
15
15
|
|
16
16
|
class InitTests < UnitTests
|
17
17
|
desc "when init"
|
18
|
-
subject
|
18
|
+
subject{ unit_class.new(context1, nil, @caller.first) }
|
19
19
|
|
20
20
|
setup do
|
21
21
|
@caller = caller
|
22
22
|
end
|
23
23
|
|
24
|
-
let(:context1)
|
24
|
+
let(:context1){ Assert::Context }
|
25
25
|
|
26
26
|
should have_readers :called_from, :klass, :file
|
27
27
|
should have_imeths :test_name
|
data/test/unit/context_tests.rb
CHANGED
@@ -10,9 +10,9 @@ require "assert/utils"
|
|
10
10
|
class Assert::Context
|
11
11
|
class UnitTests < Assert::Context
|
12
12
|
desc "Assert::Context"
|
13
|
-
subject
|
13
|
+
subject{ unit_class }
|
14
14
|
|
15
|
-
let(:unit_class)
|
15
|
+
let(:unit_class){ Assert::Context }
|
16
16
|
|
17
17
|
# DSL methods
|
18
18
|
should have_imeths :description, :desc, :describe, :subject, :suite, :let
|
@@ -27,20 +27,23 @@ class Assert::Context
|
|
27
27
|
|
28
28
|
class InitTests < UnitTests
|
29
29
|
desc "when init"
|
30
|
-
subject
|
30
|
+
subject{ context_class1.new(test1, test1.config, result_callback1) }
|
31
31
|
|
32
32
|
setup do
|
33
33
|
@callback_result = nil
|
34
34
|
end
|
35
35
|
|
36
|
-
let(:test1)
|
37
|
-
let(:context_class1)
|
38
|
-
let(:test_results1)
|
39
|
-
let(:result_callback1)
|
40
|
-
proc
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
let(:test1){ Factory.test }
|
37
|
+
let(:context_class1){ test1.context_class }
|
38
|
+
let(:test_results1){ [] }
|
39
|
+
let(:result_callback1) do
|
40
|
+
proc do |result|
|
41
|
+
@callback_result = result
|
42
|
+
test_results1 << result
|
43
|
+
end
|
44
|
+
end
|
45
|
+
let(:halt_config1){ Assert::Config.new(halt_on_fail: true) }
|
46
|
+
let(:msg1){ Factory.string }
|
44
47
|
|
45
48
|
should have_imeths :assert, :assert_not, :refute, :assert_that
|
46
49
|
should have_imeths :pass, :ignore, :fail, :flunk, :skip
|
@@ -48,7 +51,8 @@ class Assert::Context
|
|
48
51
|
|
49
52
|
should "collect context info" do
|
50
53
|
test = @__assert_running_test__
|
51
|
-
assert_that(test.context_info.file)
|
54
|
+
assert_that(test.context_info.file)
|
55
|
+
.matches(%r{test/unit/context_tests.rb$})
|
52
56
|
assert_that(test.context_info.klass).equals(self.class)
|
53
57
|
end
|
54
58
|
|
@@ -60,7 +64,9 @@ class Assert::Context
|
|
60
64
|
with_backtrace(caller) do
|
61
65
|
assert_that(result.with_bt_set?).is_true
|
62
66
|
|
63
|
-
exp =
|
67
|
+
exp =
|
68
|
+
Assert::Result::Backtrace.to_s(exp_with_bt +
|
69
|
+
[(result.backtrace.filtered.first)])
|
64
70
|
assert_that(result.trace).equals(exp)
|
65
71
|
assert_that(result.src_line).equals(exp_with_bt.first)
|
66
72
|
end
|
@@ -71,7 +77,8 @@ class Assert::Context
|
|
71
77
|
assert_that(result.with_bt_set?).is_false
|
72
78
|
|
73
79
|
assert_that(result.trace).equals(result.src_line)
|
74
|
-
assert_that(result.src_line)
|
80
|
+
assert_that(result.src_line)
|
81
|
+
.equals(result.backtrace.filtered.first.to_s)
|
75
82
|
end
|
76
83
|
end
|
77
84
|
end
|
@@ -80,7 +87,12 @@ class Assert::Context
|
|
80
87
|
desc "skip method"
|
81
88
|
|
82
89
|
setup do
|
83
|
-
|
90
|
+
@exception =
|
91
|
+
begin
|
92
|
+
subject.skip(msg1)
|
93
|
+
rescue => ex
|
94
|
+
ex
|
95
|
+
end
|
84
96
|
@result = Factory.skip_result(@exception)
|
85
97
|
end
|
86
98
|
|
@@ -98,7 +110,12 @@ class Assert::Context
|
|
98
110
|
assert_that(@exception.backtrace.size).does_not_equal(1)
|
99
111
|
|
100
112
|
called_from = Factory.string
|
101
|
-
|
113
|
+
exception =
|
114
|
+
begin
|
115
|
+
subject.skip(msg1, called_from)
|
116
|
+
rescue => ex
|
117
|
+
ex
|
118
|
+
end
|
102
119
|
assert_that(exception.backtrace.size).equals(1)
|
103
120
|
assert_that(exception.backtrace.first).equals(called_from)
|
104
121
|
end
|
@@ -180,14 +197,20 @@ class Assert::Context
|
|
180
197
|
|
181
198
|
class HaltOnFailTests < InitTests
|
182
199
|
desc "failing when halting on fails"
|
183
|
-
subject
|
200
|
+
subject{ context_class1.new(test1, halt_config1, result_callback1) }
|
184
201
|
|
185
202
|
should "raise an exception with the failure's message" do
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
203
|
+
exception =
|
204
|
+
begin
|
205
|
+
subject.fail(msg1)
|
206
|
+
rescue => ex
|
207
|
+
ex
|
208
|
+
end
|
209
|
+
assert_that(exception).is_kind_of(Assert::Result::TestFailure)
|
210
|
+
assert_that(exception.message).equals(msg1)
|
211
|
+
|
212
|
+
result =
|
213
|
+
Assert::Result::Fail.for_test(Factory.test("something"), exception)
|
191
214
|
assert_that(result.message).equals(msg1)
|
192
215
|
end
|
193
216
|
|
@@ -199,7 +222,7 @@ class Assert::Context
|
|
199
222
|
class AssertTests < InitTests
|
200
223
|
desc "assert method"
|
201
224
|
|
202
|
-
let(:what_failed)
|
225
|
+
let(:what_failed){ Factory.string }
|
203
226
|
|
204
227
|
should "return a pass result given a `true` assertion" do
|
205
228
|
result = subject.assert(true, msg1){ what_failed }
|
@@ -213,7 +236,8 @@ class Assert::Context
|
|
213
236
|
end
|
214
237
|
|
215
238
|
should "pp the assertion value in the fail message by default" do
|
216
|
-
exp_def_what =
|
239
|
+
exp_def_what =
|
240
|
+
"Failed assert: assertion was `#{Assert::U.show(false, test1.config)}`."
|
217
241
|
result = subject.assert(false, msg1)
|
218
242
|
|
219
243
|
assert_that(result.message).equals([msg1, exp_def_what].join("\n"))
|
@@ -248,7 +272,9 @@ class Assert::Context
|
|
248
272
|
end
|
249
273
|
|
250
274
|
should "pp the assertion value in the fail message by default" do
|
251
|
-
exp_def_what =
|
275
|
+
exp_def_what =
|
276
|
+
"Failed assert_not: "\
|
277
|
+
"assertion was `#{Assert::U.show(true, test1.config)}`."
|
252
278
|
result = subject.assert_not(true, msg1)
|
253
279
|
|
254
280
|
assert_that(result.message).equals([msg1, exp_def_what].join("\n"))
|
@@ -267,32 +293,32 @@ class Assert::Context
|
|
267
293
|
desc "`assert_that` method"
|
268
294
|
|
269
295
|
setup do
|
270
|
-
Assert.stub_tap_on_call(Assert::ActualValue, :new)
|
296
|
+
Assert.stub_tap_on_call(Assert::ActualValue, :new) do |_, call|
|
271
297
|
@actual_value_new_call = call
|
272
|
-
|
298
|
+
end
|
273
299
|
end
|
274
300
|
|
275
|
-
let(:actual_value)
|
301
|
+
let(:actual_value){ Factory.string }
|
276
302
|
|
277
303
|
should "build an Assert::ActualValue" do
|
278
304
|
assert_instance_of Assert::ActualValue, subject.assert_that(actual_value)
|
279
305
|
assert_equal [actual_value], @actual_value_new_call.pargs
|
280
|
-
assert_equal({ context: subject },
|
306
|
+
assert_equal({ context: subject }, @actual_value_new_call.kargs)
|
281
307
|
end
|
282
308
|
end
|
283
309
|
|
284
310
|
class SubjectTests < InitTests
|
285
311
|
desc "subject method"
|
286
|
-
subject
|
312
|
+
subject{ context_class1.new(test1, test1.config, proc{ |result| }) }
|
287
313
|
|
288
314
|
setup do
|
289
315
|
expected = expected1
|
290
|
-
context_class1.subject
|
316
|
+
context_class1.subject{ @something = expected }
|
291
317
|
@subject = subject.subject
|
292
318
|
end
|
293
319
|
|
294
|
-
let(:context_class1)
|
295
|
-
let(:expected1)
|
320
|
+
let(:context_class1){ Factory.modes_off_context_class }
|
321
|
+
let(:expected1){ Factory.string }
|
296
322
|
|
297
323
|
should "instance evaluate the block set with the class setup method" do
|
298
324
|
assert_that(@subject).equals(expected1)
|
@@ -302,8 +328,17 @@ class Assert::Context
|
|
302
328
|
class PendingTests < InitTests
|
303
329
|
desc "`pending` method"
|
304
330
|
|
305
|
-
let(:block2)
|
306
|
-
|
331
|
+
let(:block2) do
|
332
|
+
proc do
|
333
|
+
fail # rubocop:disable Style/SignalException
|
334
|
+
pass # rubocop:disable Lint/UnreachableCode
|
335
|
+
end
|
336
|
+
end
|
337
|
+
# test nesting
|
338
|
+
let(:block1) do
|
339
|
+
block = block2
|
340
|
+
proc{ pending(&block) }
|
341
|
+
end
|
307
342
|
|
308
343
|
should "make fails skips and make passes fails" do
|
309
344
|
subject.fail "not affected"
|
@@ -326,29 +361,42 @@ class Assert::Context
|
|
326
361
|
|
327
362
|
class PendingWithHaltOnFailTests < PendingTests
|
328
363
|
desc "when halting on fails"
|
329
|
-
subject
|
364
|
+
subject{ context_class1.new(test1, halt_config1, result_callback1) }
|
330
365
|
|
331
366
|
should "make fails skips and stop the test" do
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
367
|
+
exception =
|
368
|
+
begin
|
369
|
+
subject.pending(&block1)
|
370
|
+
rescue => ex
|
371
|
+
ex
|
372
|
+
end
|
373
|
+
assert_that(exception).is_kind_of(Assert::Result::TestSkipped)
|
374
|
+
assert_that(exception.message).includes("Pending fail")
|
375
|
+
|
376
|
+
# it halted before the pending pass
|
377
|
+
assert_that(test_results1.size).equals(0)
|
337
378
|
end
|
338
379
|
end
|
339
380
|
|
340
381
|
class WithBacktraceTests < InitTests
|
341
382
|
desc "`with_backtrace` method"
|
342
383
|
|
343
|
-
let(:from_bt1)
|
344
|
-
let(:from_block1)
|
384
|
+
let(:from_bt1){ ["called_from_here", Factory.string] }
|
385
|
+
let(:from_block1) do
|
386
|
+
proc do
|
387
|
+
ignore
|
388
|
+
fail # rubocop:disable Style/SignalException
|
389
|
+
pass # rubocop:disable Lint/UnreachableCode
|
390
|
+
skip "todo"
|
391
|
+
end
|
392
|
+
end
|
345
393
|
|
346
394
|
should "alter non-error block results' bt with given bt's first line" do
|
347
395
|
subject.fail "not affected"
|
348
396
|
begin
|
349
397
|
subject.with_backtrace(from_bt1, &from_block1)
|
350
|
-
rescue Assert::Result::TestSkipped =>
|
351
|
-
test_results1 << Assert::Result::Skip.for_test(test1,
|
398
|
+
rescue Assert::Result::TestSkipped => ex
|
399
|
+
test_results1 << Assert::Result::Skip.for_test(test1, ex)
|
352
400
|
end
|
353
401
|
|
354
402
|
assert_that(test_results1.size).equals(5)
|
@@ -367,21 +415,29 @@ class Assert::Context
|
|
367
415
|
class WithNestedBacktraceTests < InitTests
|
368
416
|
desc "`with_backtrace` method nested"
|
369
417
|
|
370
|
-
let(:from_bt1)
|
371
|
-
let(:from_bt2)
|
372
|
-
let(:from_block2)
|
373
|
-
|
418
|
+
let(:from_bt1){ ["called_from_here 1", Factory.string] }
|
419
|
+
let(:from_bt2){ ["called_from_here 2", Factory.string] }
|
420
|
+
let(:from_block2) do
|
421
|
+
proc do
|
422
|
+
ignore
|
423
|
+
fail # rubocop:disable Style/SignalException
|
424
|
+
pass # rubocop:disable Lint/UnreachableCode
|
425
|
+
skip "todo"
|
426
|
+
end
|
427
|
+
end
|
428
|
+
let(:from_block1) do
|
374
429
|
from_bt = from_bt2
|
375
430
|
from_block = from_block2
|
376
|
-
proc
|
377
|
-
|
431
|
+
proc{ with_backtrace(from_bt, &from_block) }
|
432
|
+
end
|
378
433
|
|
379
|
-
should "alter non-error block results' bt with nested wbt accrued
|
434
|
+
should "alter non-error block results' bt with nested wbt accrued "\
|
435
|
+
"first lines" do
|
380
436
|
subject.fail "not affected"
|
381
437
|
begin
|
382
438
|
subject.with_backtrace(from_bt1, &from_block1)
|
383
|
-
rescue Assert::Result::TestSkipped =>
|
384
|
-
test_results1 << Assert::Result::Skip.for_test(test1,
|
439
|
+
rescue Assert::Result::TestSkipped => ex
|
440
|
+
test_results1 << Assert::Result::Skip.for_test(test1, ex)
|
385
441
|
end
|
386
442
|
|
387
443
|
assert_that(test_results1.size).equals(5)
|