Class: Cucumber::Core::Test::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/core/test/action.rb

Direct Known Subclasses

UnskippableAction

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Action

Returns a new instance of Action.

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'lib/cucumber/core/test/action.rb', line 10

def initialize(&block)
  raise ArgumentError, "Passing a block to execute the action is mandatory." unless block
  @block = block
  @timer = Timer.new
end

Instance Method Details

#execute(*args) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/cucumber/core/test/action.rb', line 20

def execute(*args)
  @timer.start
  @block.call(*args)
  passed
rescue Result::Raisable => exception
  exception.with_duration(@timer.duration)
rescue Exception => exception
  failed(exception)
end

#inspectObject



34
35
36
# File 'lib/cucumber/core/test/action.rb', line 34

def inspect
  "#<#{self.class}: #{location}>"
end

#locationObject



30
31
32
# File 'lib/cucumber/core/test/action.rb', line 30

def location
  Ast::Location.new(*@block.source_location)
end

#skipObject



16
17
18
# File 'lib/cucumber/core/test/action.rb', line 16

def skip(*)
  skipped
end