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

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/core/test/actions/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
17
# File 'lib/cucumber/core/test/actions/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



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

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



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

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

#locationObject



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

def location
  @location
end

#skipObject



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

def skip(*)
  skipped
end