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
Overview
This is the meaty part of Cucumber that ties everything together.
Direct Known Subclasses
Defined Under Namespace
Modules: UserInterface Classes: FeaturesLoader, 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:.
- #features_paths ⇒ Object
-
#initialize(configuration = Configuration.default) ⇒ Runtime
constructor
A new instance of Runtime.
- #invoke(step_name, multiline_argument = nil) ⇒ Object
-
#invoke_steps(steps_text, i18n, file_colon_line) ⇒ Object
Invokes a series of steps
steps_text
. -
#load_programming_language(ext) ⇒ Object
Loads and registers programming language implementation.
-
#py_string(string_with_triple_quotes, file = nil, line_offset = 0) ⇒ Object
Returns a regular String for
string_with_triple_quotes
. - #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
-
#table(text_or_table, file = nil, line_offset = 0) ⇒ Object
Returns a Cucumber::Ast::Table for
text_or_table
, which can either be a String:. - #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.
18 19 20 21 22 23 |
# File 'lib/cucumber/runtime.rb', line 18 def initialize(configuration = Configuration.default) @current_scenario = nil @configuration = Configuration.parse(configuration) @support_code = SupportCode.new(self, @configuration.guess?) @results = Results.new(@configuration) end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
13 14 15 |
# File 'lib/cucumber/runtime.rb', line 13 def results @results end |
Instance Method Details
#after(scenario) ⇒ Object
:nodoc:
154 155 156 157 158 |
# File 'lib/cucumber/runtime.rb', line 154 def after(scenario) #:nodoc: @current_scenario = nil return if @configuration.dry_run? @support_code.fire_hook(:after, scenario) end |
#after_step ⇒ Object
:nodoc:
160 161 162 163 |
# File 'lib/cucumber/runtime.rb', line 160 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:
132 133 134 135 136 137 138 139 |
# File 'lib/cucumber/runtime.rb', line 132 def around(scenario, skip_hooks=false, &block) #:nodoc: if skip_hooks yield return end @support_code.around(scenario, block) end |
#before(scenario) ⇒ Object
:nodoc:
148 149 150 151 152 |
# File 'lib/cucumber/runtime.rb', line 148 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:
141 142 143 144 145 146 |
# File 'lib/cucumber/runtime.rb', line 141 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 |
#features_paths ⇒ Object
35 36 37 |
# File 'lib/cucumber/runtime.rb', line 35 def features_paths @configuration.paths end |
#invoke(step_name, multiline_argument = nil) ⇒ Object
59 60 61 62 |
# File 'lib/cucumber/runtime.rb', line 59 def invoke(step_name, multiline_argument=nil) # It is very important to leave multiline_argument=nil as a vararg. Cuke4Duke needs it that way. @support_code.invoke(step_name, multiline_argument) end |
#invoke_steps(steps_text, i18n, file_colon_line) ⇒ 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
})
70 71 72 |
# File 'lib/cucumber/runtime.rb', line 70 def invoke_steps(steps_text, i18n, file_colon_line) @support_code.invoke_steps(steps_text, i18n, file_colon_line) end |
#load_programming_language(ext) ⇒ Object
Loads and registers programming language implementation. Instances are cached, so calling with the same argument twice will return the same instance.
55 56 57 |
# File 'lib/cucumber/runtime.rb', line 55 def load_programming_language(ext) @support_code.load_programming_language!(ext) end |
#py_string(string_with_triple_quotes, file = nil, line_offset = 0) ⇒ Object
Returns a regular String for string_with_triple_quotes
. Example:
"""
hello
world
"""
Is retured as: “ hellonworld”
108 109 110 |
# File 'lib/cucumber/runtime.rb', line 108 def py_string(string_with_triple_quotes, file=nil, line_offset=0) Ast::PyString.parse(string_with_triple_quotes) end |
#run! ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/cucumber/runtime.rb', line 25 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
43 44 45 |
# File 'lib/cucumber/runtime.rb', line 43 def scenarios(status = nil) @results.scenarios(status) end |
#snippet_text(step_keyword, step_name, multiline_arg_class) ⇒ Object
:nodoc:
120 121 122 |
# File 'lib/cucumber/runtime.rb', line 120 def snippet_text(step_keyword, step_name, multiline_arg_class) #:nodoc: @support_code.snippet_text(step_keyword, step_name, multiline_arg_class) end |
#step_match(step_name, name_to_report = nil) ⇒ Object
:nodoc:
112 113 114 |
# File 'lib/cucumber/runtime.rb', line 112 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:
39 40 41 |
# File 'lib/cucumber/runtime.rb', line 39 def step_visited(step) #:nodoc: @results.step_visited(step) end |
#steps(status = nil) ⇒ Object
47 48 49 |
# File 'lib/cucumber/runtime.rb', line 47 def steps(status = nil) @results.steps(status) end |
#table(text_or_table, file = nil, line_offset = 0) ⇒ Object
Returns a Cucumber::Ast::Table for text_or_table
, which can either be a String:
table(%{
| account | description | amount |
| INT-100 | Taxi | 114 |
| CUC-101 | Peeler | 22 |
})
or a 2D Array:
table([
%w{ account description amount },
%w{ INT-100 Taxi 114 },
%w{ CUC-101 Peeler 22 }
])
91 92 93 94 95 96 97 |
# File 'lib/cucumber/runtime.rb', line 91 def table(text_or_table, file=nil, line_offset=0) if Array === text_or_table Ast::Table.new(text_or_table) else Ast::Table.parse(text_or_table, file, line_offset) end end |
#unknown_programming_language? ⇒ Boolean
165 166 167 |
# File 'lib/cucumber/runtime.rb', line 165 def unknown_programming_language? @support_code.unknown_programming_language? end |
#unmatched_step_definitions ⇒ Object
116 117 118 |
# File 'lib/cucumber/runtime.rb', line 116 def unmatched_step_definitions @support_code.unmatched_step_definitions end |
#with_hooks(scenario, skip_hooks = false) ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/cucumber/runtime.rb', line 124 def with_hooks(scenario, skip_hooks=false) around(scenario, skip_hooks) do before_and_after(scenario, skip_hooks) do yield scenario end end end |