Module: Gurke::Steps

Defined in:
lib/gurke/steps.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_step(step, world, type) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gurke/steps.rb', line 21

def find_step(step, world, type)
  matches = world.methods.map do |method|
    next unless method.to_s.start_with?('match: ')
    world.send(method.to_s, step.to_s, type)
  end.compact

  case matches.size
    when 0 then raise Gurke::StepPending.new step.to_s
    when 1 then matches.first
    else raise Gurke::StepAmbiguous.new step.to_s
  end
end

Instance Method Details

#Given(step) ⇒ Object



5
6
7
8
# File 'lib/gurke/steps.rb', line 5

def Given(step)
  rst = self.class.find_step(step, self, :given)
  send rst.method_name
end

#Then(step) ⇒ Object



15
16
17
18
# File 'lib/gurke/steps.rb', line 15

def Then(step)
  rst = self.class.find_step(step, self, :then)
  send rst.method_name
end

#When(step) ⇒ Object



10
11
12
13
# File 'lib/gurke/steps.rb', line 10

def When(step)
  rst = self.class.find_step(step, self, :when)
  send rst.method_name
end