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

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/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)


10
11
12
13
14
15
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/test/action.rb', line 10

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

Instance Method Details

#execute(*args) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/test/action.rb', line 21

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



35
36
37
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/test/action.rb', line 35

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

#locationObject



31
32
33
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/test/action.rb', line 31

def location
  @location
end

#skipObject



17
18
19
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/test/action.rb', line 17

def skip(*)
  skipped
end