Class: GUnit::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/gunit/setup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &blk) ⇒ Setup

Setup.new(“my message”) Setup.new(“my message”) { @foo = “bar” } Setup.new() { @foo = “bar” }



10
11
12
13
# File 'lib/gunit/setup.rb', line 10

def initialize(*args, &blk)
  self.message = args[0]
  self.task = blk if blk
end

Instance Attribute Details

#messageObject



29
30
31
# File 'lib/gunit/setup.rb', line 29

def message
  @message || default_message
end

#taskObject

Returns the value of attribute task.



5
6
7
# File 'lib/gunit/setup.rb', line 5

def task
  @task
end

Instance Method Details

#default_messageObject



33
34
35
# File 'lib/gunit/setup.rb', line 33

def default_message
  "Setup"
end

#run(binding = self) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gunit/setup.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