Class: Mustard::Test
Constant Summary
collapse
- @@all =
{}
Instance Attribute Summary
Attributes inherited from Scope
#name
Class Method Summary
collapse
Instance Method Summary
collapse
-
#assert!(context = nil, &callbk) ⇒ Object
-
#initialize(name, *scopes, &defn) ⇒ Test
constructor
-
#must(name = nil, file = __FILE__, line = __LINE__, &blk) ⇒ Object
-
#must_not(name = nil, file = __FILE__, line = __LINE__, &blk) ⇒ Object
-
#test(name = nil, &defn) ⇒ Object
def go( name, &blk ) Test.new “#selfself.name+#Scope#name”, self, &blk end.
Methods inherited from Scope
[], #setup, #teardown, #use!, #with
Constructor Details
#initialize(name, *scopes, &defn) ⇒ Test
Returns a new instance of Test.
14
15
16
17
|
# File 'lib/mustard/test.rb', line 14
def initialize( name, *scopes, &defn )
@assertions = []
super name, *scopes, &defn
end
|
Class Method Details
.use(name = nil, *scopes, &defn) ⇒ Object
8
9
10
11
12
|
# File 'lib/mustard/test.rb', line 8
def self.use( name = nil, *scopes, &defn )
t = Scope[name] || Test.new( name, *scopes )
t.instance_eval( &defn ) if defn
t
end
|
Instance Method Details
#assert!(context = nil, &callbk) ⇒ Object
35
36
37
38
39
|
# File 'lib/mustard/test.rb', line 35
def assert!( context = nil, &callbk )
use! context do |ctx|
@assertions.each { |a| a.assert!( ctx, &callbk ) }
end
end
|
#must(name = nil, file = __FILE__, line = __LINE__, &blk) ⇒ Object
19
20
21
|
# File 'lib/mustard/test.rb', line 19
def must( name = nil, file = __FILE__, line = __LINE__, &blk )
@assertions << Assertion.new( name, self, file, line, &blk )
end
|
#must_not(name = nil, file = __FILE__, line = __LINE__, &blk) ⇒ Object
23
24
25
|
# File 'lib/mustard/test.rb', line 23
def must_not( name = nil, file = __FILE__, line = __LINE__, &blk )
@assertions << Assertion.new( (name && "not #{name}"), self, file, line ) { ! instance_eval(&blk) }
end
|
#test(name = nil, &defn) ⇒ Object
def go( name, &blk )
Test.new "#{self.name}+#{name}", self, &blk
end
31
32
33
|
# File 'lib/mustard/test.rb', line 31
def test( name = nil, &defn )
@assertions << Test.new( name, self, &defn )
end
|