Class: Cucumber::Runtime
- Includes:
- Formatter::Duration, UserInterface
- Defined in:
- lib/cucumber/runtime.rb,
lib/cucumber/runtime/results.rb,
lib/cucumber/runtime/support_code.rb,
lib/cucumber/runtime/user_interface.rb,
lib/cucumber/runtime/features_loader.rb,
lib/cucumber/runtime/for_programming_languages.rb
Overview
This is the meaty part of Cucumber that ties everything together.
Direct Known Subclasses
Defined Under Namespace
Modules: UserInterface Classes: FeaturesLoader, ForProgrammingLanguages, Results, SupportCode
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Attributes included from UserInterface
Instance Method Summary collapse
-
#after(scenario) ⇒ Object
:nodoc:.
-
#after_step ⇒ Object
:nodoc:.
-
#around(scenario, skip_hooks = false, &block) ⇒ Object
:nodoc:.
-
#before(scenario) ⇒ Object
:nodoc:.
-
#before_and_after(scenario, skip_hooks = false) {|scenario| ... } ⇒ Object
:nodoc:.
-
#configure(new_configuration) ⇒ Object
Allows you to take an existing runtime and change it’s configuration.
- #features_paths ⇒ Object
-
#initialize(configuration = Configuration.default) ⇒ Runtime
constructor
A new instance of Runtime.
- #load_programming_language(language) ⇒ Object
- #run! ⇒ Object
- #scenarios(status = nil) ⇒ Object
-
#snippet_text(step_keyword, step_name, multiline_arg_class) ⇒ Object
:nodoc:.
-
#step_match(step_name, name_to_report = nil) ⇒ Object
:nodoc:.
-
#step_visited(step) ⇒ Object
:nodoc:.
- #steps(status = nil) ⇒ Object
- #unknown_programming_language? ⇒ Boolean
- #unmatched_step_definitions ⇒ Object
- #with_hooks(scenario, skip_hooks = false) ⇒ Object
Methods included from UserInterface
Methods included from Formatter::Duration
Constructor Details
#initialize(configuration = Configuration.default) ⇒ Runtime
Returns a new instance of Runtime.
19 20 21 22 23 24 25 |
# File 'lib/cucumber/runtime.rb', line 19 def initialize(configuration = Configuration.default) require 'cucumber/core_ext/disable_mini_unit_autorun' @current_scenario = nil @configuration = Configuration.parse(configuration) @support_code = SupportCode.new(self, @configuration) @results = Results.new(@configuration) end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
14 15 16 |
# File 'lib/cucumber/runtime.rb', line 14 def results @results end |
Instance Method Details
#after(scenario) ⇒ Object
:nodoc:
106 107 108 109 110 |
# File 'lib/cucumber/runtime.rb', line 106 def after(scenario) #:nodoc: @current_scenario = nil return if @configuration.dry_run? @support_code.fire_hook(:after, scenario) end |
#after_step ⇒ Object
:nodoc:
112 113 114 115 |
# File 'lib/cucumber/runtime.rb', line 112 def after_step #:nodoc: return if @configuration.dry_run? @support_code.fire_hook(:execute_after_step, @current_scenario) end |
#around(scenario, skip_hooks = false, &block) ⇒ Object
:nodoc:
84 85 86 87 88 89 90 91 |
# File 'lib/cucumber/runtime.rb', line 84 def around(scenario, skip_hooks=false, &block) #:nodoc: if skip_hooks yield return end @support_code.around(scenario, block) end |
#before(scenario) ⇒ Object
:nodoc:
100 101 102 103 104 |
# File 'lib/cucumber/runtime.rb', line 100 def before(scenario) #:nodoc: return if @configuration.dry_run? || @current_scenario @current_scenario = scenario @support_code.fire_hook(:before, scenario) end |
#before_and_after(scenario, skip_hooks = false) {|scenario| ... } ⇒ Object
:nodoc:
93 94 95 96 97 98 |
# File 'lib/cucumber/runtime.rb', line 93 def before_and_after(scenario, skip_hooks=false) #:nodoc: before(scenario) unless skip_hooks yield scenario after(scenario) unless skip_hooks @results.scenario_visited(scenario) end |
#configure(new_configuration) ⇒ Object
Allows you to take an existing runtime and change it’s configuration
28 29 30 31 32 |
# File 'lib/cucumber/runtime.rb', line 28 def configure(new_configuration) @configuration = Configuration.parse(new_configuration) @support_code.configure(@configuration) @results.configure(@configuration) end |
#features_paths ⇒ Object
48 49 50 |
# File 'lib/cucumber/runtime.rb', line 48 def features_paths @configuration.paths end |
#load_programming_language(language) ⇒ Object
34 35 36 |
# File 'lib/cucumber/runtime.rb', line 34 def load_programming_language(language) @support_code.load_programming_language(language) end |
#run! ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/cucumber/runtime.rb', line 38 def run! load_step_definitions fire_after_configuration_hook tree_walker = @configuration.build_tree_walker(self) self.visitor = tree_walker # Ugly circular dependency, but needed to support World#announce tree_walker.visit_features(features) end |
#scenarios(status = nil) ⇒ Object
56 57 58 |
# File 'lib/cucumber/runtime.rb', line 56 def scenarios(status = nil) @results.scenarios(status) end |
#snippet_text(step_keyword, step_name, multiline_arg_class) ⇒ Object
:nodoc:
72 73 74 |
# File 'lib/cucumber/runtime.rb', line 72 def snippet_text(step_keyword, step_name, multiline_arg_class) #:nodoc: @support_code.snippet_text(Gherkin::I18n.code_keyword_for(step_keyword), step_name, multiline_arg_class) end |
#step_match(step_name, name_to_report = nil) ⇒ Object
:nodoc:
64 65 66 |
# File 'lib/cucumber/runtime.rb', line 64 def step_match(step_name, name_to_report=nil) #:nodoc: @support_code.step_match(step_name, name_to_report) end |
#step_visited(step) ⇒ Object
:nodoc:
52 53 54 |
# File 'lib/cucumber/runtime.rb', line 52 def step_visited(step) #:nodoc: @results.step_visited(step) end |
#steps(status = nil) ⇒ Object
60 61 62 |
# File 'lib/cucumber/runtime.rb', line 60 def steps(status = nil) @results.steps(status) end |
#unknown_programming_language? ⇒ Boolean
117 118 119 |
# File 'lib/cucumber/runtime.rb', line 117 def unknown_programming_language? @support_code.unknown_programming_language? end |
#unmatched_step_definitions ⇒ Object
68 69 70 |
# File 'lib/cucumber/runtime.rb', line 68 def unmatched_step_definitions @support_code.unmatched_step_definitions end |
#with_hooks(scenario, skip_hooks = false) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/cucumber/runtime.rb', line 76 def with_hooks(scenario, skip_hooks=false) around(scenario, skip_hooks) do before_and_after(scenario, skip_hooks) do yield scenario end end end |