Class: Cucumber::Core::Test::Step

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, action = Test::UndefinedAction.new) ⇒ Step

Returns a new instance of Step.

Raises:

  • (ArgumentError)


10
11
12
13
# File 'lib/cucumber/core/test/step.rb', line 10

def initialize(source, action = Test::UndefinedAction.new)
  raise ArgumentError if source.any?(&:nil?)
  @source, @action = source, action
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



8
9
10
# File 'lib/cucumber/core/test/step.rb', line 8

def source
  @source
end

Instance Method Details

#describe_source_to(visitor, *args) ⇒ Object



19
20
21
22
23
24
# File 'lib/cucumber/core/test/step.rb', line 19

def describe_source_to(visitor, *args)
  source.reverse.each do |node|
    node.describe_to(visitor, *args)
  end
  self
end

#describe_to(visitor, *args) ⇒ Object



15
16
17
# File 'lib/cucumber/core/test/step.rb', line 15

def describe_to(visitor, *args)
  visitor.test_step(self, *args)
end

#execute(*args) ⇒ Object



30
31
32
# File 'lib/cucumber/core/test/step.rb', line 30

def execute(*args)
  @action.execute(*args)
end

#inspectObject



51
52
53
# File 'lib/cucumber/core/test/step.rb', line 51

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

#locationObject



42
43
44
# File 'lib/cucumber/core/test/step.rb', line 42

def location
  source.last.location
end

#match_locations?(queried_locations) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
# File 'lib/cucumber/core/test/step.rb', line 46

def match_locations?(queried_locations)
  return true if queried_locations.include? location
  source.any? { |s| s.match_locations?(queried_locations) }
end

#nameObject



38
39
40
# File 'lib/cucumber/core/test/step.rb', line 38

def name
  source.last.name
end

#skip(*args) ⇒ Object



26
27
28
# File 'lib/cucumber/core/test/step.rb', line 26

def skip(*args)
  @action.skip(*args)
end

#with_action(&block) ⇒ Object



34
35
36
# File 'lib/cucumber/core/test/step.rb', line 34

def with_action(&block)
  self.class.new(source, Test::Action.new(&block))
end