Sha256: d7a1c69db753ae3e64fb29f2b7fddacc9050ce4f8ca07876ad763e205589e9ca

Contents?: true

Size: 1.65 KB

Versions: 16

Compression:

Stored size: 1.65 KB

Contents

# cucumber transforms
_folder = 'cucumber/pickles/'

require _folder + 'transform'
require _folder + 'fill_in'
require _folder + 'check_in'

_steps_folder = _folder + 'steps/'

module Pickles::StepDef

  module_function

  def define_table_step(allowed_table_cols)
    -> ( within, table ) do

      Waiter.wait_for_ajax

      if table.headers.length == 3 && 3.in?(allowed_table_cols)
        current_within = within

        rows = table.rows.unshift(table.headers)

        rows.each do |(within, label, value)|
          case within
          when Helpers::Regex::WITHIN
            current_within = Pickles.detect_node($1, $2, within: within)
          when "-"
            current_within = within
          end

          if label['pry']
            label['pry'] = ''

            pry binding
          end

          yield(label, value, current_within)
        end
      elsif table.headers.length == 2 && 2.in?(allowed_table_cols)
        table.rows_hash.each do |label, value|
          if label['pry']
            label['pry'] = ''

            pry binding
          end

          yield(label, value, within)
        end
      elsif table.headers.length == 1 && 1.in?(allowed_table_cols)
        table.each do |label|
          if label['pry']
            label['pry'] = ''

            pry binding
          end

          yield(label, nil, within)
        end
      else
        raise(ArgumentError, "Unsupported table format. Must contain #{allowed_table_cols.join(' || ')} cols")
      end

    end
  end

end

require _steps_folder + 'fill'
require _steps_folder + 'check'
require _steps_folder + 'can_see'
require _steps_folder + 'redirect'
require _steps_folder + 'click'

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pickles-0.2.4 lib/cucumber/pickles/steps.rb
pickles-0.2.3 lib/cucumber/pickles/steps.rb
pickles-0.2.2 lib/cucumber/pickles/steps.rb
pickles-0.2.1 lib/cucumber/pickles/steps.rb
pickles-0.2.0 lib/cucumber/pickles/steps.rb
pickles-0.1.12 lib/cucumber/pickles/steps.rb
pickles-0.1.10 lib/cucumber/pickles/steps.rb
pickles-0.1.9 lib/cucumber/pickles/steps.rb
pickles-0.1.8 lib/cucumber/pickles/steps.rb
pickles-0.1.7 lib/cucumber/pickles/steps.rb
pickles-0.1.6 lib/cucumber/pickles/steps.rb
pickles-0.1.5 lib/cucumber/pickles/steps.rb
pickles-0.1.4 lib/cucumber/pickles/steps.rb
pickles-0.1.3 lib/cucumber/pickles/steps.rb
pickles-0.1.2 lib/cucumber/pickles/steps.rb
pickles-0.1.1 lib/cucumber/pickles/steps.rb