Sha256: bab6514ddbb6210de9a8c02ccf41525e1a786e240c6536b2e38a459b9fce59a4

Contents?: true

Size: 691 Bytes

Versions: 2

Compression:

Stored size: 691 Bytes

Contents

class FillIN::Factory

  TAG = /^(.+\S+)\s*\((.*)\)$/

  def initialize(label, value, within: nil)
    @label = label
    @value = value
    @within = within
  end

  def call
    if in_quotes?
      remove_quotes!
    end

    if !@value.nil? && @value[':'] && !in_quotes?
      step = FillIN::ComplexInput
    elsif @label =~ TAG
      @label = $1
      tag = $2
      step = Pickles.config.step_by_tag(tag) || FillIN::Input
    else
      step = FillIN::Input
    end

    step.new(@label, @value, @within)
  end

private

  def in_quotes?
    @in_quotes ||= @value && @value[0] == "\"" && @value[-1] == "\""
  end

  def remove_quotes!
    @value[0]  = ''
    @value[-1] = ''
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pickles-0.1.10 lib/cucumber/pickles/steps/fill_in/factory.rb
pickles-0.1.9 lib/cucumber/pickles/steps/fill_in/factory.rb