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(location = nil, &block) ⇒ Action

Returns a new instance of Action.

Raises:

  • (ArgumentError)


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

def initialize(location = nil, &block)
  raise ArgumentError, 'Passing a block to execute the action is mandatory.' unless block
  @location = location || Test::Location.new(*block.source_location)
  @block = block
  @timer = Timer.new
end

Instance Method Details

#execute(*args) ⇒ Object



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

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



36
37
38
# File 'lib/cucumber/core/test/action.rb', line 36

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

#locationObject



32
33
34
# File 'lib/cucumber/core/test/action.rb', line 32

def location
  @location
end

#skipObject



18
19
20
# File 'lib/cucumber/core/test/action.rb', line 18

def skip(*)
  skipped
end