Sha256: cada530d956f63b73f611637b8fafd530f8c6781059cef03043e408705a622be

Contents?: true

Size: 834 Bytes

Versions: 15

Compression:

Stored size: 834 Bytes

Contents

# rubocop:disable MethodName

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

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

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

    class << self
      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
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gurke-2.4.2 lib/gurke/steps.rb
gurke-2.4.1 lib/gurke/steps.rb
gurke-2.4.0 lib/gurke/steps.rb
gurke-2.3.0 lib/gurke/steps.rb
gurke-2.2.2 lib/gurke/steps.rb
gurke-2.2.1 lib/gurke/steps.rb
gurke-2.1.0 lib/gurke/steps.rb
gurke-2.0.3 lib/gurke/steps.rb
gurke-2.0.2 lib/gurke/steps.rb
gurke-2.0.1 lib/gurke/steps.rb
gurke-2.0.0 lib/gurke/steps.rb
gurke-2.0.0.dev.1.b25 lib/gurke/steps.rb
gurke-2.0.0.dev.1.b24 lib/gurke/steps.rb
gurke-2.0.0.dev.1.b23 lib/gurke/steps.rb
gurke-2.0.0.dev.1.b22 lib/gurke/steps.rb