Sha256: d64250e832e4d8bfe3f06c7fee98e1aa29c38aa7ed0a977457bc3a2fc245ce39

Contents?: true

Size: 877 Bytes

Versions: 13

Compression:

Stored size: 877 Bytes

Contents

module Turnip
  module Execute
    def step(step_or_description, *extra_args)

      if step_or_description.respond_to?(:argument) # Turnip::Node::Step
        description = step_or_description.description
        if step_or_description.argument
          extra_args << step_or_description.argument
        end
      else # String
        description = step_or_description
      end

      matches = methods.map do |method|
        next unless method.to_s.start_with?("match: ")
        send(method.to_s, description)
      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

13 entries across 13 versions & 1 rubygems

Version Path
turnip-4.4.1 lib/turnip/execute.rb
turnip-4.4.0 lib/turnip/execute.rb
turnip-4.3.0 lib/turnip/execute.rb
turnip-4.2.0 lib/turnip/execute.rb
turnip-4.1.0 lib/turnip/execute.rb
turnip-4.0.1 lib/turnip/execute.rb
turnip-4.0.0 lib/turnip/execute.rb
turnip-3.1.0 lib/turnip/execute.rb
turnip-3.0.0 lib/turnip/execute.rb
turnip-3.0.0.pre.beta.5 lib/turnip/execute.rb
turnip-3.0.0.pre.beta.4 lib/turnip/execute.rb
turnip-3.0.0.pre.beta.3 lib/turnip/execute.rb
turnip-3.0.0.pre.beta.2 lib/turnip/execute.rb