class Lucid::InterfaceRb::RbLanguage
Constants
- MATCHER_TYPES
Attributes
current_domain[R]
step_definitions[R]
Public Class Methods
new(runtime)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 42 def initialize(runtime) @runtime = runtime @step_definitions = [] RbLucid.rb_language = self @domain_proc = @domain_modules = nil @assertions_module = find_best_assertions_module end
Private Class Methods
cli_matcher_type_options()
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 166 def self.cli_matcher_type_options MATCHER_TYPES.keys.sort_by(&:to_s).map do |type| MATCHER_TYPES[type].cli_option_string(type) end end
Public Instance Methods
begin_rb_scenario(scenario)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 73 def begin_rb_scenario(scenario) create_domain extend_domain connect_domain(scenario) end
build_rb_world_factory(domain_modules, proc)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 93 def build_rb_world_factory(domain_modules, proc) if(proc) raise MultipleDomain.new(@domain_proc, proc) if @domain_proc @domain_proc = proc end @domain_modules ||= [] @domain_modules += domain_modules end
find_best_assertions_module()
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 50 def find_best_assertions_module begin ::RSpec::Matchers rescue NameError ::Test::Unit::Assertions end end
load_code_file(code_file)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 102 def load_code_file(code_file) # This is what will allow self.add_step_definition, self.add_hook, # and self.add_transform to be called from RbLucid. load File.expand_path(code_file) end
matcher_text(code_keyword, step_name, multiline_arg_class, matcher_type = :regexp)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 68 def matcher_text(code_keyword, step_name, multiline_arg_class, matcher_type = :regexp) matcher_class = typed_matcher_class(matcher_type) matcher_class.new(code_keyword, step_name, multiline_arg_class).to_s end
register_rb_hook(phase, tag_expressions, proc)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 79 def register_rb_hook(phase, tag_expressions, proc) add_hook(phase, RbHook.new(self, tag_expressions, proc)) end
register_rb_step_definition(regexp, proc_or_sym, options)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 87 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
register_rb_transform(regexp, proc)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 83 def register_rb_transform(regexp, proc) add_transform(RbTransform.new(self, regexp, proc)) end
step_matches(name_to_match, name_to_format)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 58 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
Protected Instance Methods
begin_scenario(scenario)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 110 def begin_scenario(scenario) begin_rb_scenario(scenario) end
end_scenario()
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 114 def end_scenario @current_domain = nil end
Private Instance Methods
check_nil(o, proc)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 142 def check_nil(o, proc) if o.nil? begin raise NilDomain.new rescue NilDomain => e e.backtrace.clear e.backtrace.push(proc.backtrace_line('Domain')) raise e end else o end end
connect_domain(scenario)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 137 def connect_domain(scenario) @current_domain.__lucid_runtime = @runtime @current_domain.__natural_language = scenario.language end
create_domain()
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 120 def create_domain if(@domain_proc) @current_domain = @domain_proc.call check_nil(@current_domain, @domain_proc) else @current_domain = Object.new end end
extend_domain()
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 129 def extend_domain @current_domain.extend(RbDomain) @current_domain.extend(@assertions_module) (@domain_modules || []).each do |mod| @current_domain.extend(mod) end end
typed_matcher_class(type)
click to toggle source
# File lib/lucid/interface_rb/rb_language.rb, line 162 def typed_matcher_class(type) MATCHER_TYPES.fetch(type || :regexp) end