baretest 0.1.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/LICENSE.txt +52 -0
  2. data/MANIFEST.txt +50 -31
  3. data/README.rdoc +260 -0
  4. data/bin/baretest +82 -24
  5. data/doc/baretest.rdoc +98 -0
  6. data/doc/mocking_stubbing_test_doubles.rdoc +5 -0
  7. data/doc/quickref.rdoc +261 -0
  8. data/doc/writing_tests.rdoc +148 -0
  9. data/examples/test.rake +58 -30
  10. data/examples/tests/irb_mode/failures.rb +26 -0
  11. data/examples/tests/mock_developer/test/helper/mocks.rb +0 -0
  12. data/examples/tests/mock_developer/test/setup.rb +57 -0
  13. data/examples/tests/mock_developer/test/suite/mock_demo.rb +19 -0
  14. data/examples/tests/overview/test.rb +89 -0
  15. data/examples/tests/variations/variations_01.rb +14 -0
  16. data/examples/tests/variations/variations_02.rb +19 -0
  17. data/examples/tests/variations/variations_03.rb +19 -0
  18. data/lib/baretest/assertion/context.rb +20 -0
  19. data/lib/baretest/assertion/failure.rb +22 -0
  20. data/lib/baretest/assertion/skip.rb +21 -0
  21. data/lib/{test → baretest}/assertion/support.rb +174 -39
  22. data/lib/baretest/assertion.rb +182 -0
  23. data/lib/baretest/irb_mode.rb +263 -0
  24. data/lib/{test/assertion/failure.rb → baretest/layout.rb} +6 -5
  25. data/lib/baretest/mocha.rb +18 -0
  26. data/lib/baretest/run/cli.rb +104 -0
  27. data/lib/{test → baretest}/run/errors.rb +12 -7
  28. data/lib/{test → baretest}/run/minimal.rb +8 -3
  29. data/lib/baretest/run/profile.rb +151 -0
  30. data/lib/{test → baretest}/run/spec.rb +10 -4
  31. data/lib/baretest/run/tap.rb +44 -0
  32. data/lib/baretest/run/xml.rb +80 -0
  33. data/lib/{test → baretest}/run.rb +31 -18
  34. data/lib/baretest/setup.rb +15 -0
  35. data/lib/baretest/skipped/assertion.rb +20 -0
  36. data/lib/baretest/skipped/suite.rb +49 -0
  37. data/lib/baretest/skipped.rb +15 -0
  38. data/lib/baretest/suite.rb +234 -0
  39. data/lib/baretest/utilities.rb +43 -0
  40. data/lib/{test → baretest}/version.rb +12 -3
  41. data/lib/baretest.rb +112 -0
  42. data/test/external/bootstraptest.rb +1 -1
  43. data/test/setup.rb +1 -1
  44. data/test/{lib/test → suite/lib/baretest}/assertion/support.rb +78 -24
  45. data/test/suite/lib/baretest/assertion.rb +192 -0
  46. data/test/{lib/test → suite/lib/baretest}/irb_mode.rb +0 -0
  47. data/test/{lib/test → suite/lib/baretest}/run/cli.rb +0 -0
  48. data/test/{lib/test → suite/lib/baretest}/run/errors.rb +0 -0
  49. data/test/{lib/test → suite/lib/baretest}/run/interactive.rb +0 -0
  50. data/test/{lib/test → suite/lib/baretest}/run/spec.rb +0 -0
  51. data/test/{lib/test → suite/lib/baretest}/run/tap.rb +0 -0
  52. data/test/{lib/test → suite/lib/baretest}/run/xml.rb +0 -0
  53. data/test/{lib/test → suite/lib/baretest}/run.rb +63 -61
  54. data/test/{lib/test → suite/lib/baretest}/suite.rb +77 -54
  55. data/test/{lib/test.rb → suite/lib/baretest.rb} +37 -37
  56. metadata +61 -40
  57. data/README.markdown +0 -229
  58. data/examples/test.rb +0 -93
  59. data/lib/test/assertion.rb +0 -117
  60. data/lib/test/debug.rb +0 -34
  61. data/lib/test/irb_mode.rb +0 -104
  62. data/lib/test/run/cli.rb +0 -79
  63. data/lib/test/run/interactive.rb +0 -60
  64. data/lib/test/run/tap.rb +0 -32
  65. data/lib/test/run/xml.rb +0 -56
  66. data/lib/test/suite.rb +0 -95
  67. data/lib/test.rb +0 -118
  68. data/test/lib/test/assertion.rb +0 -142
  69. data/test/lib/test/debug.rb +0 -63
@@ -6,39 +6,39 @@
6
6
 
7
7
 
8
8
 
9
- Test.define "Test" do
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 ::Test::Run, ::Test::Run.new(::Test::Suite.new)
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 ::Test::Run.new end &&
18
- raises_nothing do ::Test::Run.new(::Test::Suite.new) end &&
19
- raises_nothing do ::Test::Run.new(::Test::Suite.new, {}) end &&
20
- raises(ArgumentError) do ::Test::Run.new(::Test::Suite.new, {}, nil) end
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 ::Test::Run.new(::Test::Suite.new, :format => 'spec') end
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 = ::Test::Run.new(::Test::Suite.new, :format => 'spec')
29
- kind_of(::Test::Run::Spec, run)
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 = ::Test::Run.new(::Test::Suite.new, :interactive => true)
34
- kind_of(::Test::IRBMode, run)
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 = ::Test::Suite.new
41
- run = ::Test::Run.new(suite)
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
- Test.extender.clear # avoid interference
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 << 'test/run/test_init.rb' unless $LOADED_FEATURES.include?('test/run/test_init.rb') # suppress require
65
- ::Test.format['test/run/test_init'] = @extender # provide the module as formatter
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 = ::Test::Run.new(::Test::Suite.new, :format => 'test_init')
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 = ::Test::Run.new(::Test::Suite.new, :format => 'test_init')
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 = ::Test::Suite.new
88
- $LOADED_FEATURES << 'test/run/test_init.rb' unless $LOADED_FEATURES.include?('test/run/test_init.rb') # suppress require
89
- ::Test.format['test/run/test_init'] = extender # provide the module as formatter
90
- run = ::Test::Run.new(toplevel_suite, :format => 'test_init')
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
- ::Test::Suite.new,
108
- ::Test::Suite.new
108
+ ["desc1", ::BareTest::Suite.new],
109
+ ["desc2", ::BareTest::Suite.new]
109
110
  ]
110
- toplevel_suite = ::Test::Suite.new
111
+ toplevel_suite = ::BareTest::Suite.new
111
112
  toplevel_suite.suites.concat(suites) # HAX, should have an API for this
112
- suites.unshift(toplevel_suite)
113
- $LOADED_FEATURES << 'test/run/test_init.rb' unless $LOADED_FEATURES.include?('test/run/test_init.rb') # suppress require
114
- ::Test.format['test/run/test_init'] = extender # provide the module as formatter
115
- run = ::Test::Run.new(toplevel_suite, :format => 'test_init')
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(suites, invoked_suites)
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 = ::Test::Suite.new
130
+ toplevel_suite = ::BareTest::Suite.new
129
131
  assertions = [
130
- ::Test::Assertion.new(toplevel_suite, "assertion1"),
131
- ::Test::Assertion.new(toplevel_suite, "assertion2")
132
+ ::BareTest::Assertion.new(toplevel_suite, "assertion1"),
133
+ ::BareTest::Assertion.new(toplevel_suite, "assertion2")
132
134
  ]
133
- toplevel_suite.tests.concat(assertions) # HAX, should have an API for this
134
- $LOADED_FEATURES << 'test/run/test_init.rb' unless $LOADED_FEATURES.include?('test/run/test_init.rb') # suppress require
135
- ::Test.format['test/run/test_init'] = extender # provide the module as formatter
136
- run = ::Test::Run.new(toplevel_suite, :format => 'test_init')
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 = ::Test::Suite.new
144
- run = ::Test::Run.new(toplevel_suite)
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 = ::Test::Assertion.new(nil, nil) do true end
158
- run = ::Test::Run.new(::Test::Suite.new)
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 = ::Test::Assertion.new(nil, "") do true end
166
- run = ::Test::Run.new(::Test::Suite.new)
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 = ::Test::Assertion.new(nil, "") do true end
177
- run = ::Test::Run.new(::Test::Suite.new)
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 = ::Test::Assertion.new(nil, "")
189
- run = ::Test::Run.new(::Test::Suite.new)
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 = ::Test::Skipped::Assertion.new(nil, "")
201
- run = ::Test::Run.new(::Test::Suite.new)
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 = ::Test::Assertion.new(nil, "") do false end
213
- run = ::Test::Run.new(::Test::Suite.new)
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 = ::Test::Assertion.new(nil, "") do raise end
225
- run = ::Test::Run.new(::Test::Suite.new)
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
- Test.define "Test", :requires => 'test/debug' do
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 { ::Test::Suite.create() } &&
14
- raises_nothing { ::Test::Suite.create(nil) } &&
15
- raises_nothing { ::Test::Suite.create(nil, nil) } &&
16
- raises_nothing { ::Test::Suite.create(nil, nil, {}) } &&
17
- raises(ArgumentError) { ::Test::Suite.create(nil, nil, {}, nil) }
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
- ::Test::Suite.create(nil, nil, :requires => file)
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
- ::Test::Suite.create(nil, nil, :requires => files)
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 ::Test::Suite instance." do
43
- ::Test::Suite.create {}.class == ::Test::Suite
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 ::Test::Suite instance without a block." do
47
- ::Test::Suite.create.class == ::Test::Skipped::Suite
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 ::Test::Skipped::Suite instance if a required file is not available." do
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 = ::Test::Suite.create(nil, nil, :requires => 'fake')
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 == ::Test::Skipped::Suite
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 ::Test::Suite instance" do
62
- ::Test::Suite.new(nil, nil).class == ::Test::Suite
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 { ::Test::Suite.new() } &&
67
- raises_nothing { ::Test::Suite.new(nil) } &&
68
- raises_nothing { ::Test::Suite.new(nil, nil) } &&
69
- raises(ArgumentError) { ::Test::Suite.new(nil, nil, nil) }
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 = ::Test::Suite.new do
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| child.description }
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 "#tests" do
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 = ::Test::Suite.new do
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.tests.map { |child| child.description }
104
+ actual_descriptions = suite.assertions.map { |child| child.description }
105
105
 
106
106
  equal(
107
107
  :expected => 3,
108
- :actual => suite.tests.size,
109
- :message => "number of defined tests"
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 = ::Test::Suite.new(description)
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 = ::Test::Suite.new
130
- suite = ::Test::Suite.new("", parent)
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 = ::Test::Suite.new("first")
138
- parent = ::Test::Suite.new("second", grand_parent)
139
- suite = ::Test::Suite.new("third", parent)
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 = ::Test::Suite.new
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| child.description },
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 = ::Test::Suite.new
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 = ::Test::Suite.new
189
+ suite = ::BareTest::Suite.new
190
190
  block = proc {}
191
- before = suite.setup.dup
191
+ before = suite.first_component_variant.dup
192
192
 
193
193
  suite.setup(&block)
194
- after = suite.setup.dup
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 = ::Test::Suite.new
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 = ::Test::Suite.new
234
+ suite = ::BareTest::Suite.new
235
235
  equal(
236
236
  :expected => 0,
237
- :actual => suite.tests.size,
238
- :message => "number of defined tests before adding any"
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.tests.size,
245
- :message => "number of defined tests after adding one"
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.tests.size,
252
- :message => "number of defined tests after adding two"
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.tests.map { |child| child.description },
257
+ :actual => suite.assertions.map { |child| child.description },
258
258
  :message => "the descriptions"
259
259
  )
260
260
  end
261
261
 
262
- assert "Added tests should have the receiving suite as suite." do
263
- suite = ::Test::Suite.new
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.tests.first
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