Module: Cucumber::LanguageSupport::LanguageMethods
- Included in:
- JsSupport::JsLanguage, PySupport::PyLanguage, RbSupport::RbLanguage, WireSupport::WireLanguage
- Defined in:
- lib/cucumber/language_support/language_methods.rb
Instance Method Summary collapse
- #add_hook(phase, hook) ⇒ Object
- #add_transform(transform) ⇒ Object
- #after(scenario) ⇒ Object
- #after_configuration(configuration) ⇒ Object
- #around(scenario) ⇒ Object
- #available_step_definition(regexp_source, file_colon_line) ⇒ Object
- #before(scenario) ⇒ Object
- #clear_hooks ⇒ Object
- #execute_after_step(scenario) ⇒ Object
- #execute_transforms(args) ⇒ Object
-
#hooks_for(phase, scenario) ⇒ Object
:nodoc:.
- #invoked_step_definition(regexp_source, file_colon_line) ⇒ Object
- #unmatched_step_definitions ⇒ Object
Instance Method Details
#add_hook(phase, hook) ⇒ Object
42 43 44 45 |
# 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) ⇒ Object
51 52 53 54 |
# File 'lib/cucumber/language_support/language_methods.rb', line 51 def add_transform(transform) transforms.unshift transform transform end |
#after(scenario) ⇒ Object
18 19 20 21 |
# File 'lib/cucumber/language_support/language_methods.rb', line 18 def after(scenario) execute_after(scenario) end_scenario end |
#after_configuration(configuration) ⇒ Object
23 24 25 26 27 |
# 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) ⇒ Object
7 8 9 10 11 |
# 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) ⇒ Object
64 65 66 |
# 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) ⇒ Object
13 14 15 16 |
# File 'lib/cucumber/language_support/language_methods.rb', line 13 def before(scenario) begin_scenario(scenario) execute_before(scenario) end |
#clear_hooks ⇒ Object
47 48 49 |
# File 'lib/cucumber/language_support/language_methods.rb', line 47 def clear_hooks @hooks = nil end |
#execute_after_step(scenario) ⇒ Object
29 30 31 32 33 |
# 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) ⇒ Object
35 36 37 38 39 40 |
# 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 |
#hooks_for(phase, scenario) ⇒ Object
:nodoc:
56 57 58 |
# File 'lib/cucumber/language_support/language_methods.rb', line 56 def hooks_for(phase, scenario) #:nodoc: hooks[phase.to_sym].select{|hook| scenario.accept_hook?(hook)} end |
#invoked_step_definition(regexp_source, file_colon_line) ⇒ Object
68 69 70 |
# 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 ⇒ Object
60 61 62 |
# 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 |