class Cucumber::Runtime::SupportCode
def apply_after_hooks(test_case)
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
def apply_before_hooks(test_case)
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
def configure(new_configuration)
def configure(new_configuration) @configuration = Configuration.new(new_configuration) end
def find_after_step_hooks(test_case)
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
def find_around_hooks(test_case)
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
def fire_hook(name, *args)
def fire_hook(name, *args) # TODO: kill with fire registry.send(name, *args) end
def initialize(user_interface, configuration = Configuration.default)
def initialize(user_interface, configuration = Configuration.default) @configuration = configuration # TODO: needs a better name, or inlining its methods @runtime_facade = Runtime::ForProgrammingLanguages.new(self, user_interface) @registry = Cucumber::Glue::RegistryAndMore.new(@runtime_facade, @configuration) end
def invoke_dynamic_step(step_name, multiline_argument, _location = nil)
- Api: - private
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
def invoke_dynamic_steps(steps_text, iso_code, _location)
Then I should not be thirsty
Given I have 8 cukes in my belly
invoke(%Q{
Invokes a series of steps +steps_text+. Example:
def invoke_dynamic_steps(steps_text, iso_code, _location) parser = Cucumber::Gherkin::StepsParser.new(StepInvoker.new(self), iso_code) parser.parse(steps_text) end
def load_file(file)
def load_file(file) log.debug(" * #{file}\n") registry.load_code_file(file) end
def load_files!(files)
def load_files!(files) log.debug("Code:\n") files.each do |file| load_file(file) end log.debug("\n") end
def load_files_from_paths(paths)
def load_files_from_paths(paths) files = paths.map { |path| Dir["#{path}/**/*.rb"] }.flatten load_files! files end
def log
def log Cucumber.logger end
def step_definitions
def step_definitions registry.step_definitions end
def step_matches(step_name)
def step_matches(step_name) StepMatchSearch.new(registry.method(:step_matches), @configuration).call(step_name) end
def unmatched_step_definitions
def unmatched_step_definitions registry.unmatched_step_definitions end