assert 2.0.0.rc.1 → 2.0.0
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.
- data/Gemfile +1 -1
- data/{LICENSE → LICENSE.txt} +0 -0
- data/Rakefile +1 -3
- data/assert.gemspec +15 -15
- data/lib/assert.rb +1 -2
- data/lib/assert/assert_runner.rb +2 -1
- data/lib/assert/assertions.rb +153 -189
- data/lib/assert/version.rb +1 -1
- data/test/helper.rb +74 -51
- data/test/{fixtures → support}/inherited_stuff.rb +0 -0
- data/test/{test → system}/running_tests.rb +16 -43
- data/test/{assert_test.rb → unit/assert_tests.rb} +0 -0
- data/test/unit/assertions/assert_block_tests.rb +57 -0
- data/test/unit/assertions/assert_empty_tests.rb +58 -0
- data/test/unit/assertions/assert_equal_tests.rb +59 -0
- data/test/unit/assertions/assert_file_exists_tests.rb +59 -0
- data/test/unit/assertions/assert_includes_tests.rb +61 -0
- data/test/unit/assertions/assert_instance_of_tests.rb +61 -0
- data/test/unit/assertions/assert_kind_of_tests.rb +60 -0
- data/test/unit/assertions/assert_match_tests.rb +59 -0
- data/test/unit/assertions/assert_nil_tests.rb +59 -0
- data/test/unit/assertions/assert_raises_tests.rb +73 -0
- data/test/unit/assertions/assert_respond_to_tests.rb +63 -0
- data/test/unit/assertions/assert_same_tests.rb +65 -0
- data/test/unit/assertions_tests.rb +65 -0
- data/test/unit/context/basic_singleton_tests.rb +86 -0
- data/test/unit/context/setup_teardown_singleton_tests.rb +105 -0
- data/test/unit/context/test_should_singleton_tests.rb +134 -0
- data/test/{context_test.rb → unit/context_tests.rb} +53 -131
- data/test/{macro_test.rb → unit/macro_tests.rb} +15 -11
- data/test/{result_test.rb → unit/result_tests.rb} +27 -26
- data/test/{runner_test.rb → unit/runner_tests.rb} +1 -2
- data/test/{suite_test.rb → unit/suite_tests.rb} +63 -95
- data/test/{test_test.rb → unit/test_tests.rb} +45 -77
- data/test/{view/base_tests.rb → unit/view_tests.rb} +0 -1
- metadata +63 -104
- data/CHANGELOG.md +0 -33
- data/test/assertions/assert_block_test.rb +0 -39
- data/test/assertions/assert_empty_test.rb +0 -43
- data/test/assertions/assert_equal_test.rb +0 -43
- data/test/assertions/assert_file_exists_test.rb +0 -43
- data/test/assertions/assert_includes_test.rb +0 -44
- data/test/assertions/assert_instance_of_test.rb +0 -43
- data/test/assertions/assert_kind_of_test.rb +0 -43
- data/test/assertions/assert_match_test.rb +0 -43
- data/test/assertions/assert_nil_test.rb +0 -43
- data/test/assertions/assert_not_block_test.rb +0 -39
- data/test/assertions/assert_not_empty_test.rb +0 -43
- data/test/assertions/assert_not_equal_test.rb +0 -43
- data/test/assertions/assert_not_file_exists_test.rb +0 -43
- data/test/assertions/assert_not_included_test.rb +0 -44
- data/test/assertions/assert_not_instance_of_test.rb +0 -43
- data/test/assertions/assert_not_kind_of_test.rb +0 -43
- data/test/assertions/assert_not_match_test.rb +0 -43
- data/test/assertions/assert_not_nil_test.rb +0 -43
- data/test/assertions/assert_not_respond_to_test.rb +0 -43
- data/test/assertions/assert_not_same_test.rb +0 -45
- data/test/assertions/assert_nothing_raised_test.rb +0 -46
- data/test/assertions/assert_raises_test.rb +0 -49
- data/test/assertions/assert_respond_to_test.rb +0 -43
- data/test/assertions/assert_same_test.rb +0 -45
- data/test/assertions_test.rb +0 -60
- data/test/context/class_methods_test.rb +0 -531
- data/test/fixtures/sample_context.rb +0 -13
- data/test/fixtures/test_root/one_test.rb +0 -0
- data/test/fixtures/test_root/parent/area_one/area_test.rb +0 -0
- data/test/fixtures/test_root/shallow/deeply/nested_test.rb +0 -0
- data/test/fixtures/test_root/shallow/nested_test.rb +0 -0
- data/test/fixtures/test_root/shallow_test.rb +0 -0
- data/test/fixtures/test_root/two_test.rb +0 -0
- data/test/suite/context_info_test.rb +0 -42
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'assert'
|
2
|
-
|
3
2
|
require 'assert/suite'
|
4
3
|
require 'assert/view/base'
|
5
4
|
require 'assert/runner'
|
6
5
|
|
7
6
|
class Assert::Runner
|
8
7
|
|
9
|
-
class
|
8
|
+
class BasicTests < Assert::Context
|
10
9
|
desc "a basic runner"
|
11
10
|
setup do
|
12
11
|
@suite = Assert::Suite.new
|
@@ -1,76 +1,55 @@
|
|
1
1
|
require 'assert'
|
2
|
-
|
3
2
|
require 'assert/suite'
|
4
|
-
require 'assert/context'
|
5
3
|
require 'assert/test'
|
6
|
-
require 'test/
|
7
|
-
require 'test/fixtures/sample_context'
|
8
|
-
|
4
|
+
require 'test/support/inherited_stuff'
|
9
5
|
|
10
6
|
class Assert::Suite
|
11
7
|
|
12
|
-
class
|
8
|
+
class BasicTests < Assert::Context
|
13
9
|
desc "an basic suite"
|
14
10
|
setup do
|
15
11
|
@suite = Assert::Suite.new
|
16
12
|
end
|
17
|
-
subject
|
18
|
-
|
19
|
-
should have_instance_methods :ordered_tests, :results, :ordered_results
|
20
|
-
should have_instance_methods :count, :test_count, :result_count
|
21
|
-
should have_instance_methods :setup, :startup, :teardown, :shutdown
|
13
|
+
subject{ @suite }
|
22
14
|
|
23
|
-
should
|
24
|
-
should
|
25
|
-
should
|
15
|
+
should have_imeths :ordered_tests, :results, :ordered_results, :run_time
|
16
|
+
should have_imeths :count, :test_count, :result_count
|
17
|
+
should have_imeths :setup, :startup, :teardown, :shutdown
|
18
|
+
should have_accessors :tests, :test_methods, :start_time, :end_time
|
26
19
|
|
27
20
|
should "determine a klass' local public test methods" do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
)
|
21
|
+
exp = ["test_subclass_stuff", "test_mixin_stuff", "test_repeated"].sort
|
22
|
+
act = subject.send(:local_public_test_methods, SubStuff).sort.map(&:to_s)
|
23
|
+
assert_equal(exp, act)
|
32
24
|
end
|
33
25
|
|
34
|
-
should "have zero run time by default" do
|
26
|
+
should "have zero a run time by default" do
|
35
27
|
assert_equal 0, subject.run_time
|
36
28
|
end
|
37
29
|
|
38
30
|
end
|
39
31
|
|
40
|
-
class
|
32
|
+
class WithTestsTests < Assert::Context
|
41
33
|
desc "a suite with tests"
|
42
34
|
setup do
|
35
|
+
ci = Factory.context_info(Factory.context_class)
|
43
36
|
@suite = Assert::Suite.new
|
44
|
-
context_class = Factory.context_class
|
45
37
|
@suite.tests = [
|
46
|
-
Factory.test("should
|
47
|
-
Factory.test("should pass",
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
Factory.test("should
|
52
|
-
ignore
|
53
|
-
assert(1==0)
|
54
|
-
refute(1==1)
|
55
|
-
end,
|
56
|
-
Factory.test("should be ignored", Factory.context_info(context_class)) do
|
57
|
-
ignore
|
58
|
-
end,
|
59
|
-
Factory.test("should skip", Factory.context_info(context_class)) do
|
60
|
-
skip
|
61
|
-
ignore
|
62
|
-
assert(1==1)
|
63
|
-
end,
|
64
|
-
Factory.test("should error", Factory.context_info(context_class)) do
|
65
|
-
raise Exception
|
66
|
-
ignore
|
67
|
-
assert(1==1)
|
68
|
-
end
|
38
|
+
Factory.test("should nothing", ci){ },
|
39
|
+
Factory.test("should pass", ci){ assert(1==1); refute(1==0) },
|
40
|
+
Factory.test("should fail", ci){ ignore; assert(1==0); refute(1==1) },
|
41
|
+
Factory.test("should ignored", ci){ ignore },
|
42
|
+
Factory.test("should skip", ci){ skip; ignore; assert(1==1) },
|
43
|
+
Factory.test("should error", ci){ raise Exception; ignore; assert(1==1) }
|
69
44
|
]
|
70
45
|
@suite.tests.each(&:run)
|
71
46
|
end
|
72
47
|
subject{ @suite }
|
73
48
|
|
49
|
+
should "build test instances to run" do
|
50
|
+
assert_kind_of Assert::Test, subject.tests.first
|
51
|
+
end
|
52
|
+
|
74
53
|
should "know how many tests it has" do
|
75
54
|
assert_equal 6, subject.test_count
|
76
55
|
end
|
@@ -107,10 +86,6 @@ class Assert::Suite
|
|
107
86
|
assert_equal 1, subject.result_count(:error)
|
108
87
|
end
|
109
88
|
|
110
|
-
end
|
111
|
-
|
112
|
-
class CountTest < WithTestsTest
|
113
|
-
|
114
89
|
should "count its tests" do
|
115
90
|
assert_equal subject.test_count, subject.count(:tests)
|
116
91
|
end
|
@@ -146,58 +121,33 @@ class Assert::Suite
|
|
146
121
|
|
147
122
|
end
|
148
123
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
should "build test instances to run" do
|
153
|
-
assert_kind_of Assert::Test, subject.tests.first
|
154
|
-
end
|
155
|
-
|
156
|
-
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
class SetupTest < Assert::Context
|
161
|
-
desc "a suite with a setup"
|
124
|
+
class SetupTests < Assert::Context
|
125
|
+
desc "a suite with a setup block"
|
162
126
|
setup do
|
163
127
|
@setup_status = nil
|
164
128
|
@suite = Assert::Suite.new
|
165
129
|
@setup_blocks = []
|
166
130
|
@setup_blocks << ::Proc.new{ @setup_status = "setup" }
|
167
131
|
@setup_blocks << ::Proc.new{ @setup_status += " has been run" }
|
168
|
-
@setup_blocks.each
|
169
|
-
@suite.setup(&setup_block)
|
170
|
-
end
|
171
|
-
@expected = "setup has been run"
|
132
|
+
@setup_blocks.each{ |setup_block| @suite.setup(&setup_block) }
|
172
133
|
end
|
173
134
|
subject{ @setup_status }
|
174
135
|
|
175
136
|
should "set the setup status to the correct message" do
|
176
137
|
@suite.setup
|
177
|
-
assert_equal
|
138
|
+
assert_equal "setup has been run", subject
|
178
139
|
end
|
179
140
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
class SetupsTest < SetupTest
|
185
|
-
desc "when calling the setups method"
|
186
|
-
setup do
|
187
|
-
@setups = @suite.send(:setups)
|
188
|
-
end
|
189
|
-
subject{ @setups }
|
190
|
-
|
191
|
-
should "include the setup we defined on the suite" do
|
141
|
+
should "return the setup blocks with the #setups method" do
|
142
|
+
setups = @suite.send(:setups)
|
192
143
|
@setup_blocks.each do |setup_block|
|
193
|
-
assert_includes setup_block,
|
144
|
+
assert_includes setup_block, setups
|
194
145
|
end
|
195
146
|
end
|
196
|
-
end
|
197
|
-
|
198
147
|
|
148
|
+
end
|
199
149
|
|
200
|
-
class
|
150
|
+
class TeardownTests < Assert::Context
|
201
151
|
desc "a suite with a teardown"
|
202
152
|
setup do
|
203
153
|
@teardown_status = nil
|
@@ -205,10 +155,7 @@ class Assert::Suite
|
|
205
155
|
@teardown_blocks = []
|
206
156
|
@teardown_blocks << ::Proc.new{ @teardown_status += " has been run" }
|
207
157
|
@teardown_blocks << ::Proc.new{ @teardown_status = "teardown" }
|
208
|
-
@teardown_blocks.each
|
209
|
-
@suite.teardown(&teardown_block)
|
210
|
-
end
|
211
|
-
@expected = "teardown has been run"
|
158
|
+
@teardown_blocks.each{ |teardown_block| @suite.teardown(&teardown_block) }
|
212
159
|
end
|
213
160
|
|
214
161
|
should "set the teardown status to the correct message" do
|
@@ -216,22 +163,43 @@ class Assert::Suite
|
|
216
163
|
assert_equal "teardown has been run", @teardown_status
|
217
164
|
end
|
218
165
|
|
166
|
+
should "return the teardown blocks with the #teardowns method" do
|
167
|
+
teardowns = @suite.send(:teardowns)
|
168
|
+
@teardown_blocks.each do |setup_block|
|
169
|
+
assert_includes setup_block, teardowns
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
219
173
|
end
|
220
174
|
|
175
|
+
class ContextInfoTests < Assert::Context
|
176
|
+
desc "a suite's context info"
|
177
|
+
setup do
|
178
|
+
@caller = caller
|
179
|
+
@klass = Assert::Context
|
180
|
+
@info = Assert::Suite::ContextInfo.new(@klass, nil, @caller.first)
|
181
|
+
end
|
182
|
+
subject{ @info }
|
221
183
|
|
184
|
+
should have_readers :called_from, :first_caller, :klass, :file
|
222
185
|
|
223
|
-
|
224
|
-
|
225
|
-
setup do
|
226
|
-
@teardowns = @suite.send(:teardowns)
|
186
|
+
should "set its klass on init" do
|
187
|
+
assert_equal @klass, subject.klass
|
227
188
|
end
|
228
|
-
subject{ @teardowns }
|
229
189
|
|
230
|
-
should "
|
231
|
-
@
|
232
|
-
assert_includes teardown_block, subject
|
233
|
-
end
|
190
|
+
should "set its called_from to the first caller on init" do
|
191
|
+
assert_equal @caller.first, subject.first_caller
|
234
192
|
end
|
193
|
+
|
194
|
+
should "set its file from caller info on init" do
|
195
|
+
assert_equal @caller.first.gsub(/\:[0-9]+.*$/, ''), subject.file
|
196
|
+
end
|
197
|
+
|
198
|
+
should "not have any file info if no caller is given" do
|
199
|
+
info = Assert::Suite::ContextInfo.new(@klass)
|
200
|
+
assert_nil info.file
|
201
|
+
end
|
202
|
+
|
235
203
|
end
|
236
204
|
|
237
205
|
end
|
@@ -1,19 +1,15 @@
|
|
1
1
|
require 'assert'
|
2
|
+
require 'assert/test'
|
2
3
|
|
3
4
|
class Assert::Test
|
4
5
|
|
5
|
-
class
|
6
|
-
desc "
|
6
|
+
class BasicTests < Assert::Context
|
7
|
+
desc "a test obj"
|
7
8
|
setup do
|
8
|
-
test_name = "should do something amazing"
|
9
9
|
@test_code = lambda{ assert(true) }
|
10
|
-
|
11
|
-
@
|
12
|
-
|
13
|
-
end
|
14
|
-
@context_info = Factory.context_info(@context_class)
|
15
|
-
@test = Factory.test(test_name, @context_info, @test_code)
|
16
|
-
@expected_name = [ context_desc, test_name.gsub(/^test:\s+should/, "should") ].join(" ")
|
10
|
+
@context_class = Factory.context_class { desc "context class" }
|
11
|
+
@context_info = Factory.context_info(@context_class)
|
12
|
+
@test = Factory.test("should do something amazing", @context_info, @test_code)
|
17
13
|
end
|
18
14
|
teardown do
|
19
15
|
TEST_ASSERT_SUITE.tests.clear
|
@@ -21,15 +17,16 @@ class Assert::Test
|
|
21
17
|
subject{ @test }
|
22
18
|
|
23
19
|
should have_readers :name, :code, :context_info
|
24
|
-
should
|
25
|
-
should
|
26
|
-
should
|
20
|
+
should have_accessors :results, :output
|
21
|
+
should have_imeths :run, :result_count, :context_class
|
22
|
+
should have_imeths *Assert::Result.types.keys.collect{ |k| "#{k}_results" }
|
27
23
|
|
28
|
-
should "
|
29
|
-
|
24
|
+
should "build its name from the context description" do
|
25
|
+
exp_name = "context class should do something amazing"
|
26
|
+
assert_equal exp_name, subject.name
|
30
27
|
end
|
31
28
|
|
32
|
-
should "
|
29
|
+
should "know it's context class and code" do
|
33
30
|
assert_equal @context_class, subject.context_class
|
34
31
|
assert_equal @test_code, subject.code
|
35
32
|
end
|
@@ -39,22 +36,16 @@ class Assert::Test
|
|
39
36
|
end
|
40
37
|
|
41
38
|
should "have a custom inspect that only shows limited attributes" do
|
42
|
-
|
39
|
+
attrs_string = [:name, :context_info, :results].collect do |method|
|
43
40
|
"@#{method}=#{subject.send(method).inspect}"
|
44
41
|
end.join(" ")
|
45
|
-
expected = "#<#{subject.class} #{
|
42
|
+
expected = "#<#{subject.class} #{attrs_string}>"
|
46
43
|
assert_equal expected, subject.inspect
|
47
44
|
end
|
48
45
|
|
49
46
|
end
|
50
47
|
|
51
|
-
|
52
|
-
# testing <type>_results methods and result_count(<type>)
|
53
|
-
class ResultsTest < BasicTest
|
54
|
-
desc "methods from Assert::Result.types"
|
55
|
-
end
|
56
|
-
|
57
|
-
class PassFailIgnoreTest < ResultsTest
|
48
|
+
class PassFailIgnoreTotalTests < BasicTests
|
58
49
|
setup do
|
59
50
|
@test = Factory.test("pass fail ignore test", @context_info) do
|
60
51
|
ignore("something")
|
@@ -68,74 +59,58 @@ class Assert::Test
|
|
68
59
|
end
|
69
60
|
subject{ @test }
|
70
61
|
|
71
|
-
should "
|
62
|
+
should "know its pass results" do
|
72
63
|
assert_kind_of Array, subject.pass_results
|
73
64
|
assert_equal 2, subject.pass_results.size
|
74
65
|
subject.pass_results.each do |result|
|
75
66
|
assert_kind_of Assert::Result::Pass, result
|
76
67
|
end
|
68
|
+
assert_equal subject.pass_results.size, subject.result_count(:pass)
|
77
69
|
end
|
78
70
|
|
79
|
-
should "
|
80
|
-
assert_equal(subject.pass_results.size, subject.result_count(:pass))
|
81
|
-
end
|
82
|
-
|
83
|
-
should "return the fail results with #fail_results" do
|
71
|
+
should "know its fail results" do
|
84
72
|
assert_kind_of Array, subject.fail_results
|
85
73
|
assert_equal 2, subject.fail_results.size
|
86
74
|
subject.fail_results.each do |result|
|
87
75
|
assert_kind_of Assert::Result::Fail, result
|
88
76
|
end
|
77
|
+
assert_equal subject.fail_results.size, subject.result_count(:fail)
|
89
78
|
end
|
90
79
|
|
91
|
-
should "
|
92
|
-
assert_equal(subject.fail_results.size, subject.result_count(:fail))
|
93
|
-
end
|
94
|
-
|
95
|
-
should "return the ignore results with #ignore_results" do
|
80
|
+
should "know its ignore results" do
|
96
81
|
assert_kind_of Array, subject.ignore_results
|
97
82
|
assert_equal 2, subject.ignore_results.size
|
98
83
|
subject.ignore_results.each do |result|
|
99
84
|
assert_kind_of Assert::Result::Ignore, result
|
100
85
|
end
|
86
|
+
assert_equal subject.ignore_results.size, subject.result_count(:ignore)
|
101
87
|
end
|
102
88
|
|
103
|
-
should "
|
104
|
-
assert_equal(subject.ignore_results.size, subject.result_count(:ignore))
|
105
|
-
end
|
106
|
-
|
107
|
-
should "return the total number of tests with #result_count" do
|
89
|
+
should "know the total number of results" do
|
108
90
|
assert_equal(6, subject.result_count)
|
109
91
|
end
|
110
92
|
|
111
93
|
end
|
112
94
|
|
113
|
-
|
114
|
-
|
115
|
-
class SkipHandlingTest < ResultsTest
|
95
|
+
class SkipHandlingTests < BasicTests
|
116
96
|
setup do
|
117
97
|
@test = Factory.test("skip test", @context_info) { skip }
|
118
98
|
@test.run
|
119
99
|
end
|
120
100
|
subject{ @test }
|
121
101
|
|
122
|
-
should "
|
102
|
+
should "know its skip results" do
|
123
103
|
assert_kind_of Array, subject.skip_results
|
124
104
|
assert_equal 1, subject.skip_results.size
|
125
105
|
subject.skip_results.each do |result|
|
126
106
|
assert_kind_of Assert::Result::Skip, result
|
127
107
|
end
|
128
|
-
|
129
|
-
|
130
|
-
should "return the size of #skip_results with #result_count(:skip)" do
|
131
|
-
assert_equal(subject.skip_results.size, subject.result_count(:skip))
|
108
|
+
assert_equal subject.skip_results.size, subject.result_count(:skip)
|
132
109
|
end
|
133
110
|
|
134
111
|
end
|
135
112
|
|
136
|
-
|
137
|
-
|
138
|
-
class ErrorHandlingTest < ResultsTest
|
113
|
+
class ErrorHandlingTests < BasicTests
|
139
114
|
setup do
|
140
115
|
@test = Factory.test("error test", @context_info) do
|
141
116
|
raise StandardError, "WHAT"
|
@@ -144,23 +119,18 @@ class Assert::Test
|
|
144
119
|
end
|
145
120
|
subject{ @test }
|
146
121
|
|
147
|
-
should "
|
122
|
+
should "know its error results" do
|
148
123
|
assert_kind_of Array, subject.error_results
|
149
124
|
assert_equal 1, subject.error_results.size
|
150
125
|
subject.error_results.each do |result|
|
151
126
|
assert_kind_of Assert::Result::Error, result
|
152
127
|
end
|
153
|
-
|
154
|
-
|
155
|
-
should "return the size of #error_results with #result_count(:error)" do
|
156
|
-
assert_equal(subject.error_results.size, subject.result_count(:error))
|
128
|
+
assert_equal subject.error_results.size, subject.result_count(:error)
|
157
129
|
end
|
158
130
|
|
159
131
|
end
|
160
132
|
|
161
|
-
|
162
|
-
|
163
|
-
class ComparingTest < BasicTest
|
133
|
+
class ComparingTests < BasicTests
|
164
134
|
desc "<=> another test"
|
165
135
|
setup do
|
166
136
|
@test = Factory.test("mmm")
|
@@ -184,19 +154,19 @@ class Assert::Test
|
|
184
154
|
|
185
155
|
end
|
186
156
|
|
187
|
-
class
|
157
|
+
class CaptureOutTests < BasicTests
|
188
158
|
desc "when capturing std out"
|
189
|
-
setup
|
159
|
+
setup do
|
190
160
|
@test = Factory.test("stdout") {
|
191
161
|
puts "std out from the test"
|
192
162
|
assert true
|
193
163
|
}
|
194
164
|
@orig_show = Assert.config.show_output
|
195
165
|
Assert.config.show_output false
|
196
|
-
|
197
|
-
teardown
|
166
|
+
end
|
167
|
+
teardown do
|
198
168
|
Assert.config.show_output @orig_show
|
199
|
-
|
169
|
+
end
|
200
170
|
|
201
171
|
should "capture any io from the test" do
|
202
172
|
@test.run
|
@@ -205,30 +175,28 @@ class Assert::Test
|
|
205
175
|
|
206
176
|
end
|
207
177
|
|
208
|
-
class
|
178
|
+
class FullCaptureOutTests < CaptureOutTests
|
209
179
|
desc "across setup, teardown, and meth calls"
|
210
180
|
setup do
|
211
|
-
@test = Factory.test("fullstdouttest")
|
181
|
+
@test = Factory.test("fullstdouttest") do
|
212
182
|
puts "std out from the test"
|
213
|
-
assert a_method_an_assert_calls
|
214
|
-
|
183
|
+
assert a_method_an_assert_calls
|
184
|
+
end
|
215
185
|
@test.context_class.setup { puts "std out from the setup" }
|
216
186
|
@test.context_class.teardown { puts "std out from the teardown" }
|
217
187
|
@test.context_class.send(:define_method, "a_method_an_assert_calls") do
|
218
188
|
puts "std out from a method an assert called"
|
219
|
-
true
|
220
189
|
end
|
221
190
|
end
|
222
191
|
|
223
|
-
should "collect
|
192
|
+
should "collect all stdout in the output accessor" do
|
224
193
|
@test.run
|
225
194
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
].join("\n"), @test.output)
|
195
|
+
exp_out = "std out from the setup\n"\
|
196
|
+
"std out from the test\n"\
|
197
|
+
"std out from a method an assert called\n"\
|
198
|
+
"std out from the teardown\n"
|
199
|
+
assert_equal(exp_out, @test.output)
|
232
200
|
end
|
233
201
|
end
|
234
202
|
|