assert 2.18.2 → 2.19.2
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/README.md +7 -6
- data/assert.gemspec +5 -2
- data/bin/assert +1 -0
- data/lib/assert.rb +2 -0
- data/lib/assert/actual_value.rb +143 -0
- data/lib/assert/assert_runner.rb +2 -0
- data/lib/assert/assertions.rb +82 -20
- data/lib/assert/cli.rb +2 -0
- data/lib/assert/config.rb +2 -0
- data/lib/assert/config_helpers.rb +2 -0
- data/lib/assert/context.rb +33 -37
- data/lib/assert/context/let_dsl.rb +16 -0
- data/lib/assert/context/method_missing.rb +22 -0
- data/lib/assert/context/setup_dsl.rb +3 -0
- data/lib/assert/context/subject_dsl.rb +26 -24
- data/lib/assert/context/suite_dsl.rb +3 -0
- data/lib/assert/context/test_dsl.rb +3 -0
- data/lib/assert/context_info.rb +2 -0
- data/lib/assert/default_runner.rb +2 -0
- data/lib/assert/default_suite.rb +2 -0
- data/lib/assert/default_view.rb +2 -0
- data/lib/assert/factory.rb +2 -0
- data/lib/assert/file_line.rb +2 -0
- data/lib/assert/macro.rb +2 -0
- data/lib/assert/macros/methods.rb +6 -4
- data/lib/assert/result.rb +8 -1
- data/lib/assert/runner.rb +2 -0
- data/lib/assert/stub.rb +45 -0
- data/lib/assert/suite.rb +9 -10
- data/lib/assert/test.rb +3 -9
- data/lib/assert/utils.rb +3 -1
- data/lib/assert/version.rb +3 -1
- data/lib/assert/view.rb +2 -0
- data/lib/assert/view_helpers.rb +2 -0
- data/test/helper.rb +28 -28
- data/test/support/factory.rb +17 -0
- data/test/support/inherited_stuff.rb +2 -0
- data/test/system/stub_tests.rb +334 -333
- data/test/system/test_tests.rb +101 -109
- data/test/unit/actual_value_tests.rb +373 -0
- data/test/unit/assert_tests.rb +79 -61
- data/test/unit/assertions/assert_block_tests.rb +32 -31
- data/test/unit/assertions/assert_changes_tests.rb +99 -0
- data/test/unit/assertions/assert_empty_tests.rb +35 -32
- data/test/unit/assertions/assert_equal_tests.rb +96 -74
- data/test/unit/assertions/assert_file_exists_tests.rb +34 -33
- data/test/unit/assertions/assert_includes_tests.rb +40 -37
- data/test/unit/assertions/assert_instance_of_tests.rb +36 -33
- data/test/unit/assertions/assert_kind_of_tests.rb +36 -33
- data/test/unit/assertions/assert_match_tests.rb +36 -33
- data/test/unit/assertions/assert_nil_tests.rb +32 -31
- data/test/unit/assertions/assert_raises_tests.rb +57 -55
- data/test/unit/assertions/assert_respond_to_tests.rb +38 -35
- data/test/unit/assertions/assert_same_tests.rb +88 -81
- data/test/unit/assertions/assert_true_false_tests.rb +62 -60
- data/test/unit/assertions_tests.rb +28 -24
- data/test/unit/config_helpers_tests.rb +45 -38
- data/test/unit/config_tests.rb +40 -34
- data/test/unit/context/let_dsl_tests.rb +12 -0
- data/test/unit/context/setup_dsl_tests.rb +72 -81
- data/test/unit/context/subject_dsl_tests.rb +17 -43
- data/test/unit/context/suite_dsl_tests.rb +17 -16
- data/test/unit/context/test_dsl_tests.rb +52 -52
- data/test/unit/context_info_tests.rb +25 -15
- data/test/unit/context_tests.rb +186 -179
- data/test/unit/default_runner_tests.rb +4 -5
- data/test/unit/default_suite_tests.rb +59 -53
- data/test/unit/factory_tests.rb +7 -3
- data/test/unit/file_line_tests.rb +35 -35
- data/test/unit/macro_tests.rb +16 -10
- data/test/unit/result_tests.rb +161 -183
- data/test/unit/runner_tests.rb +67 -65
- data/test/unit/suite_tests.rb +58 -59
- data/test/unit/test_tests.rb +120 -139
- data/test/unit/utils_tests.rb +45 -45
- data/test/unit/view_helpers_tests.rb +56 -52
- data/test/unit/view_tests.rb +24 -23
- metadata +29 -6
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/config_helpers"
|
3
5
|
|
@@ -6,19 +8,24 @@ require "assert/config"
|
|
6
8
|
module Assert::ConfigHelpers
|
7
9
|
class UnitTests < Assert::Context
|
8
10
|
desc "Assert::ConfigHelpers"
|
9
|
-
|
10
|
-
|
11
|
+
subject { unit_class }
|
12
|
+
|
13
|
+
let(:unit_class) {
|
14
|
+
Class.new do
|
11
15
|
include Assert::ConfigHelpers
|
12
16
|
|
13
17
|
def config
|
14
18
|
# use the assert config since it has tests, contexts, etc
|
15
|
-
# also
|
19
|
+
# also use a fresh config that is empty
|
16
20
|
@config ||= [Assert.config, Assert::Config.new].sample
|
17
21
|
end
|
18
22
|
end
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
class InitTests < UnitTests
|
27
|
+
desc "when init"
|
28
|
+
subject { unit_class.new }
|
22
29
|
|
23
30
|
should have_imeths :runner, :suite, :view
|
24
31
|
should have_imeths :runner_seed, :single_test?, :single_test_file_line
|
@@ -34,67 +41,67 @@ module Assert::ConfigHelpers
|
|
34
41
|
should have_imeths :ocurring_result_types
|
35
42
|
|
36
43
|
should "know the config's runner, suite and view" do
|
37
|
-
|
38
|
-
|
39
|
-
|
44
|
+
assert_that(subject.runner).equals(subject.config.runner)
|
45
|
+
assert_that(subject.suite).equals(subject.config.suite)
|
46
|
+
assert_that(subject.view).equals(subject.config.view)
|
40
47
|
end
|
41
48
|
|
42
49
|
should "know its runner seed" do
|
43
|
-
|
50
|
+
assert_that(subject.runner_seed).equals(subject.config.runner_seed)
|
44
51
|
end
|
45
52
|
|
46
53
|
should "know if it is in single test mode" do
|
47
|
-
Assert.stub(subject.config, :single_test?){ true }
|
48
|
-
|
54
|
+
Assert.stub(subject.config, :single_test?) { true }
|
55
|
+
assert_that(subject.single_test?).is_true
|
49
56
|
|
50
|
-
Assert.stub(subject.config, :single_test?){ false }
|
51
|
-
|
57
|
+
Assert.stub(subject.config, :single_test?) { false }
|
58
|
+
assert_that(subject.single_test?).is_false
|
52
59
|
end
|
53
60
|
|
54
61
|
should "know its single test file line" do
|
55
62
|
exp = subject.config.single_test_file_line
|
56
|
-
|
63
|
+
assert_that(subject.single_test_file_line).equals(exp)
|
57
64
|
end
|
58
65
|
|
59
66
|
should "know its tests-to-run attrs" do
|
60
67
|
exp = subject.config.suite.tests_to_run?
|
61
|
-
|
68
|
+
assert_that(subject.tests_to_run?).equals(exp)
|
62
69
|
|
63
70
|
exp = subject.config.suite.tests_to_run_count
|
64
|
-
|
71
|
+
assert_that(subject.tests_to_run_count).equals(exp)
|
65
72
|
end
|
66
73
|
|
67
74
|
should "know its test/result counts" do
|
68
75
|
exp = subject.config.suite.test_count
|
69
|
-
|
76
|
+
assert_that(subject.test_count).equals(exp)
|
70
77
|
|
71
78
|
exp = subject.config.suite.result_count
|
72
|
-
|
79
|
+
assert_that(subject.result_count).equals(exp)
|
73
80
|
|
74
81
|
exp = subject.config.suite.pass_result_count
|
75
|
-
|
82
|
+
assert_that(subject.pass_result_count).equals(exp)
|
76
83
|
|
77
84
|
exp = subject.config.suite.fail_result_count
|
78
|
-
|
85
|
+
assert_that(subject.fail_result_count).equals(exp)
|
79
86
|
|
80
87
|
exp = subject.config.suite.error_result_count
|
81
|
-
|
88
|
+
assert_that(subject.error_result_count).equals(exp)
|
82
89
|
|
83
90
|
exp = subject.config.suite.skip_result_count
|
84
|
-
|
91
|
+
assert_that(subject.skip_result_count).equals(exp)
|
85
92
|
|
86
93
|
exp = subject.config.suite.ignore_result_count
|
87
|
-
|
94
|
+
assert_that(subject.ignore_result_count).equals(exp)
|
88
95
|
end
|
89
96
|
|
90
97
|
should "know if all tests are passing or not" do
|
91
98
|
result_count = Factory.integer
|
92
99
|
Assert.stub(subject, :result_count){ result_count }
|
93
100
|
Assert.stub(subject, :pass_result_count){ result_count }
|
94
|
-
|
101
|
+
assert_that(subject.all_pass?).is_true
|
95
102
|
|
96
103
|
Assert.stub(subject, :pass_result_count){ Factory.integer }
|
97
|
-
|
104
|
+
assert_that(subject.all_pass?).is_false
|
98
105
|
end
|
99
106
|
|
100
107
|
should "know its formatted run time, test rate and result rate" do
|
@@ -102,39 +109,39 @@ module Assert::ConfigHelpers
|
|
102
109
|
|
103
110
|
run_time = Factory.float
|
104
111
|
exp = format % run_time
|
105
|
-
|
106
|
-
|
112
|
+
assert_that(subject.formatted_run_time(run_time, format)).equals(exp)
|
113
|
+
assert_that(subject.formatted_run_time(run_time)).equals(exp)
|
107
114
|
|
108
115
|
test_rate = Factory.float
|
109
116
|
exp = format % test_rate
|
110
|
-
|
111
|
-
|
117
|
+
assert_that(subject.formatted_result_rate(test_rate, format)).equals(exp)
|
118
|
+
assert_that(subject.formatted_result_rate(test_rate)).equals(exp)
|
112
119
|
|
113
120
|
result_rate = Factory.float
|
114
121
|
exp = format % result_rate
|
115
|
-
|
116
|
-
|
122
|
+
assert_that(subject.formatted_result_rate(result_rate, format)).equals(exp)
|
123
|
+
assert_that(subject.formatted_result_rate(result_rate)).equals(exp)
|
117
124
|
end
|
118
125
|
|
119
126
|
should "know its formatted suite run time, test rate and result rate" do
|
120
127
|
format = "%.6f"
|
121
128
|
|
122
129
|
exp = format % subject.config.suite.run_time
|
123
|
-
|
130
|
+
assert_that(subject.formatted_suite_run_time(format)).equals(exp)
|
124
131
|
|
125
132
|
exp = format % subject.config.suite.test_rate
|
126
|
-
|
133
|
+
assert_that(subject.formatted_suite_test_rate(format)).equals(exp)
|
127
134
|
|
128
135
|
exp = format % subject.config.suite.result_rate
|
129
|
-
|
136
|
+
assert_that(subject.formatted_suite_result_rate(format)).equals(exp)
|
130
137
|
end
|
131
138
|
|
132
139
|
should "know whether to show test profile info" do
|
133
|
-
|
140
|
+
assert_that(subject.show_test_profile_info?).equals(!!subject.config.profile)
|
134
141
|
end
|
135
142
|
|
136
143
|
should "know whether to show verbose info" do
|
137
|
-
|
144
|
+
assert_that(subject.show_test_verbose_info?).equals(!!subject.config.verbose)
|
138
145
|
end
|
139
146
|
|
140
147
|
should "know what result types occur in a suite's results" do
|
@@ -145,7 +152,7 @@ module Assert::ConfigHelpers
|
|
145
152
|
exp = result_types.select do |type_sym|
|
146
153
|
subject.send("#{type_sym}_result_count") > 0
|
147
154
|
end
|
148
|
-
|
155
|
+
assert_that(subject.ocurring_result_types).equals(exp)
|
149
156
|
end
|
150
157
|
end
|
151
158
|
end
|
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,10 +12,14 @@ require "assert/runner"
|
|
10
12
|
class Assert::Config
|
11
13
|
class UnitTests < Assert::Context
|
12
14
|
desc "Assert::Config"
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
subject { unit_class }
|
16
|
+
|
17
|
+
let(:unit_class) { Assert::Config }
|
18
|
+
end
|
19
|
+
|
20
|
+
class InitTests < UnitTests
|
21
|
+
desc "when init"
|
22
|
+
subject { unit_class.new }
|
17
23
|
|
18
24
|
should have_imeths :view, :suite, :runner
|
19
25
|
should have_imeths :test_dir, :test_helper, :test_file_suffixes
|
@@ -25,73 +31,73 @@ class Assert::Config
|
|
25
31
|
should have_imeths :single_test_file_line, :single_test_file_path
|
26
32
|
|
27
33
|
should "default the view, suite, and runner" do
|
28
|
-
|
29
|
-
|
30
|
-
|
34
|
+
assert_that(subject.view).is_kind_of(Assert::DefaultView)
|
35
|
+
assert_that(subject.suite).is_kind_of(Assert::DefaultSuite)
|
36
|
+
assert_that(subject.runner).is_kind_of(Assert::DefaultRunner)
|
31
37
|
end
|
32
38
|
|
33
39
|
should "default the test dir/helper/suffixes" do
|
34
|
-
|
35
|
-
|
36
|
-
|
40
|
+
assert_that(subject.test_dir).equals("test")
|
41
|
+
assert_that(subject.test_helper).equals("helper.rb")
|
42
|
+
assert_that(subject.test_file_suffixes).equals(["_tests.rb", "_test.rb"])
|
37
43
|
end
|
38
44
|
|
39
45
|
should "default the procs" do
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
46
|
+
assert_that(subject.changed_proc).is_not_nil
|
47
|
+
assert_that(subject.pp_proc).is_not_nil
|
48
|
+
assert_that(subject.use_diff_proc).is_not_nil
|
49
|
+
assert_that(subject.run_diff_proc).is_not_nil
|
44
50
|
end
|
45
51
|
|
46
52
|
should "default the option settings" do
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
assert_that(subject.runner_seed).is_not_nil
|
54
|
+
assert_that(subject.changed_only).is_false
|
55
|
+
assert_that(subject.changed_ref).is_empty
|
56
|
+
assert_that(subject.single_test).is_empty
|
57
|
+
assert_that(subject.pp_objects).is_false
|
58
|
+
assert_that(subject.capture_output).is_false
|
59
|
+
assert_that(subject.halt_on_fail).is_true
|
60
|
+
assert_that(subject.profile).is_false
|
61
|
+
assert_that(subject.verbose).is_false
|
62
|
+
assert_that(subject.list).is_false
|
63
|
+
assert_that(subject.debug).is_false
|
58
64
|
end
|
59
65
|
|
60
66
|
should "apply settings given from a hash" do
|
61
67
|
assert subject.halt_on_fail
|
62
68
|
subject.apply(:halt_on_fail => false)
|
63
|
-
|
69
|
+
assert_that(subject.halt_on_fail).is_false
|
64
70
|
|
65
|
-
|
66
|
-
|
71
|
+
assert_that(Assert::Config.new.halt_on_fail).is_true
|
72
|
+
assert_that(Assert::Config.new(:halt_on_fail => false).halt_on_fail).is_false
|
67
73
|
end
|
68
74
|
|
69
75
|
should "know if it is in single test mode" do
|
70
|
-
|
76
|
+
assert_that(subject.single_test?).is_false
|
71
77
|
|
72
78
|
subject.apply(:single_test => Factory.string)
|
73
|
-
|
79
|
+
assert_that(subject.single_test?).is_true
|
74
80
|
end
|
75
81
|
|
76
82
|
should "know its single test file line" do
|
77
83
|
exp = Assert::FileLine.parse(File.expand_path("", Dir.pwd))
|
78
|
-
|
84
|
+
assert_that(subject.single_test_file_line).equals(exp)
|
79
85
|
|
80
86
|
file_line_path = "#{Factory.path}_tests.rb:#{Factory.integer}"
|
81
87
|
subject.apply(:single_test => file_line_path)
|
82
88
|
|
83
89
|
exp = Assert::FileLine.parse(File.expand_path(file_line_path, Dir.pwd))
|
84
|
-
|
90
|
+
assert_that(subject.single_test_file_line).equals(exp)
|
85
91
|
end
|
86
92
|
|
87
93
|
should "know its single test file path" do
|
88
94
|
exp = Assert::FileLine.parse(File.expand_path("", Dir.pwd)).file
|
89
|
-
|
95
|
+
assert_that(subject.single_test_file_path).equals(exp)
|
90
96
|
|
91
97
|
path = "#{Factory.path}_tests.rb"
|
92
98
|
file_line_path = "#{path}:#{Factory.integer}"
|
93
99
|
subject.apply(:single_test => file_line_path)
|
94
|
-
|
100
|
+
assert_that(subject.single_test_file_path).equals(File.expand_path(path, Dir.pwd))
|
95
101
|
end
|
96
102
|
end
|
97
103
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "assert"
|
4
|
+
require "assert/context/let_dsl"
|
5
|
+
|
6
|
+
module Assert::Context::LetDSL
|
7
|
+
class UnitTests < Assert::Context
|
8
|
+
desc "Assert::Context::LetDSL"
|
9
|
+
|
10
|
+
# This is tested implicitly by running Assert's test suite.
|
11
|
+
end
|
12
|
+
end
|
@@ -1,80 +1,70 @@
|
|
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 }
|
10
|
+
|
11
|
+
let(:block1) { ::Proc.new {} }
|
8
12
|
end
|
9
13
|
|
10
14
|
class SetupTeardownOnceMethodsTests < UnitTests
|
11
15
|
desc "once methods"
|
12
|
-
setup do
|
13
|
-
block = @block = ::Proc.new{ something_once = true }
|
14
|
-
@context_class = Factory.modes_off_context_class do
|
15
|
-
setup_once(&block)
|
16
|
-
teardown_once(&block)
|
17
|
-
end
|
18
|
-
end
|
19
16
|
|
20
17
|
should "add the block to the suite" do
|
21
|
-
|
22
|
-
|
18
|
+
subject.setup_once(&block1)
|
19
|
+
subject.teardown_once(&block1)
|
20
|
+
|
21
|
+
assert_that(subject.suite.send(:setups)).includes(block1)
|
22
|
+
assert_that(subject.suite.send(:teardowns)).includes(block1)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
class SetupTeardownMethodsTests < UnitTests
|
27
27
|
desc "methods"
|
28
|
-
setup do
|
29
|
-
block = @block = ::Proc.new{ something = true }
|
30
|
-
@context_class = Factory.modes_off_context_class do
|
31
|
-
setup(&block)
|
32
|
-
teardown(&block)
|
33
|
-
end
|
34
|
-
end
|
35
28
|
|
36
29
|
should "add the block to the context" do
|
37
|
-
|
38
|
-
|
30
|
+
subject.setup(&block1)
|
31
|
+
subject.teardown(&block1)
|
32
|
+
|
33
|
+
assert_that(subject.send(:setups)).includes(block1)
|
34
|
+
assert_that(subject.send(:teardowns)).includes(block1)
|
39
35
|
end
|
40
36
|
end
|
41
37
|
|
42
38
|
class SetupTeardownWithMethodNameTests < UnitTests
|
43
39
|
desc "methods given a method name"
|
44
|
-
|
45
|
-
|
46
|
-
@context_class = Factory.modes_off_context_class do
|
47
|
-
setup(method_name)
|
48
|
-
teardown(method_name)
|
49
|
-
end
|
50
|
-
end
|
40
|
+
|
41
|
+
let(:method_name1) { :something_amazing }
|
51
42
|
|
52
43
|
should "add the method name to the context" do
|
53
|
-
|
54
|
-
|
44
|
+
subject.setup(method_name1)
|
45
|
+
subject.teardown(method_name1)
|
46
|
+
|
47
|
+
assert_that(subject.send(:setups)).includes(method_name1)
|
48
|
+
assert_that(subject.send(:teardowns)).includes(method_name1)
|
55
49
|
end
|
56
50
|
end
|
57
51
|
|
58
|
-
class
|
52
|
+
class ParentContextClassTests < UnitTests
|
53
|
+
subject { Factory.modes_off_context_class(parent_class1) }
|
54
|
+
|
55
|
+
let(:parent_class1) { Factory.modes_off_context_class }
|
56
|
+
end
|
57
|
+
|
58
|
+
class SetupTeardownMultipleTests < ParentContextClassTests
|
59
59
|
desc "with multiple calls"
|
60
|
-
setup do
|
61
|
-
parent_setup_block = ::Proc.new{ self.setup_status = "the setup" }
|
62
|
-
parent_teardown_block = ::Proc.new{ self.teardown_status += "the teardown" }
|
63
|
-
@parent_class = Factory.modes_off_context_class do
|
64
|
-
setup(&parent_setup_block)
|
65
|
-
teardown(&parent_teardown_block)
|
66
|
-
end
|
67
60
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
setup(:setup_something)
|
73
|
-
teardown(:teardown_something)
|
74
|
-
teardown(&context_teardown_block)
|
75
|
-
end
|
61
|
+
let(:parent_setup_block1) { ::Proc.new { self.setup_status = "the setup" } }
|
62
|
+
let(:parent_teardown_block1) { ::Proc.new { self.teardown_status += "the teardown" } }
|
63
|
+
let(:context_setup_block1) { ::Proc.new { self.setup_status += " has been run" } }
|
64
|
+
let(:context_teardown_block1) { ::Proc.new { self.teardown_status += "has been run " } }
|
76
65
|
|
77
|
-
|
66
|
+
let(:test_status_class) {
|
67
|
+
Class.new do
|
78
68
|
attr_accessor :setup_status, :teardown_status
|
79
69
|
define_method(:setup_something) do
|
80
70
|
self.setup_status += " with something"
|
@@ -83,57 +73,58 @@ module Assert::Context::SetupDSL
|
|
83
73
|
self.teardown_status = "with something "
|
84
74
|
end
|
85
75
|
end
|
86
|
-
|
76
|
+
}
|
77
|
+
|
78
|
+
should "run its parent and its own blocks in the correct order" do
|
79
|
+
parent_class1.setup(&parent_setup_block1)
|
80
|
+
parent_class1.teardown(&parent_teardown_block1)
|
81
|
+
subject.setup(&context_setup_block1)
|
82
|
+
subject.setup(:setup_something)
|
83
|
+
subject.teardown(:teardown_something)
|
84
|
+
subject.teardown(&context_teardown_block1)
|
87
85
|
|
88
|
-
|
89
|
-
|
90
|
-
assert_equal "the setup has been run with something", obj.setup_status
|
86
|
+
subject.send("run_setups", obj = test_status_class.new)
|
87
|
+
assert_that(obj.setup_status).equals("the setup has been run with something")
|
91
88
|
|
92
|
-
subject.send("run_teardowns", obj =
|
93
|
-
|
89
|
+
subject.send("run_teardowns", obj = test_status_class.new)
|
90
|
+
assert_that(obj.teardown_status).equals("with something has been run the teardown")
|
94
91
|
end
|
95
92
|
end
|
96
93
|
|
97
|
-
class AroundMethodTests <
|
94
|
+
class AroundMethodTests < ParentContextClassTests
|
98
95
|
desc "with multiple `around` calls"
|
99
|
-
setup do
|
100
|
-
@parent_class = Factory.modes_off_context_class do
|
101
|
-
around do |block|
|
102
|
-
self.out_status ||= ""
|
103
|
-
self.out_status += "p-around start, "
|
104
|
-
block.call
|
105
|
-
self.out_status += "p-around end."
|
106
|
-
end
|
107
|
-
end
|
108
96
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
block.call
|
118
|
-
self.out_status += "c-around2 end, "
|
119
|
-
end
|
97
|
+
let(:test_status_class) { Class.new { attr_accessor :out_status } }
|
98
|
+
|
99
|
+
should "run its parent and its own blocks in the correct order" do
|
100
|
+
parent_class1.around do |block|
|
101
|
+
self.out_status ||= ""
|
102
|
+
self.out_status += "p-around start, "
|
103
|
+
block.call
|
104
|
+
self.out_status += "p-around end."
|
120
105
|
end
|
121
106
|
|
122
|
-
|
123
|
-
|
107
|
+
subject.around do |block|
|
108
|
+
self.out_status += "c-around1 start, "
|
109
|
+
block.call
|
110
|
+
self.out_status += "c-around1 end, "
|
111
|
+
end
|
112
|
+
subject.around do |block|
|
113
|
+
self.out_status += "c-around2 start, "
|
114
|
+
block.call
|
115
|
+
self.out_status += "c-around2 end, "
|
124
116
|
end
|
125
|
-
end
|
126
117
|
|
127
|
-
|
128
|
-
obj = @test_status_class.new
|
118
|
+
obj = test_status_class.new
|
129
119
|
subject.send("run_arounds", obj) do
|
130
120
|
obj.instance_eval{ self.out_status += "TEST, " }
|
131
121
|
end
|
132
122
|
|
133
|
-
exp =
|
134
|
-
|
135
|
-
|
136
|
-
|
123
|
+
exp =
|
124
|
+
"p-around start, c-around1 start, c-around2 start, "\
|
125
|
+
"TEST, "\
|
126
|
+
"c-around2 end, c-around1 end, p-around end."
|
127
|
+
assert_that(obj.out_status).equals(exp)
|
137
128
|
end
|
138
129
|
end
|
139
130
|
end
|