module Cucumber::LanguageSupport::LanguageMethods
Public Instance Methods
add_hook(phase, hook)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 42 def add_hook(phase, hook) hooks[phase.to_sym] << hook hook end
add_transform(transform)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 51 def add_transform(transform) transforms.unshift transform transform end
after(scenario)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 18 def after(scenario) execute_after(scenario) end_scenario end
after_configuration(configuration)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 23 def after_configuration(configuration) hooks[:after_configuration].each do |hook| hook.invoke('AfterConfiguration', configuration) end end
around(scenario) { || ... }
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 7 def around(scenario) execute_around(scenario) do yield end end
available_step_definition(regexp_source, file_colon_line)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 64 def available_step_definition(regexp_source, file_colon_line) available_step_definition_hash[StepDefinitionLight.new(regexp_source, file_colon_line)] = nil end
before(scenario)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 13 def before(scenario) begin_scenario(scenario) execute_before(scenario) end
clear_hooks()
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 47 def clear_hooks @hooks = nil end
execute_after_step(scenario)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 29 def execute_after_step(scenario) hooks_for(:after_step, scenario).each do |hook| invoke(hook, 'AfterStep', scenario, false) end end
execute_transforms(args)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 35 def execute_transforms(args) args.map do |arg| matching_transform = transforms.detect {|transform| transform.match(arg) } matching_transform ? matching_transform.invoke(arg) : arg end end
invoked_step_definition(regexp_source, file_colon_line)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 68 def invoked_step_definition(regexp_source, file_colon_line) invoked_step_definition_hash[StepDefinitionLight.new(regexp_source, file_colon_line)] = nil end
unmatched_step_definitions()
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 60 def unmatched_step_definitions available_step_definition_hash.keys - invoked_step_definition_hash.keys end
Private Instance Methods
available_step_definition_hash()
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 74 def available_step_definition_hash @available_step_definition_hash ||= {} end
execute_after(scenario)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 106 def execute_after(scenario) hooks_for(:after, scenario).reverse_each do |hook| invoke(hook, 'After', scenario, true) end end
execute_around(scenario, &block)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 90 def execute_around(scenario, &block) hooks_for(:around, scenario).reverse.inject(block) do |blk, hook| proc do invoke(hook, 'Around', scenario, true) do blk.call(scenario) end end end.call end
execute_before(scenario)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 100 def execute_before(scenario) hooks_for(:before, scenario).each do |hook| invoke(hook, 'Before', scenario, true) end end
hooks()
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 82 def hooks @hooks ||= Hash.new{|h,k| h[k] = []} end
invoke(hook, location, scenario, exception_fails_scenario, &block)
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 112 def invoke(hook, location, scenario, exception_fails_scenario, &block) begin hook.invoke(location, scenario, &block) rescue Exception => exception if exception_fails_scenario scenario.fail!(exception) else raise end end end
invoked_step_definition_hash()
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 78 def invoked_step_definition_hash @invoked_step_definition_hash ||= {} end
transforms()
click to toggle source
# File lib/cucumber/language_support/language_methods.rb, line 86 def transforms @transforms ||= [] end