class Cucumber::RbSupport::RbLanguage
The Ruby implementation of the programming language API.
def self.cli_snippet_type_options
def self.cli_snippet_type_options SNIPPET_TYPES.keys.sort_by(&:to_s).map do |type| SNIPPET_TYPES[type].cli_option_string(type) end end
def begin_rb_scenario(scenario)
def begin_rb_scenario(scenario) create_world extend_world connect_world(scenario) end
def begin_scenario(scenario)
def begin_scenario(scenario) begin_rb_scenario(scenario) end
def build_rb_world_factory(world_modules, proc)
def build_rb_world_factory(world_modules, proc) if(proc) raise MultipleWorld.new(@world_proc, proc) if @world_proc @world_proc = proc end @world_modules ||= [] @world_modules += world_modules end
def check_nil(o, proc)
def check_nil(o, proc) if o.nil? begin raise NilWorld.new rescue NilWorld => e e.backtrace.clear e.backtrace.push(RbSupport.backtrace_line(proc, "World")) raise e end else o end end
def connect_world(scenario)
def connect_world(scenario) @current_world.__cucumber_runtime = @runtime @current_world.__natural_language = scenario.language end
def create_world
def create_world if(@world_proc) @current_world = @world_proc.call check_nil(@current_world, @world_proc) else @current_world = Object.new end end
def end_scenario
def end_scenario @current_world = nil end
def extend_world
def extend_world @current_world.extend(RbWorld) MultiTest.extend_with_best_assertion_library(@current_world) (@world_modules || []).each do |mod| @current_world.extend(mod) end end
def initialize(runtime)
def initialize(runtime) @runtime = runtime @step_definitions = [] RbDsl.rb_language = self @world_proc = @world_modules = nil end
def load_code_file(code_file)
def load_code_file(code_file) load File.expand_path(code_file) # This will cause self.add_step_definition, self.add_hook, and self.add_transform to be called from RbDsl end
def register_rb_hook(phase, tag_expressions, proc)
def register_rb_hook(phase, tag_expressions, proc) add_hook(phase, RbHook.new(self, tag_expressions, proc)) end
def register_rb_step_definition(regexp, proc_or_sym, options)
def register_rb_step_definition(regexp, proc_or_sym, options) step_definition = RbStepDefinition.new(self, regexp, proc_or_sym, options) @step_definitions << step_definition step_definition end
def register_rb_transform(regexp, proc)
def register_rb_transform(regexp, proc) add_transform(RbTransform.new(self, regexp, proc)) end
def snippet_text(code_keyword, step_name, multiline_arg, snippet_type = :regexp)
def snippet_text(code_keyword, step_name, multiline_arg, snippet_type = :regexp) snippet_class = typed_snippet_class(snippet_type) snippet_class.new(code_keyword, step_name, multiline_arg).to_s end
def step_matches(name_to_match, name_to_format)
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
def typed_snippet_class(type)
def typed_snippet_class(type) SNIPPET_TYPES.fetch(type || :regexp) end