Class: Cucumber::Runtime::SupportCode
- Inherits:
-
Object
- Object
- Cucumber::Runtime::SupportCode
show all
- Includes:
- Constantize
- Defined in:
- lib/cucumber/runtime/support_code.rb
Defined Under Namespace
Classes: StepInvoker
Instance Attribute Summary collapse
Instance Method Summary
collapse
#constantize, #underscore
Instance Attribute Details
permalink
#registry ⇒ Object
Returns the value of attribute registry.
[
View on GitHub]
42
43
44
|
# File 'lib/cucumber/runtime/support_code.rb', line 42
def registry
@registry
end
|
Instance Method Details
permalink
#apply_after_hooks(test_case) ⇒ Object
[View source] [
View on GitHub]
119
120
121
122
123
124
125
|
# File 'lib/cucumber/runtime/support_code.rb', line 119
def apply_after_hooks(test_case)
return test_case if test_case.test_steps.empty?
scenario = RunningTestCase.new(test_case)
hooks = registry.hooks_for(:after, scenario)
AfterHooks.new(@configuration.id_generator, hooks, scenario, @configuration.event_bus).apply_to(test_case)
end
|
permalink
#apply_before_hooks(test_case) ⇒ Object
[View source] [
View on GitHub]
111
112
113
114
115
116
117
|
# File 'lib/cucumber/runtime/support_code.rb', line 111
def apply_before_hooks(test_case)
return test_case if test_case.test_steps.empty?
scenario = RunningTestCase.new(test_case)
hooks = registry.hooks_for(:before, scenario)
BeforeHooks.new(@configuration.id_generator, hooks, scenario, @configuration.event_bus).apply_to(test_case)
end
|
permalink
#find_after_step_hooks(test_case) ⇒ Object
[View source] [
View on GitHub]
105
106
107
108
109
|
# File 'lib/cucumber/runtime/support_code.rb', line 105
def find_after_step_hooks(test_case)
scenario = RunningTestCase.new(test_case)
hooks = registry.hooks_for(:after_step, scenario)
StepHooks.new(@configuration.id_generator, hooks, @configuration.event_bus)
end
|
permalink
#find_around_hooks(test_case) ⇒ Object
[View source] [
View on GitHub]
127
128
129
130
131
132
133
134
135
|
# File 'lib/cucumber/runtime/support_code.rb', line 127
def find_around_hooks(test_case)
scenario = RunningTestCase.new(test_case)
registry.hooks_for(:around, scenario).map do |hook|
Hooks.around_hook do |run_scenario|
hook.invoke('Around', scenario, &run_scenario)
end
end
end
|
permalink
#fire_hook(name, *args) ⇒ Object
[View source] [
View on GitHub]
96
97
98
99
|
# File 'lib/cucumber/runtime/support_code.rb', line 96
def fire_hook(name, *args)
registry.send(name, *args)
end
|
permalink
#invoke_dynamic_step(step_name, multiline_argument, _location = nil) ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
This allows users to attempt to find, match and execute steps from code as the features are running, as opposed to regular steps which are compiled into test steps before execution.
These are commonly called nested steps.
[View source] [
View on GitHub]
72
73
74
75
76
77
|
# File 'lib/cucumber/runtime/support_code.rb', line 72
def invoke_dynamic_step(step_name, multiline_argument, _location = nil)
matches = step_matches(step_name)
raise UndefinedDynamicStep, step_name if matches.empty?
matches.first.invoke(multiline_argument)
end
|
permalink
#invoke_dynamic_steps(steps_text, iso_code, _location) ⇒ Object
Invokes a series of steps steps_text
. Example:
invoke(%Q{
Given I have 8 cukes in my belly
Then I should not be thirsty
})
[View source] [
View on GitHub]
61
62
63
64
|
# File 'lib/cucumber/runtime/support_code.rb', line 61
def invoke_dynamic_steps(steps_text, iso_code, _location)
parser = Cucumber::Gherkin::StepsParser.new(StepInvoker.new(self), iso_code)
parser.parse(steps_text)
end
|
permalink
#load_files!(files) ⇒ Object
[View source] [
View on GitHub]
79
80
81
82
83
84
85
|
# File 'lib/cucumber/runtime/support_code.rb', line 79
def load_files!(files)
log.debug("Code:\n")
files.each do |file|
load_file(file)
end
log.debug("\n")
end
|
permalink
#load_files_from_paths(paths) ⇒ Object
[View source] [
View on GitHub]
87
88
89
90
|
# File 'lib/cucumber/runtime/support_code.rb', line 87
def load_files_from_paths(paths)
files = paths.map { |path| Dir["#{path}/**/*.rb"] }.flatten
load_files! files
end
|
permalink
#step_definitions ⇒ Object
[View source] [
View on GitHub]
101
102
103
|
# File 'lib/cucumber/runtime/support_code.rb', line 101
def step_definitions
registry.step_definitions
end
|
permalink
#unmatched_step_definitions ⇒ Object
[View source] [
View on GitHub]
92
93
94
|
# File 'lib/cucumber/runtime/support_code.rb', line 92
def unmatched_step_definitions
registry.unmatched_step_definitions
end
|