Sha256: e8b55754994598d4809977773ac0f76daa64acedfb2e53bbc5fffae08cff1b85

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 KB

Contents

def prepare_cucumber_example
  if Cucumber::VERSION >= '3'
    @runtime = Cucumber::Runtime.new
    scenario = double('scenario', :language => 'en', :accept_hook? => true)
    @runtime.send(:begin_scenario, scenario)
    @main = Object.new
    @main.extend(Cucumber::Glue::Dsl)
  else
    @runtime = Cucumber::Runtime.new
    language = support_code.ruby if support_code.respond_to?(:ruby)
    language ||= support_code.load_programming_language('rb')
    language
    scenario = double('scenario', :language => 'en', :accept_hook? => true)
    language.send(:begin_scenario, scenario)
    @world = language.current_world
    @main = Object.new
    @main.extend(Cucumber::RbSupport::RbDsl)
  end

  Cucumber::Factory.add_steps(@main)
end

def invoke_cucumber_step(step, doc_string = nil, data_table = nil)
  if Cucumber::VERSION >= '2'
    multiline_argument = Cucumber::MultilineArgument::None.new

    if doc_string.present?
      multiline_argument = Cucumber::MultilineArgument::DocString.new(doc_string)
    end

    if data_table.present?
      multiline_argument = Cucumber::MultilineArgument::DataTable.from(data_table)
    end
  else
    multiline_argument = nil

    if doc_string.present?
      multiline_argument =  Cucumber::Ast::DocString.new(doc_string, '')
    end

    if data_table.present?
      multiline_argument = Cucumber::Ast::Table.parse(data_table, nil, nil)
    end
  end

  first_step_match(step).invoke(multiline_argument)
end

def support_code
  @runtime.instance_variable_get(:@support_code)
end

def first_step_match(*args)
  support_code.send(:step_matches, *args).first
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cucumber_factory-1.14.2 spec/support/cucumber_helper.rb
cucumber_factory-1.14.1 spec/support/cucumber_helper.rb
cucumber_factory-1.14.0 spec/support/cucumber_helper.rb
cucumber_factory-1.13.0 spec/support/cucumber_helper.rb