Class: GUnit::Groundwork
- Inherits:
-
Object
show all
- Defined in:
- lib/gunit/groundwork.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args, &blk) ⇒ Groundwork
Groundwork.new(“my message”) Groundwork.new(“my message”) { @foo.bar() } Groundwork.new() { @foo.bar() }
10
11
12
13
|
# File 'lib/gunit/groundwork.rb', line 10
def initialize(*args, &blk)
self.message = args[0]
self.task = blk if blk
end
|
Instance Attribute Details
#message ⇒ Object
29
30
31
|
# File 'lib/gunit/groundwork.rb', line 29
def message
@message || default_message
end
|
#task ⇒ Object
Returns the value of attribute task.
5
6
7
|
# File 'lib/gunit/groundwork.rb', line 5
def task
@task
end
|
Instance Method Details
#default_message ⇒ Object
33
34
35
|
# File 'lib/gunit/groundwork.rb', line 33
def default_message
self.class.to_s.split('::').last
end
|
#run(binding = self) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/gunit/groundwork.rb', line 15
def run(binding=self)
begin
if @task.is_a?(Proc)
bound_task = @task.bind(binding)
bound_task.call
end
return true
rescue GUnit::AssertionFailure => e
FailResponse.new
rescue ::StandardError => e
ExceptionResponse.new
end
end
|