baretest 0.1.0 → 0.2.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.
- data/LICENSE.txt +52 -0
- data/MANIFEST.txt +50 -31
- data/README.rdoc +260 -0
- data/bin/baretest +82 -24
- data/doc/baretest.rdoc +98 -0
- data/doc/mocking_stubbing_test_doubles.rdoc +5 -0
- data/doc/quickref.rdoc +261 -0
- data/doc/writing_tests.rdoc +148 -0
- data/examples/test.rake +58 -30
- data/examples/tests/irb_mode/failures.rb +26 -0
- data/examples/tests/mock_developer/test/helper/mocks.rb +0 -0
- data/examples/tests/mock_developer/test/setup.rb +57 -0
- data/examples/tests/mock_developer/test/suite/mock_demo.rb +19 -0
- data/examples/tests/overview/test.rb +89 -0
- data/examples/tests/variations/variations_01.rb +14 -0
- data/examples/tests/variations/variations_02.rb +19 -0
- data/examples/tests/variations/variations_03.rb +19 -0
- data/lib/baretest/assertion/context.rb +20 -0
- data/lib/baretest/assertion/failure.rb +22 -0
- data/lib/baretest/assertion/skip.rb +21 -0
- data/lib/{test → baretest}/assertion/support.rb +174 -39
- data/lib/baretest/assertion.rb +182 -0
- data/lib/baretest/irb_mode.rb +263 -0
- data/lib/{test/assertion/failure.rb → baretest/layout.rb} +6 -5
- data/lib/baretest/mocha.rb +18 -0
- data/lib/baretest/run/cli.rb +104 -0
- data/lib/{test → baretest}/run/errors.rb +12 -7
- data/lib/{test → baretest}/run/minimal.rb +8 -3
- data/lib/baretest/run/profile.rb +151 -0
- data/lib/{test → baretest}/run/spec.rb +10 -4
- data/lib/baretest/run/tap.rb +44 -0
- data/lib/baretest/run/xml.rb +80 -0
- data/lib/{test → baretest}/run.rb +31 -18
- data/lib/baretest/setup.rb +15 -0
- data/lib/baretest/skipped/assertion.rb +20 -0
- data/lib/baretest/skipped/suite.rb +49 -0
- data/lib/baretest/skipped.rb +15 -0
- data/lib/baretest/suite.rb +234 -0
- data/lib/baretest/utilities.rb +43 -0
- data/lib/{test → baretest}/version.rb +12 -3
- data/lib/baretest.rb +112 -0
- data/test/external/bootstraptest.rb +1 -1
- data/test/setup.rb +1 -1
- data/test/{lib/test → suite/lib/baretest}/assertion/support.rb +78 -24
- data/test/suite/lib/baretest/assertion.rb +192 -0
- data/test/{lib/test → suite/lib/baretest}/irb_mode.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/cli.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/errors.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/interactive.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/spec.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/tap.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/xml.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run.rb +63 -61
- data/test/{lib/test → suite/lib/baretest}/suite.rb +77 -54
- data/test/{lib/test.rb → suite/lib/baretest.rb} +37 -37
- metadata +61 -40
- data/README.markdown +0 -229
- data/examples/test.rb +0 -93
- data/lib/test/assertion.rb +0 -117
- data/lib/test/debug.rb +0 -34
- data/lib/test/irb_mode.rb +0 -104
- data/lib/test/run/cli.rb +0 -79
- data/lib/test/run/interactive.rb +0 -60
- data/lib/test/run/tap.rb +0 -32
- data/lib/test/run/xml.rb +0 -56
- data/lib/test/suite.rb +0 -95
- data/lib/test.rb +0 -118
- data/test/lib/test/assertion.rb +0 -142
- data/test/lib/test/debug.rb +0 -63
@@ -6,39 +6,39 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
BareTest.suite "BareTest" do
|
10
10
|
suite "Run" do
|
11
11
|
suite "::new" do
|
12
12
|
assert "Should return an instance of Run" do
|
13
|
-
kind_of ::
|
13
|
+
kind_of ::BareTest::Run, ::BareTest::Run.new(::BareTest::Suite.new)
|
14
14
|
end
|
15
15
|
|
16
16
|
assert "Should accept 1-2 arguments" do
|
17
|
-
raises(ArgumentError) do ::
|
18
|
-
raises_nothing do ::
|
19
|
-
raises_nothing do ::
|
20
|
-
raises(ArgumentError) do ::
|
17
|
+
raises(ArgumentError) do ::BareTest::Run.new end &&
|
18
|
+
raises_nothing do ::BareTest::Run.new(::BareTest::Suite.new) end &&
|
19
|
+
raises_nothing do ::BareTest::Run.new(::BareTest::Suite.new, {}) end &&
|
20
|
+
raises(ArgumentError) do ::BareTest::Run.new(::BareTest::Suite.new, {}, nil) end
|
21
21
|
end
|
22
22
|
|
23
23
|
assert "Should accept an option ':format'" do
|
24
|
-
raises_nothing do ::
|
24
|
+
raises_nothing do ::BareTest::Run.new(::BareTest::Suite.new, :format => 'spec') end
|
25
25
|
end
|
26
26
|
|
27
27
|
assert "Should use the formatter specified in the :format option" do
|
28
|
-
run = ::
|
29
|
-
kind_of(::
|
28
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new, :format => 'spec')
|
29
|
+
kind_of(::BareTest::Run::Spec, run)
|
30
30
|
end
|
31
31
|
|
32
32
|
assert "Should accept an option ':interactive' and load irb_mode" do
|
33
|
-
run = ::
|
34
|
-
kind_of(::
|
33
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new, :interactive => true)
|
34
|
+
kind_of(::BareTest::IRBMode, run)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
suite "#suite" do
|
39
39
|
assert "Should return the suite the instance was initialized with" do
|
40
|
-
suite = ::
|
41
|
-
run = ::
|
40
|
+
suite = ::BareTest::Suite.new
|
41
|
+
run = ::BareTest::Run.new(suite)
|
42
42
|
|
43
43
|
same(suite, run.suite)
|
44
44
|
end
|
@@ -46,7 +46,7 @@ Test.define "Test" do
|
|
46
46
|
|
47
47
|
suite "#inits" do
|
48
48
|
setup do
|
49
|
-
|
49
|
+
BareTest.extender.clear # avoid interference
|
50
50
|
@executed = []
|
51
51
|
executed = @executed # for closure
|
52
52
|
@init_blocks = [
|
@@ -61,17 +61,17 @@ Test.define "Test" do
|
|
61
61
|
}
|
62
62
|
end
|
63
63
|
end
|
64
|
-
$LOADED_FEATURES << '
|
65
|
-
::
|
64
|
+
$LOADED_FEATURES << 'baretest/run/test_init.rb' unless $LOADED_FEATURES.include?('baretest/run/test_init.rb') # suppress require
|
65
|
+
::BareTest.format['baretest/run/test_init'] = @extender # provide the module as formatter
|
66
66
|
end
|
67
67
|
|
68
68
|
assert "Should return the array with blocks called at the end of initialize" do
|
69
|
-
run = ::
|
69
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new, :format => 'test_init')
|
70
70
|
equal(@init_blocks, run.inits)
|
71
71
|
end
|
72
72
|
|
73
73
|
assert "Should run the blocks at the end of initialize" do
|
74
|
-
run = ::
|
74
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new, :format => 'test_init')
|
75
75
|
equal([:block1, :block2], @executed)
|
76
76
|
end
|
77
77
|
end
|
@@ -84,10 +84,10 @@ Test.define "Test" do
|
|
84
84
|
invoked_suites << suite
|
85
85
|
end
|
86
86
|
end
|
87
|
-
toplevel_suite = ::
|
88
|
-
$LOADED_FEATURES << '
|
89
|
-
::
|
90
|
-
run = ::
|
87
|
+
toplevel_suite = ::BareTest::Suite.new
|
88
|
+
$LOADED_FEATURES << 'baretest/run/test_init.rb' unless $LOADED_FEATURES.include?('baretest/run/test_init.rb') # suppress require
|
89
|
+
::BareTest.format['baretest/run/test_init'] = extender # provide the module as formatter
|
90
|
+
run = ::BareTest::Run.new(toplevel_suite, :format => 'test_init')
|
91
91
|
run.run_all
|
92
92
|
|
93
93
|
equal([toplevel_suite], invoked_suites)
|
@@ -103,45 +103,47 @@ Test.define "Test" do
|
|
103
103
|
super(suite)
|
104
104
|
end
|
105
105
|
end
|
106
|
+
|
106
107
|
suites = [
|
107
|
-
::
|
108
|
-
::
|
108
|
+
["desc1", ::BareTest::Suite.new],
|
109
|
+
["desc2", ::BareTest::Suite.new]
|
109
110
|
]
|
110
|
-
toplevel_suite = ::
|
111
|
+
toplevel_suite = ::BareTest::Suite.new
|
111
112
|
toplevel_suite.suites.concat(suites) # HAX, should have an API for this
|
112
|
-
suites.
|
113
|
-
|
114
|
-
|
115
|
-
run =
|
113
|
+
expect = [toplevel_suite]+suites.map { |desc, suite| suite }
|
114
|
+
|
115
|
+
$LOADED_FEATURES << 'baretest/run/test_init.rb' unless $LOADED_FEATURES.include?('baretest/run/test_init.rb') # suppress require
|
116
|
+
::BareTest.format['baretest/run/test_init'] = extender # provide the module as formatter
|
117
|
+
run = ::BareTest::Run.new(toplevel_suite, :format => 'test_init')
|
116
118
|
run.run_suite(toplevel_suite)
|
117
119
|
|
118
|
-
equal_unordered(
|
120
|
+
equal_unordered(expect, invoked_suites)
|
119
121
|
end
|
120
122
|
|
121
123
|
assert "Invokes #run_test with every suite in the given suite" do
|
122
124
|
invoked_tests = []
|
123
125
|
extender = Module.new do |m|
|
124
|
-
define_method :run_test do |test|
|
126
|
+
define_method :run_test do |test, setup|
|
125
127
|
invoked_tests << test
|
126
128
|
end
|
127
129
|
end
|
128
|
-
toplevel_suite = ::
|
130
|
+
toplevel_suite = ::BareTest::Suite.new
|
129
131
|
assertions = [
|
130
|
-
::
|
131
|
-
::
|
132
|
+
::BareTest::Assertion.new(toplevel_suite, "assertion1"),
|
133
|
+
::BareTest::Assertion.new(toplevel_suite, "assertion2")
|
132
134
|
]
|
133
|
-
toplevel_suite.
|
134
|
-
$LOADED_FEATURES << '
|
135
|
-
::
|
136
|
-
run = ::
|
135
|
+
toplevel_suite.assertions.concat(assertions) # HAX, should have an API for this
|
136
|
+
$LOADED_FEATURES << 'baretest/run/test_init.rb' unless $LOADED_FEATURES.include?('baretest/run/test_init.rb') # suppress require
|
137
|
+
::BareTest.format['baretest/run/test_init'] = extender # provide the module as formatter
|
138
|
+
run = ::BareTest::Run.new(toplevel_suite, :format => 'test_init')
|
137
139
|
run.run_all
|
138
140
|
|
139
141
|
equal_unordered(assertions, invoked_tests)
|
140
142
|
end
|
141
143
|
|
142
144
|
assert "Increments the counter ':suite' at the end" do
|
143
|
-
toplevel_suite = ::
|
144
|
-
run = ::
|
145
|
+
toplevel_suite = ::BareTest::Suite.new
|
146
|
+
run = ::BareTest::Run.new(toplevel_suite)
|
145
147
|
|
146
148
|
count_before = run.count[:suite]
|
147
149
|
run.run_suite(toplevel_suite)
|
@@ -154,18 +156,18 @@ Test.define "Test" do
|
|
154
156
|
suite "#run_test" do
|
155
157
|
assert "Runs the given test" do
|
156
158
|
# should implement this with a mock, expecting #execute to be called
|
157
|
-
assertion = ::
|
158
|
-
run = ::
|
159
|
-
run.run_test(assertion)
|
159
|
+
assertion = ::BareTest::Assertion.new(nil, nil) do true end
|
160
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new)
|
161
|
+
run.run_test(assertion, [])
|
160
162
|
|
161
163
|
equal(:success, assertion.status)
|
162
164
|
end
|
163
165
|
|
164
166
|
assert "Increments the counter ':test' at the end" do
|
165
|
-
assertion = ::
|
166
|
-
run = ::
|
167
|
+
assertion = ::BareTest::Assertion.new(nil, "") do true end
|
168
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new)
|
167
169
|
count_before = run.count[:test]
|
168
|
-
run.run_test(assertion)
|
170
|
+
run.run_test(assertion, [])
|
169
171
|
count_after = run.count[:test]
|
170
172
|
|
171
173
|
equal(count_before+1, count_after)
|
@@ -173,10 +175,10 @@ Test.define "Test" do
|
|
173
175
|
|
174
176
|
suite "The given test was a success" do
|
175
177
|
assert "Increments the counter ':success' at the end" do
|
176
|
-
assertion = ::
|
177
|
-
run = ::
|
178
|
+
assertion = ::BareTest::Assertion.new(nil, "") do true end
|
179
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new)
|
178
180
|
count_before = run.count[:success]
|
179
|
-
run.run_test(assertion)
|
181
|
+
run.run_test(assertion, [])
|
180
182
|
count_after = run.count[:success]
|
181
183
|
|
182
184
|
equal(count_before+1, count_after)
|
@@ -185,10 +187,10 @@ Test.define "Test" do
|
|
185
187
|
|
186
188
|
suite "The given test was pending" do
|
187
189
|
assert "Increments the counter ':pending' at the end" do
|
188
|
-
assertion = ::
|
189
|
-
run = ::
|
190
|
+
assertion = ::BareTest::Assertion.new(nil, "")
|
191
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new)
|
190
192
|
count_before = run.count[:pending]
|
191
|
-
run.run_test(assertion)
|
193
|
+
run.run_test(assertion, [])
|
192
194
|
count_after = run.count[:pending]
|
193
195
|
|
194
196
|
equal(count_before+1, count_after)
|
@@ -197,10 +199,10 @@ Test.define "Test" do
|
|
197
199
|
|
198
200
|
suite "The given test was skipped" do
|
199
201
|
assert "Increments the counter ':skipped' at the end" do
|
200
|
-
assertion = ::
|
201
|
-
run = ::
|
202
|
+
assertion = ::BareTest::Skipped::Assertion.new(nil, "")
|
203
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new)
|
202
204
|
count_before = run.count[:skipped]
|
203
|
-
run.run_test(assertion)
|
205
|
+
run.run_test(assertion, [])
|
204
206
|
count_after = run.count[:skipped]
|
205
207
|
|
206
208
|
equal(count_before+1, count_after)
|
@@ -209,10 +211,10 @@ Test.define "Test" do
|
|
209
211
|
|
210
212
|
suite "The given test was failure" do
|
211
213
|
assert "Increments the counter ':failure' at the end" do
|
212
|
-
assertion = ::
|
213
|
-
run = ::
|
214
|
+
assertion = ::BareTest::Assertion.new(nil, "") do false end
|
215
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new)
|
214
216
|
count_before = run.count[:failure]
|
215
|
-
run.run_test(assertion)
|
217
|
+
run.run_test(assertion, [])
|
216
218
|
count_after = run.count[:failure]
|
217
219
|
|
218
220
|
equal(count_before+1, count_after)
|
@@ -221,10 +223,10 @@ Test.define "Test" do
|
|
221
223
|
|
222
224
|
suite "The given test was error" do
|
223
225
|
assert "Increments the counter ':error' at the end" do
|
224
|
-
assertion = ::
|
225
|
-
run = ::
|
226
|
+
assertion = ::BareTest::Assertion.new(nil, "") do raise end
|
227
|
+
run = ::BareTest::Run.new(::BareTest::Suite.new)
|
226
228
|
count_before = run.count[:error]
|
227
|
-
run.run_test(assertion)
|
229
|
+
run.run_test(assertion, [])
|
228
230
|
count_after = run.count[:error]
|
229
231
|
|
230
232
|
equal(count_before+1, count_after)
|
@@ -6,15 +6,15 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
BareTest.suite "BareTest" do
|
10
10
|
suite "Assertion" do
|
11
11
|
suite "::create" do
|
12
12
|
assert "Should accept 0-3 arguments" do
|
13
|
-
raises_nothing { ::
|
14
|
-
raises_nothing { ::
|
15
|
-
raises_nothing { ::
|
16
|
-
raises_nothing { ::
|
17
|
-
raises(ArgumentError) { ::
|
13
|
+
raises_nothing { ::BareTest::Suite.create() } &&
|
14
|
+
raises_nothing { ::BareTest::Suite.create(nil) } &&
|
15
|
+
raises_nothing { ::BareTest::Suite.create(nil, nil) } &&
|
16
|
+
raises_nothing { ::BareTest::Suite.create(nil, nil, {}) } &&
|
17
|
+
raises(ArgumentError) { ::BareTest::Suite.create(nil, nil, {}, nil) }
|
18
18
|
end
|
19
19
|
|
20
20
|
assert "Should require a single file listed in :requires option." do
|
@@ -22,7 +22,7 @@ Test.define "Test", :requires => 'test/debug' do
|
|
22
22
|
original_require = Kernel.instance_method(:require)
|
23
23
|
file = 'foo/bar'
|
24
24
|
Kernel.send(:define_method, :require) do |file, *args| a.touch(file) end
|
25
|
-
::
|
25
|
+
::BareTest::Suite.create(nil, nil, :requires => file)
|
26
26
|
Kernel.send(:define_method, :require, original_require)
|
27
27
|
|
28
28
|
touched file
|
@@ -33,52 +33,52 @@ Test.define "Test", :requires => 'test/debug' do
|
|
33
33
|
original_require = Kernel.instance_method(:require)
|
34
34
|
files = %w[moo/bar moo/baz moo/quuz]
|
35
35
|
Kernel.send(:define_method, :require) do |file, *args| a.touch(file) end
|
36
|
-
::
|
36
|
+
::BareTest::Suite.create(nil, nil, :requires => files)
|
37
37
|
Kernel.send(:define_method, :require, original_require)
|
38
38
|
|
39
39
|
files.all? { |file| touched file }
|
40
40
|
end
|
41
41
|
|
42
|
-
assert "Should return a ::
|
43
|
-
::
|
42
|
+
assert "Should return a ::BareTest::Suite instance." do
|
43
|
+
::BareTest::Suite.create {}.class == ::BareTest::Suite
|
44
44
|
end
|
45
45
|
|
46
|
-
assert "Should return a ::
|
47
|
-
::
|
46
|
+
assert "Should return a ::BareTest::Suite instance without a block." do
|
47
|
+
::BareTest::Suite.create.class == ::BareTest::Skipped::Suite
|
48
48
|
end
|
49
49
|
|
50
|
-
assert "Should return a ::
|
50
|
+
assert "Should return a ::BareTest::Skipped::Suite instance if a required file is not available." do
|
51
51
|
original_require = Kernel.instance_method(:require)
|
52
52
|
Kernel.send(:define_method, :require) do |*args| raise LoadError end # simulate that the required file was not found
|
53
|
-
return_value = ::
|
53
|
+
return_value = ::BareTest::Suite.create(nil, nil, :requires => 'fake')
|
54
54
|
Kernel.send(:define_method, :require, original_require)
|
55
55
|
|
56
|
-
return_value.class == ::
|
56
|
+
return_value.class == ::BareTest::Skipped::Suite
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
suite "::new" do
|
61
|
-
assert "Should return a ::
|
62
|
-
::
|
61
|
+
assert "Should return a ::BareTest::Suite instance" do
|
62
|
+
::BareTest::Suite.new(nil, nil).class == ::BareTest::Suite
|
63
63
|
end
|
64
64
|
|
65
65
|
assert "Should accept 0-2 arguments" do
|
66
|
-
raises_nothing { ::
|
67
|
-
raises_nothing { ::
|
68
|
-
raises_nothing { ::
|
69
|
-
raises(ArgumentError) { ::
|
66
|
+
raises_nothing { ::BareTest::Suite.new() } &&
|
67
|
+
raises_nothing { ::BareTest::Suite.new(nil) } &&
|
68
|
+
raises_nothing { ::BareTest::Suite.new(nil, nil) } &&
|
69
|
+
raises(ArgumentError) { ::BareTest::Suite.new(nil, nil, nil) }
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
suite "#suites" do
|
74
74
|
assert "Should return all the suites defined in the block." do
|
75
75
|
expected_descriptions = %w[a b c]
|
76
|
-
suite = ::
|
76
|
+
suite = ::BareTest::Suite.new do
|
77
77
|
expected_descriptions.each { |desc|
|
78
78
|
suite desc
|
79
79
|
}
|
80
80
|
end
|
81
|
-
actual_descriptions = suite.suites.map { |child|
|
81
|
+
actual_descriptions = suite.suites.map { |description, child| description }
|
82
82
|
|
83
83
|
equal(
|
84
84
|
:expected => 3,
|
@@ -93,20 +93,20 @@ Test.define "Test", :requires => 'test/debug' do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
suite "#
|
96
|
+
suite "#assertions" do
|
97
97
|
assert "Should return all the suites defined in the block." do
|
98
98
|
expected_descriptions = %w[a b c]
|
99
|
-
suite = ::
|
99
|
+
suite = ::BareTest::Suite.new do
|
100
100
|
expected_descriptions.each { |desc|
|
101
101
|
assert desc
|
102
102
|
}
|
103
103
|
end
|
104
|
-
actual_descriptions = suite.
|
104
|
+
actual_descriptions = suite.assertions.map { |child| child.description }
|
105
105
|
|
106
106
|
equal(
|
107
107
|
:expected => 3,
|
108
|
-
:actual => suite.
|
109
|
-
:message => "number of defined
|
108
|
+
:actual => suite.assertions.size,
|
109
|
+
:message => "number of defined assertions"
|
110
110
|
) &&
|
111
111
|
equal_unordered(
|
112
112
|
:expected => expected_descriptions,
|
@@ -119,31 +119,31 @@ Test.define "Test", :requires => 'test/debug' do
|
|
119
119
|
suite "#description" do
|
120
120
|
assert "A suite should have a description" do
|
121
121
|
description = "The suite description"
|
122
|
-
suite = ::
|
122
|
+
suite = ::BareTest::Suite.new(description)
|
123
123
|
equal :expected => description, :actual => suite.description, :message => 'suite description'
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
suite "#parent" do
|
128
128
|
assert "A suite can have a parent suite" do
|
129
|
-
parent = ::
|
130
|
-
suite = ::
|
129
|
+
parent = ::BareTest::Suite.new
|
130
|
+
suite = ::BareTest::Suite.new("", parent)
|
131
131
|
same :expected => suite.parent, :actual => parent, :message => "suite's parent"
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
135
|
suite "#ancestors" do
|
136
136
|
assert "A suite can have ancestors" do
|
137
|
-
grand_parent = ::
|
138
|
-
parent = ::
|
139
|
-
suite = ::
|
137
|
+
grand_parent = ::BareTest::Suite.new("first")
|
138
|
+
parent = ::BareTest::Suite.new("second", grand_parent)
|
139
|
+
suite = ::BareTest::Suite.new("third", parent)
|
140
140
|
equal :expected => suite.ancestors, :actual => [suite, parent, grand_parent], :message => "suite's ancestors"
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
144
|
suite "#suite" do
|
145
145
|
assert "Should add new suites to a suite." do
|
146
|
-
suite = ::
|
146
|
+
suite = ::BareTest::Suite.new
|
147
147
|
equal(
|
148
148
|
:expected => 0,
|
149
149
|
:actual => suite.suites.size,
|
@@ -166,15 +166,15 @@ Test.define "Test", :requires => 'test/debug' do
|
|
166
166
|
|
167
167
|
equal_unordered(
|
168
168
|
:expected => ['a', 'b'],
|
169
|
-
:actual => suite.suites.map { |child|
|
169
|
+
:actual => suite.suites.map { |description, child| description },
|
170
170
|
:message => "the descriptions"
|
171
171
|
)
|
172
172
|
end
|
173
173
|
|
174
174
|
assert "Added suites should have the receiving suite as parent." do
|
175
|
-
parent = ::
|
175
|
+
parent = ::BareTest::Suite.new
|
176
176
|
parent.suite "a"
|
177
|
-
child = parent.suites.first
|
177
|
+
child = parent.suites.first.last
|
178
178
|
|
179
179
|
same(
|
180
180
|
:expected => parent,
|
@@ -186,12 +186,12 @@ Test.define "Test", :requires => 'test/debug' do
|
|
186
186
|
|
187
187
|
suite "#setup" do
|
188
188
|
assert "Called with a block it should add a new setup block." do
|
189
|
-
suite = ::
|
189
|
+
suite = ::BareTest::Suite.new
|
190
190
|
block = proc {}
|
191
|
-
before = suite.
|
191
|
+
before = suite.first_component_variant.dup
|
192
192
|
|
193
193
|
suite.setup(&block)
|
194
|
-
after = suite.
|
194
|
+
after = suite.first_component_variant.dup
|
195
195
|
|
196
196
|
equal(
|
197
197
|
:expected => 1,
|
@@ -199,7 +199,7 @@ Test.define "Test", :requires => 'test/debug' do
|
|
199
199
|
:message => "number of new setup blocks after adding one"
|
200
200
|
) &&
|
201
201
|
same(
|
202
|
-
:expected => (after-before).first,
|
202
|
+
:expected => (after-before).first.block,
|
203
203
|
:actual => block,
|
204
204
|
:message => "the new block"
|
205
205
|
)
|
@@ -209,7 +209,7 @@ Test.define "Test", :requires => 'test/debug' do
|
|
209
209
|
|
210
210
|
suite "#teardown" do
|
211
211
|
assert "Called with a block it should add a new teardown block." do
|
212
|
-
suite = ::
|
212
|
+
suite = ::BareTest::Suite.new
|
213
213
|
block = proc {}
|
214
214
|
before = suite.teardown.dup
|
215
215
|
|
@@ -231,38 +231,38 @@ Test.define "Test", :requires => 'test/debug' do
|
|
231
231
|
|
232
232
|
suite "#assert" do
|
233
233
|
assert "Should add new assertions to a suite." do
|
234
|
-
suite = ::
|
234
|
+
suite = ::BareTest::Suite.new
|
235
235
|
equal(
|
236
236
|
:expected => 0,
|
237
|
-
:actual => suite.
|
238
|
-
:message => "number of defined
|
237
|
+
:actual => suite.assertions.size,
|
238
|
+
:message => "number of defined assertions before adding any"
|
239
239
|
)
|
240
240
|
|
241
241
|
suite.assert "a"
|
242
242
|
equal(
|
243
243
|
:expected => 1,
|
244
|
-
:actual => suite.
|
245
|
-
:message => "number of defined
|
244
|
+
:actual => suite.assertions.size,
|
245
|
+
:message => "number of defined assertions after adding one"
|
246
246
|
)
|
247
247
|
|
248
248
|
suite.assert "b"
|
249
249
|
equal(
|
250
250
|
:expected => 2,
|
251
|
-
:actual => suite.
|
252
|
-
:message => "number of defined
|
251
|
+
:actual => suite.assertions.size,
|
252
|
+
:message => "number of defined assertions after adding two"
|
253
253
|
)
|
254
254
|
|
255
255
|
equal_unordered(
|
256
256
|
:expected => ['a', 'b'],
|
257
|
-
:actual => suite.
|
257
|
+
:actual => suite.assertions.map { |child| child.description },
|
258
258
|
:message => "the descriptions"
|
259
259
|
)
|
260
260
|
end
|
261
261
|
|
262
|
-
assert "Added
|
263
|
-
suite = ::
|
262
|
+
assert "Added assertions should have the receiving suite as suite." do
|
263
|
+
suite = ::BareTest::Suite.new
|
264
264
|
suite.assert "a"
|
265
|
-
assertion = suite.
|
265
|
+
assertion = suite.assertions.first
|
266
266
|
|
267
267
|
same(
|
268
268
|
:expected => suite,
|
@@ -271,5 +271,28 @@ Test.define "Test", :requires => 'test/debug' do
|
|
271
271
|
)
|
272
272
|
end
|
273
273
|
end
|
274
|
+
|
275
|
+
suite "#to_s" do
|
276
|
+
assert "Suite should have a to_s which contains the classname and the description" do
|
277
|
+
description = "the description"
|
278
|
+
suite = ::BareTest::Suite.new(description)
|
279
|
+
print_string = suite.to_s
|
280
|
+
|
281
|
+
print_string.include?(suite.class.name) &&
|
282
|
+
print_string.include?(description)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
suite "#inspect" do
|
287
|
+
assert "Suite should have an inspect which contains the classname, the shifted object-id in zero-padded hex and the description's inspect" do
|
288
|
+
description = "the description"
|
289
|
+
suite = ::BareTest::Suite.new(description)
|
290
|
+
inspect_string = suite.inspect
|
291
|
+
|
292
|
+
inspect_string.include?(suite.class.name) &&
|
293
|
+
inspect_string.include?("%08x" % (suite.object_id >> 1)) &&
|
294
|
+
inspect_string.include?(description.inspect)
|
295
|
+
end
|
296
|
+
end
|
274
297
|
end
|
275
298
|
end
|