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



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

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

    world.send(method.to_s, step.to_s, type)
  end

  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

rubocop:disable Naming/MethodName



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

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

#Then(step) ⇒ Object



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

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

#When(step) ⇒ Object



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

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