-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathcucumber_helper.rb
More file actions
56 lines (47 loc) · 1.77 KB
/
Copy pathcucumber_helper.rb
File metadata and controls
56 lines (47 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def prepare_cucumber_example
if Gem::Version.new(Cucumber::VERSION) > Gem::Version.new('3.0')
@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
add_steps_filepath = File.expand_path(File.join(File.dirname(__FILE__), '../../lib/cucumber_factory/add_steps.rb'))
@main.instance_eval(File.read(add_steps_filepath))
end
def invoke_cucumber_step(step, doc_string = nil, data_table = nil)
if Gem::Version.new(Cucumber::VERSION) > Gem::Version.new('2.0')
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