mofo 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/Manifest.txt +55 -0
- data/Rakefile +32 -0
- data/init.rb +2 -0
- data/lib/microformat.rb +39 -6
- data/lib/mofo/hentry.rb +4 -0
- data/site/index.html +382 -0
- data/site/mofo-logo.png +0 -0
- data/site/mootools.v1.00.js +2 -0
- data/site/style.css +159 -0
- data/test/base_url_test.rb +22 -0
- data/test/fixtures/corkd.html +1 -1
- data/test/hatom_test.rb +1 -1
- data/test/hreview_test.rb +4 -3
- data/test/include_pattern_test.rb +1 -1
- data/test/test_helper.rb +17 -6
- metadata +63 -115
- data/test/format_test.rb +0 -230
- data/vendor/testspec-0.3.0/ChangeLog +0 -177
- data/vendor/testspec-0.3.0/README +0 -289
- data/vendor/testspec-0.3.0/ROADMAP +0 -1
- data/vendor/testspec-0.3.0/Rakefile +0 -151
- data/vendor/testspec-0.3.0/SPECS +0 -108
- data/vendor/testspec-0.3.0/TODO +0 -2
- data/vendor/testspec-0.3.0/bin/specrb +0 -104
- data/vendor/testspec-0.3.0/doc/classes/Kernel.html +0 -140
- data/vendor/testspec-0.3.0/doc/classes/Object.html +0 -155
- data/vendor/testspec-0.3.0/doc/classes/Test/Spec.html +0 -128
- data/vendor/testspec-0.3.0/doc/classes/Test/Spec/CustomShould.html +0 -236
- data/vendor/testspec-0.3.0/doc/classes/Test/Spec/DefinitionError.html +0 -111
- data/vendor/testspec-0.3.0/doc/classes/Test/Spec/Should.html +0 -884
- data/vendor/testspec-0.3.0/doc/classes/Test/Spec/ShouldNot.html +0 -487
- data/vendor/testspec-0.3.0/doc/classes/Test/Spec/TestCase.html +0 -220
- data/vendor/testspec-0.3.0/doc/classes/Test/Spec/TestCase/ClassMethods.html +0 -318
- data/vendor/testspec-0.3.0/doc/classes/Test/Spec/TestCase/InstanceMethods.html +0 -195
- data/vendor/testspec-0.3.0/doc/classes/Test/Unit/UI/RDox/TestRunner.html +0 -222
- data/vendor/testspec-0.3.0/doc/classes/Test/Unit/UI/SpecDox/TestRunner.html +0 -476
- data/vendor/testspec-0.3.0/doc/created.rid +0 -1
- data/vendor/testspec-0.3.0/doc/files/README.html +0 -516
- data/vendor/testspec-0.3.0/doc/files/ROADMAP.html +0 -109
- data/vendor/testspec-0.3.0/doc/files/SPECS.html +0 -386
- data/vendor/testspec-0.3.0/doc/files/lib/test/spec/dox_rb.html +0 -108
- data/vendor/testspec-0.3.0/doc/files/lib/test/spec/rdox_rb.html +0 -108
- data/vendor/testspec-0.3.0/doc/files/lib/test/spec/should-output_rb.html +0 -115
- data/vendor/testspec-0.3.0/doc/files/lib/test/spec_rb.html +0 -123
- data/vendor/testspec-0.3.0/doc/fr_class_index.html +0 -38
- data/vendor/testspec-0.3.0/doc/fr_file_index.html +0 -33
- data/vendor/testspec-0.3.0/doc/fr_method_index.html +0 -102
- data/vendor/testspec-0.3.0/doc/index.html +0 -24
- data/vendor/testspec-0.3.0/doc/rdoc-style.css +0 -208
- data/vendor/testspec-0.3.0/examples/stack.rb +0 -38
- data/vendor/testspec-0.3.0/examples/stack_spec.rb +0 -119
- data/vendor/testspec-0.3.0/lib/test/spec.rb +0 -490
- data/vendor/testspec-0.3.0/lib/test/spec/dox.rb +0 -122
- data/vendor/testspec-0.3.0/lib/test/spec/rdox.rb +0 -25
- data/vendor/testspec-0.3.0/lib/test/spec/should-output.rb +0 -49
- data/vendor/testspec-0.3.0/test/spec_dox.rb +0 -39
- data/vendor/testspec-0.3.0/test/spec_flexmock.rb +0 -210
- data/vendor/testspec-0.3.0/test/spec_mocha.rb +0 -118
- data/vendor/testspec-0.3.0/test/spec_nestedcontexts.rb +0 -26
- data/vendor/testspec-0.3.0/test/spec_should-output.rb +0 -26
- data/vendor/testspec-0.3.0/test/spec_testspec.rb +0 -522
- data/vendor/testspec-0.3.0/test/spec_testspec_order.rb +0 -26
- data/vendor/testspec-0.3.0/test/test_testunit.rb +0 -21
@@ -1,119 +0,0 @@
|
|
1
|
-
# Copied with minor code changes (should_xxx -> should.xxx) from RSpec.
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../lib/test/spec'
|
4
|
-
require File.dirname(__FILE__) + "/stack"
|
5
|
-
|
6
|
-
context "A stack (in general)" do
|
7
|
-
setup do
|
8
|
-
@stack = Stack.new
|
9
|
-
["a","b","c"].each { |x| @stack.push x }
|
10
|
-
end
|
11
|
-
|
12
|
-
specify "should add to the top when sent 'push'" do
|
13
|
-
@stack.push "d"
|
14
|
-
@stack.peek.should.equal "d"
|
15
|
-
end
|
16
|
-
|
17
|
-
specify "should return the top item when sent 'peek'" do
|
18
|
-
@stack.peek.should.equal "c"
|
19
|
-
end
|
20
|
-
|
21
|
-
specify "should NOT remove the top item when sent 'peek'" do
|
22
|
-
@stack.peek.should.equal "c"
|
23
|
-
@stack.peek.should.equal "c"
|
24
|
-
end
|
25
|
-
|
26
|
-
specify "should return the top item when sent 'pop'" do
|
27
|
-
@stack.pop.should.equal "c"
|
28
|
-
end
|
29
|
-
|
30
|
-
specify "should remove the top item when sent 'pop'" do
|
31
|
-
@stack.pop.should.equal "c"
|
32
|
-
@stack.pop.should.equal "b"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "An empty stack" do
|
37
|
-
setup do
|
38
|
-
@stack = Stack.new
|
39
|
-
end
|
40
|
-
|
41
|
-
specify "should be empty" do
|
42
|
-
@stack.should.be.empty
|
43
|
-
end
|
44
|
-
|
45
|
-
specify "should no longer be empty after 'push'" do
|
46
|
-
@stack.push "anything"
|
47
|
-
@stack.should.not.be.empty
|
48
|
-
end
|
49
|
-
|
50
|
-
specify "should complain when sent 'peek'" do
|
51
|
-
lambda { @stack.peek }.should.raise StackUnderflowError
|
52
|
-
end
|
53
|
-
|
54
|
-
specify "should complain when sent 'pop'" do
|
55
|
-
lambda { @stack.pop }.should.raise StackUnderflowError
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "An almost empty stack (with one item)" do
|
60
|
-
setup do
|
61
|
-
@stack = Stack.new
|
62
|
-
@stack.push 3
|
63
|
-
end
|
64
|
-
|
65
|
-
specify "should not be empty" do
|
66
|
-
@stack.should.not.be.empty
|
67
|
-
end
|
68
|
-
|
69
|
-
specify "should remain not empty after 'peek'" do
|
70
|
-
@stack.peek
|
71
|
-
@stack.should.not.be.empty
|
72
|
-
end
|
73
|
-
|
74
|
-
specify "should become empty after 'pop'" do
|
75
|
-
@stack.pop
|
76
|
-
@stack.should.be.empty
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context "An almost full stack (with one item less than capacity)" do
|
81
|
-
setup do
|
82
|
-
@stack = Stack.new
|
83
|
-
(1..9).each { |i| @stack.push i }
|
84
|
-
end
|
85
|
-
|
86
|
-
specify "should not be full" do
|
87
|
-
@stack.should.not.be.full
|
88
|
-
end
|
89
|
-
|
90
|
-
specify "should become full when sent 'push'" do
|
91
|
-
@stack.push Object.new
|
92
|
-
@stack.should.be.full
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context "A full stack" do
|
97
|
-
setup do
|
98
|
-
@stack = Stack.new
|
99
|
-
(1..10).each { |i| @stack.push i }
|
100
|
-
end
|
101
|
-
|
102
|
-
specify "should be full" do
|
103
|
-
@stack.should.be.full
|
104
|
-
end
|
105
|
-
|
106
|
-
specify "should remain full after 'peek'" do
|
107
|
-
@stack.peek
|
108
|
-
@stack.should.be.full
|
109
|
-
end
|
110
|
-
|
111
|
-
specify "should no longer be full after 'pop'" do
|
112
|
-
@stack.pop
|
113
|
-
@stack.should.not.be.full
|
114
|
-
end
|
115
|
-
|
116
|
-
specify "should complain on 'push'" do
|
117
|
-
lambda { @stack.push Object.new }.should.raise StackOverflowError
|
118
|
-
end
|
119
|
-
end
|
@@ -1,490 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# test/spec -- a BDD interface for Test::Unit
|
3
|
-
#
|
4
|
-
# Copyright (C) 2006, 2007 Christian Neukirchen <mailto:chneukirchen@gmail.com>
|
5
|
-
#
|
6
|
-
# This work is licensed under the same terms as Ruby itself.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'test/unit'
|
10
|
-
|
11
|
-
class Test::Unit::AutoRunner # :nodoc:
|
12
|
-
RUNNERS[:specdox] = lambda {
|
13
|
-
require 'test/spec/dox'
|
14
|
-
Test::Unit::UI::SpecDox::TestRunner
|
15
|
-
}
|
16
|
-
|
17
|
-
RUNNERS[:rdox] = lambda {
|
18
|
-
require 'test/spec/rdox'
|
19
|
-
Test::Unit::UI::RDox::TestRunner
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
module Test # :nodoc:
|
24
|
-
end
|
25
|
-
|
26
|
-
module Test::Spec
|
27
|
-
VERSION = "0.3"
|
28
|
-
|
29
|
-
CONTEXTS = {} # :nodoc:
|
30
|
-
|
31
|
-
class DefinitionError < StandardError
|
32
|
-
end
|
33
|
-
|
34
|
-
class Should
|
35
|
-
include Test::Unit::Assertions
|
36
|
-
|
37
|
-
def self.deprecated_alias(to, from) # :nodoc:
|
38
|
-
define_method(to) { |*args|
|
39
|
-
warn "Test::Spec::Should##{to} is deprecated and will be removed in future versions."
|
40
|
-
__send__ from, *args
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
def initialize(object, message=nil)
|
45
|
-
@object = object
|
46
|
-
@message = message
|
47
|
-
end
|
48
|
-
|
49
|
-
$TEST_SPEC_TESTCASE = nil
|
50
|
-
def add_assertion
|
51
|
-
$TEST_SPEC_TESTCASE && $TEST_SPEC_TESTCASE.__send__(:add_assertion)
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
def an
|
56
|
-
self
|
57
|
-
end
|
58
|
-
|
59
|
-
def a
|
60
|
-
self
|
61
|
-
end
|
62
|
-
|
63
|
-
def not(*args)
|
64
|
-
case args.size
|
65
|
-
when 0
|
66
|
-
ShouldNot.new(@object, @message)
|
67
|
-
when 1
|
68
|
-
ShouldNot.new(@object, @message).pass(args.first)
|
69
|
-
else
|
70
|
-
raise ArgumentError, "#not takes zero or one argument(s)."
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def messaging(message)
|
75
|
-
@message = message.to_s
|
76
|
-
self
|
77
|
-
end
|
78
|
-
alias blaming messaging
|
79
|
-
|
80
|
-
def satisfy(&block)
|
81
|
-
assert_block(@message || "satisfy block failed.") {
|
82
|
-
yield @object
|
83
|
-
}
|
84
|
-
end
|
85
|
-
|
86
|
-
def equal(value)
|
87
|
-
assert_equal value, @object, @message
|
88
|
-
end
|
89
|
-
alias == equal
|
90
|
-
|
91
|
-
def close(value, delta)
|
92
|
-
assert_in_delta value, @object, delta, @message
|
93
|
-
end
|
94
|
-
deprecated_alias :be_close, :close
|
95
|
-
|
96
|
-
def be(*value)
|
97
|
-
case value.size
|
98
|
-
when 0
|
99
|
-
self
|
100
|
-
when 1
|
101
|
-
if CustomShould === value.first
|
102
|
-
pass value.first
|
103
|
-
else
|
104
|
-
assert_same value.first, @object, @message
|
105
|
-
end
|
106
|
-
else
|
107
|
-
raise ArgumentError, "should.be needs zero or one argument"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def match(value)
|
112
|
-
assert_match value, @object, @message
|
113
|
-
end
|
114
|
-
alias =~ match
|
115
|
-
|
116
|
-
def instance_of(klass)
|
117
|
-
assert_instance_of klass, @object, @message
|
118
|
-
end
|
119
|
-
deprecated_alias :be_an_instance_of, :instance_of
|
120
|
-
|
121
|
-
def kind_of(klass)
|
122
|
-
assert_kind_of klass, @object, @message
|
123
|
-
end
|
124
|
-
deprecated_alias :be_a_kind_of, :kind_of
|
125
|
-
|
126
|
-
def respond_to(method)
|
127
|
-
assert_respond_to @object, method, @message
|
128
|
-
end
|
129
|
-
|
130
|
-
def _raise(*args)
|
131
|
-
args = [RuntimeError] if args.empty?
|
132
|
-
assert_raise(*(args + [@message]), &@object)
|
133
|
-
end
|
134
|
-
|
135
|
-
def throw(*args)
|
136
|
-
assert_throws(*(args + [@message]), &@object)
|
137
|
-
end
|
138
|
-
|
139
|
-
def nil
|
140
|
-
assert_nil @object, @message
|
141
|
-
end
|
142
|
-
deprecated_alias :be_nil, :nil
|
143
|
-
|
144
|
-
|
145
|
-
def include(value)
|
146
|
-
msg = build_message(@message, "<?> expected to include ?, but it didn't.",
|
147
|
-
@object, value)
|
148
|
-
assert_block(msg) { @object.include?(value) }
|
149
|
-
end
|
150
|
-
|
151
|
-
def >(value)
|
152
|
-
assert_operator @object, :>, value, @message
|
153
|
-
end
|
154
|
-
|
155
|
-
def >=(value)
|
156
|
-
assert_operator @object, :>=, value, @message
|
157
|
-
end
|
158
|
-
|
159
|
-
def <(value)
|
160
|
-
assert_operator @object, :<, value, @message
|
161
|
-
end
|
162
|
-
|
163
|
-
def <=(value)
|
164
|
-
assert_operator @object, :<=, value, @message
|
165
|
-
end
|
166
|
-
|
167
|
-
def ===(value)
|
168
|
-
assert_operator @object, :===, value, @message
|
169
|
-
end
|
170
|
-
|
171
|
-
def pass(custom)
|
172
|
-
_wrap_assertion {
|
173
|
-
assert_nothing_raised(Test::Unit::AssertionFailedError,
|
174
|
-
@message || custom.failure_message) {
|
175
|
-
assert custom.matches?(@object), @message || custom.failure_message
|
176
|
-
}
|
177
|
-
}
|
178
|
-
end
|
179
|
-
|
180
|
-
def method_missing(name, *args)
|
181
|
-
# This will make raise call Kernel.raise, and self.raise call _raise.
|
182
|
-
return _raise(*args) if name == :raise
|
183
|
-
|
184
|
-
if @object.respond_to?("#{name}?")
|
185
|
-
assert @object.__send__("#{name}?", *args),
|
186
|
-
"#{name}? expected to be true. #{@message}"
|
187
|
-
else
|
188
|
-
super
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
class ShouldNot
|
194
|
-
include Test::Unit::Assertions
|
195
|
-
|
196
|
-
def initialize(object, message=nil)
|
197
|
-
@object = object
|
198
|
-
@message = message
|
199
|
-
end
|
200
|
-
|
201
|
-
def satisfy(&block)
|
202
|
-
assert_block(@message || "not.satisfy block succeded.") {
|
203
|
-
not yield @object
|
204
|
-
}
|
205
|
-
end
|
206
|
-
|
207
|
-
def equal(value)
|
208
|
-
assert_not_equal value, @object, @message
|
209
|
-
end
|
210
|
-
alias == equal
|
211
|
-
|
212
|
-
def be(*value)
|
213
|
-
case value.size
|
214
|
-
when 0
|
215
|
-
self
|
216
|
-
when 1
|
217
|
-
if CustomShould === value.first
|
218
|
-
pass value.first
|
219
|
-
else
|
220
|
-
assert_not_same value.first, @object, @message
|
221
|
-
end
|
222
|
-
else
|
223
|
-
Kernel.raise ArgumentError, "should.be needs zero or one argument"
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
def match(value)
|
228
|
-
# Icky Regexp check
|
229
|
-
assert_no_match value, @object, @message
|
230
|
-
end
|
231
|
-
alias =~ match
|
232
|
-
|
233
|
-
def _raise(*args)
|
234
|
-
assert_nothing_raised(*(args+[@message]), &@object)
|
235
|
-
end
|
236
|
-
|
237
|
-
def throw
|
238
|
-
assert_nothing_thrown(@message, &@object)
|
239
|
-
end
|
240
|
-
|
241
|
-
def nil
|
242
|
-
assert_not_nil @object, @message
|
243
|
-
end
|
244
|
-
|
245
|
-
def be_nil
|
246
|
-
warn "Test::Spec::ShouldNot#be_nil is deprecated and will be removed in future versions."
|
247
|
-
self.nil
|
248
|
-
end
|
249
|
-
|
250
|
-
def not(*args)
|
251
|
-
case args.size
|
252
|
-
when 0
|
253
|
-
Should.new(@object, @message)
|
254
|
-
when 1
|
255
|
-
Should.new(@object, @message).pass(args.first)
|
256
|
-
else
|
257
|
-
raise ArgumentError, "#not takes zero or one argument(s)."
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
def pass(custom)
|
262
|
-
_wrap_assertion {
|
263
|
-
begin
|
264
|
-
assert !custom.matches?(@object), @message || custom.failure_message
|
265
|
-
end
|
266
|
-
}
|
267
|
-
end
|
268
|
-
|
269
|
-
def method_missing(name, *args)
|
270
|
-
# This will make raise call Kernel.raise, and self.raise call _raise.
|
271
|
-
return _raise(*args) if name == :raise
|
272
|
-
|
273
|
-
if @object.respond_to?("#{name}?")
|
274
|
-
assert_block("#{name}? expected to be false. #{@message}") {
|
275
|
-
not @object.__send__("#{name}?", *args)
|
276
|
-
}
|
277
|
-
else
|
278
|
-
super
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
end
|
283
|
-
|
284
|
-
class CustomShould
|
285
|
-
attr_accessor :object
|
286
|
-
|
287
|
-
def initialize(obj)
|
288
|
-
self.object = obj
|
289
|
-
end
|
290
|
-
|
291
|
-
def failure_message
|
292
|
-
"#{self.class.name} failed"
|
293
|
-
end
|
294
|
-
|
295
|
-
def matches?(*args, &block)
|
296
|
-
assumptions(*args, &block)
|
297
|
-
true
|
298
|
-
end
|
299
|
-
|
300
|
-
def assumptions(*args, &block)
|
301
|
-
raise NotImplementedError, "you need to supply a #{self.class}#matches? method"
|
302
|
-
end
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
class Test::Spec::TestCase
|
307
|
-
attr_reader :testcase
|
308
|
-
attr_reader :name
|
309
|
-
attr_reader :position
|
310
|
-
|
311
|
-
module InstanceMethods
|
312
|
-
def setup # :nodoc:
|
313
|
-
$TEST_SPEC_TESTCASE = self
|
314
|
-
super
|
315
|
-
self.class.setups.each { |s| instance_eval(&s) }
|
316
|
-
end
|
317
|
-
|
318
|
-
def teardown # :nodoc:
|
319
|
-
super
|
320
|
-
self.class.teardowns.each { |t| instance_eval(&t) }
|
321
|
-
end
|
322
|
-
|
323
|
-
def initialize(name)
|
324
|
-
super name
|
325
|
-
|
326
|
-
# Don't let the default_test clutter up the results and don't
|
327
|
-
# flunk if no tests given, either.
|
328
|
-
throw :invalid_test if name == :default_test
|
329
|
-
end
|
330
|
-
|
331
|
-
def position
|
332
|
-
self.class.position
|
333
|
-
end
|
334
|
-
|
335
|
-
def context(*args)
|
336
|
-
raise Test::Spec::DefinitionError,
|
337
|
-
"context definition is not allowed inside a specify-block"
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
module ClassMethods
|
342
|
-
attr_accessor :count
|
343
|
-
attr_accessor :name
|
344
|
-
attr_accessor :position
|
345
|
-
attr_accessor :parent
|
346
|
-
|
347
|
-
attr_accessor :setups
|
348
|
-
attr_accessor :teardowns
|
349
|
-
|
350
|
-
def context(name, &block)
|
351
|
-
(Test::Spec::CONTEXTS[self.name + "\t" + name] ||=
|
352
|
-
Test::Spec::TestCase.new(name, self)).add(&block)
|
353
|
-
end
|
354
|
-
|
355
|
-
def specify(specname, &block)
|
356
|
-
raise ArgumentError, "specify needs a block" if block.nil?
|
357
|
-
|
358
|
-
self.count += 1 # Let them run in order of definition
|
359
|
-
|
360
|
-
define_method("test_spec {%s} %03d [%s]" % [name, count, specname], &block)
|
361
|
-
end
|
362
|
-
|
363
|
-
def xspecify(specname, &block)
|
364
|
-
raise ArgumentError, "xspecify needs a block" if block.nil?
|
365
|
-
|
366
|
-
specify specname do
|
367
|
-
@_result.add_disabled(specname)
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
def setup(&block)
|
372
|
-
setups << block
|
373
|
-
end
|
374
|
-
|
375
|
-
def teardown(&block)
|
376
|
-
teardowns << block
|
377
|
-
end
|
378
|
-
|
379
|
-
def init(name, position, parent)
|
380
|
-
self.position = position
|
381
|
-
self.parent = parent
|
382
|
-
|
383
|
-
if parent
|
384
|
-
self.name = parent.name + "\t" + name
|
385
|
-
else
|
386
|
-
self.name = name
|
387
|
-
end
|
388
|
-
|
389
|
-
self.count = 0
|
390
|
-
self.setups = []
|
391
|
-
self.teardowns = []
|
392
|
-
end
|
393
|
-
end
|
394
|
-
|
395
|
-
@@POSITION = 0
|
396
|
-
|
397
|
-
def initialize(name, parent=nil)
|
398
|
-
@testcase = Class.new(Test::Unit::TestCase) {
|
399
|
-
include InstanceMethods
|
400
|
-
extend ClassMethods
|
401
|
-
}
|
402
|
-
|
403
|
-
@@POSITION = @@POSITION + 1
|
404
|
-
@testcase.init(name, @@POSITION, parent)
|
405
|
-
end
|
406
|
-
|
407
|
-
def add(&block)
|
408
|
-
raise ArgumentError, "context needs a block" if block.nil?
|
409
|
-
|
410
|
-
@testcase.class_eval(&block)
|
411
|
-
self
|
412
|
-
end
|
413
|
-
end
|
414
|
-
|
415
|
-
class Test::Spec::Disabled < Test::Unit::Failure # :nodoc:
|
416
|
-
def initialize(name)
|
417
|
-
@name = name
|
418
|
-
end
|
419
|
-
|
420
|
-
def single_character_display
|
421
|
-
"D"
|
422
|
-
end
|
423
|
-
|
424
|
-
def short_display
|
425
|
-
@name
|
426
|
-
end
|
427
|
-
|
428
|
-
def long_display
|
429
|
-
@name + " is disabled"
|
430
|
-
end
|
431
|
-
end
|
432
|
-
|
433
|
-
|
434
|
-
# Monkey-patch test/unit to run tests in an optionally specified order.
|
435
|
-
module Test::Unit # :nodoc:
|
436
|
-
class TestSuite # :nodoc:
|
437
|
-
undef run
|
438
|
-
def run(result, &progress_block)
|
439
|
-
sort!
|
440
|
-
yield(STARTED, name)
|
441
|
-
@tests.each do |test|
|
442
|
-
test.run(result, &progress_block)
|
443
|
-
end
|
444
|
-
yield(FINISHED, name)
|
445
|
-
end
|
446
|
-
|
447
|
-
def sort!
|
448
|
-
@tests = @tests.sort_by { |test|
|
449
|
-
test.respond_to?(:position) ? test.position : 0
|
450
|
-
}
|
451
|
-
end
|
452
|
-
|
453
|
-
def position
|
454
|
-
@tests.first.respond_to?(:position) ? @tests.first.position : 0
|
455
|
-
end
|
456
|
-
end
|
457
|
-
|
458
|
-
class TestResult # :nodoc:
|
459
|
-
# Records a disabled test.
|
460
|
-
def add_disabled(name)
|
461
|
-
notify_listeners(FAULT, Test::Spec::Disabled.new(name))
|
462
|
-
notify_listeners(CHANGED, self)
|
463
|
-
end
|
464
|
-
end
|
465
|
-
end
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
#-- Global helpers
|
470
|
-
|
471
|
-
class Object
|
472
|
-
def should(*args)
|
473
|
-
case args.size
|
474
|
-
when 0
|
475
|
-
Test::Spec::Should.new(self)
|
476
|
-
when 1
|
477
|
-
Test::Spec::Should.new(self).pass(args.first)
|
478
|
-
else
|
479
|
-
raise ArgumentError, "Object#should takes zero or one argument(s)."
|
480
|
-
end
|
481
|
-
end
|
482
|
-
end
|
483
|
-
|
484
|
-
module Kernel
|
485
|
-
def context(name, &block) # :doc:
|
486
|
-
(Test::Spec::CONTEXTS[name] ||= Test::Spec::TestCase.new(name)).add(&block)
|
487
|
-
end
|
488
|
-
|
489
|
-
private :context
|
490
|
-
end
|