module Turnip::ExtraSteps::Support::TableStepsHelper

Public Instance Methods

parse_table(table) click to toggle source
# File lib/turnip/extra_steps/table_steps.rb, line 91
def parse_table(table)
  if table.is_a?(String)
    table.sub!(/^\n/, '')
    # multiline string. split it assuming a format like cucumber tables have.
    table.split(/\n/).collect do |line|
      line.sub!(/^\|/, '')
      line.sub!(/\|$/, '')
      line.gsub!(/^\ +/, '')
      line.gsub!(/\ +$/, '')
      line.split(/\s*\|\s*/)
    end
  else
    # vanilla cucumber table.
    table.raw
  end
end