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

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

Direct Known Subclasses

Unskippable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location = nil, &block) ⇒ Defined

Returns a new instance of Defined.

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
# File 'lib/cucumber/core/test/action/defined.rb', line 14

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 Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

Instance Method Details

#execute(*args) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/cucumber/core/test/action/defined.rb', line 26

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

#inspectObject



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

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

#skipObject



22
23
24
# File 'lib/cucumber/core/test/action/defined.rb', line 22

def skip(*)
  skipped
end