Class: Cucumber::JsSupport::JsLanguage
Constant Summary
Constants included
from JsSnippets
Cucumber::JsSupport::JsSnippets::ESCAPED_PARAM_PATTERN, Cucumber::JsSupport::JsSnippets::PARAM_PATTERN
Instance Method Summary
collapse
Methods included from JsSnippets
#snippet_text
#add_hook, #add_transform, #after, #after_configuration, #around, #available_step_definition, #before, #clear_hooks, #create_step_match, #execute_after_step, #execute_transforms, #hooks_for, #invoked_step_definition, #unmatched_step_definitions
Constructor Details
#initialize(runtime) ⇒ JsLanguage
Returns a new instance of JsLanguage.
108
109
110
111
112
113
114
115
|
# File 'lib/cucumber/js_support/js_language.rb', line 108
def initialize(runtime)
@step_definitions = []
@world = JsWorld.new
@runtime = runtime
@world["jsLanguage"] = self
@world.load(File.dirname(__FILE__) + '/js_dsl.js')
end
|
Instance Method Details
#add_step_definition(regexp, js_function) ⇒ Object
147
148
149
|
# File 'lib/cucumber/js_support/js_language.rb', line 147
def add_step_definition(regexp, js_function)
@step_definitions << JsStepDefinition.new(self, regexp, js_function)
end
|
#alias_adverbs(adverbs) ⇒ Object
127
128
|
# File 'lib/cucumber/js_support/js_language.rb', line 127
def alias_adverbs(adverbs)
end
|
#begin_scenario(scenario) ⇒ Object
130
131
132
|
# File 'lib/cucumber/js_support/js_language.rb', line 130
def begin_scenario(scenario)
@language = scenario.language
end
|
#current_world ⇒ Object
164
165
166
|
# File 'lib/cucumber/js_support/js_language.rb', line 164
def current_world
@world
end
|
#end_scenario ⇒ Object
134
135
|
# File 'lib/cucumber/js_support/js_language.rb', line 134
def end_scenario
end
|
#execute_step_definition(name, multiline_argument = nil) ⇒ Object
TODO: support multiline arguments when calling steps from within steps
152
153
154
|
# File 'lib/cucumber/js_support/js_language.rb', line 152
def execute_step_definition(name, multiline_argument = nil)
@runtime.step_match(name).invoke(multiline_argument)
end
|
#load_code_file(js_file) ⇒ Object
117
118
119
|
# File 'lib/cucumber/js_support/js_language.rb', line 117
def load_code_file(js_file)
@world.load(js_file)
end
|
#register_js_hook(phase, tag_expressions, js_function) ⇒ Object
156
157
158
|
# File 'lib/cucumber/js_support/js_language.rb', line 156
def register_js_hook(phase, tag_expressions, js_function)
add_hook(phase, JsHook.new(self, tag_expressions, js_function))
end
|
160
161
162
|
# File 'lib/cucumber/js_support/js_language.rb', line 160
def register_js_transform(regexp, js_function)
add_transform(JsTransform.new(self, regexp, js_function))
end
|
#step_matches(name_to_match, name_to_format) ⇒ Object
137
138
139
140
141
142
143
144
145
|
# File 'lib/cucumber/js_support/js_language.rb', line 137
def step_matches(name_to_match, name_to_format)
@step_definitions.map do |step_definition|
if(arguments = step_definition.arguments_from(name_to_match))
StepMatch.new(step_definition, name_to_match, name_to_format, arguments)
else
nil
end
end.compact
end
|
#steps(steps_text, file_colon_line) ⇒ Object
168
169
170
|
# File 'lib/cucumber/js_support/js_language.rb', line 168
def steps(steps_text, file_colon_line)
@runtime.invoke_steps(steps_text, @language, file_colon_line)
end
|
#world(js_files) ⇒ Object
121
122
123
124
125
|
# File 'lib/cucumber/js_support/js_language.rb', line 121
def world(js_files)
js_files.each do |js_file|
load_code_file("#{path_to_load_js_from}#{js_file}")
end
end
|