Class: Lucid::InterfaceRb::RbLanguage
Overview
This module is the Ruby implementation of the TDL API.
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#begin_rb_scenario(scenario) ⇒ Object
-
#build_rb_world_factory(domain_modules, proc) ⇒ Object
-
#find_best_assertions_module ⇒ Object
-
#initialize(runtime) ⇒ RbLanguage
constructor
A new instance of RbLanguage.
-
#load_code_file(code_file) ⇒ Object
-
#matcher_text(code_keyword, step_name, multiline_arg_class, matcher_type = :regexp) ⇒ Object
-
#register_rb_hook(phase, tag_expressions, proc) ⇒ Object
-
#register_rb_step_definition(regexp, proc_or_sym, options) ⇒ Object
-
#register_rb_transform(regexp, proc) ⇒ Object
-
#step_matches(name_to_match, name_to_format) ⇒ Object
#add_hook, #add_transform, #after, #after_configuration, #around, #available_step_definition, #before, #clear_hooks, #execute_after_step, #execute_transforms, #hooks_for, #invoked_step_definition, #unmatched_step_definitions
Constructor Details
#initialize(runtime) ⇒ RbLanguage
Returns a new instance of RbLanguage.
52
53
54
55
56
57
58
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 52
def initialize(runtime)
@runtime = runtime
@step_definitions = []
RbLucid.rb_language = self
@domain_proc = @domain_modules = nil
@assertions_module = find_best_assertions_module
end
|
Instance Attribute Details
#current_domain ⇒ Object
Returns the value of attribute current_domain.
44
45
46
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 44
def current_domain
@current_domain
end
|
#step_definitions ⇒ Object
Returns the value of attribute step_definitions.
44
45
46
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 44
def step_definitions
@step_definitions
end
|
Instance Method Details
#begin_rb_scenario(scenario) ⇒ Object
90
91
92
93
94
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 90
def begin_rb_scenario(scenario)
create_domain
extend_domain
connect_domain(scenario)
end
|
#build_rb_world_factory(domain_modules, proc) ⇒ Object
110
111
112
113
114
115
116
117
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 110
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 ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 60
def find_best_assertions_module
begin
::RSpec::Matchers
rescue NameError
begin
options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
Spec::Expectations.differ = Spec::Expectations::Differs::Default.new(options)
::Spec::Matchers
rescue NameError
::Test::Unit::Assertions
end
end
end
|
#load_code_file(code_file) ⇒ Object
119
120
121
122
123
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 119
def load_code_file(code_file)
load File.expand_path(code_file)
end
|
#matcher_text(code_keyword, step_name, multiline_arg_class, matcher_type = :regexp) ⇒ Object
85
86
87
88
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 85
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) ⇒ Object
96
97
98
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 96
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) ⇒ Object
104
105
106
107
108
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 104
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
|
#step_matches(name_to_match, name_to_format) ⇒ Object
75
76
77
78
79
80
81
82
83
|
# File 'lib/lucid/interface_rb/rb_language.rb', line 75
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
|