Sha256: e0ede952f2dba90590d485a19efd604ebef1a23b67b6150f4895a44477cbe0d5

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

module Turnip
  module Execute
    def step(description, *extra_args)
      extra_args.concat(description.extra_args) if description.respond_to?(:extra_args)

      matches = methods.map do |method|
        next unless method.to_s.start_with?("match: ")
        send(method.to_s, description.to_s)
      end.compact

      if matches.length == 0
        raise Turnip::Pending, description
      end

      if matches.length > 1
        msg = ['Ambiguous step definitions'].concat(matches.map(&:trace)).join("\r\n")
        raise Turnip::Ambiguous, msg
      end

      send(matches.first.method_name, *(matches.first.params + extra_args))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
turnip-1.2.2 lib/turnip/execute.rb
turnip-1.2.1 lib/turnip/execute.rb
turnip-1.2.0 lib/turnip/execute.rb
turnip-1.1.0 lib/turnip/execute.rb