class Cucumber::Core::Test::Action

Public Class Methods

new(location = nil, &block) click to toggle source
# File lib/cucumber/core/test/action.rb, line 9
def initialize(location = nil, &block)
  raise ArgumentError, "Passing a block to execute the action is mandatory." unless block
  @location = location ? location : Test::Location.new(*block.source_location)
  @block = block
  @timer = Timer.new
end

Public Instance Methods

execute(*args) click to toggle source
# 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
inspect() click to toggle source
# File lib/cucumber/core/test/action.rb, line 34
def inspect
  "#<#{self.class}: #{location}>"
end
location() click to toggle source
# File lib/cucumber/core/test/action.rb, line 30
def location
  @location
end
skip(*) click to toggle source
# File lib/cucumber/core/test/action.rb, line 16
def skip(*)
  skipped
end

Private Instance Methods

failed(exception) click to toggle source
# File lib/cucumber/core/test/action.rb, line 44
def failed(exception)
  Result::Failed.new(@timer.duration, exception)
end
passed() click to toggle source
# File lib/cucumber/core/test/action.rb, line 40
def passed
  Result::Passed.new(@timer.duration)
end
skipped() click to toggle source
# File lib/cucumber/core/test/action.rb, line 48
def skipped
  Result::Skipped.new
end