Class: Cucumber::Runtime
- Inherits:
-
Object
- Object
- 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)
-
- (Object) results
readonly
Returns the value of attribute results.
Attributes included from UserInterface
Instance Method Summary (collapse)
-
- (Object) after(scenario)
:nodoc:.
-
- (Object) after_step
:nodoc:.
-
- (Object) around(scenario, skip_hooks = false, &block)
:nodoc:.
-
- (Object) before(scenario)
:nodoc:.
-
- (Object) before_and_after(scenario, skip_hooks = false) {|scenario| ... }
:nodoc:.
-
- (Object) configure(new_configuration)
Allows you to take an existing runtime and change it's configuration.
- - (Object) features_paths
-
- (Runtime) initialize(configuration = Configuration.default)
constructor
A new instance of Runtime.
- - (Object) load_programming_language(language)
- - (Object) run!
- - (Object) scenarios(status = nil)
-
- (Object) snippet_text(step_keyword, step_name, multiline_arg_class)
:nodoc:.
-
- (Object) step_match(step_name, name_to_report = nil)
:nodoc:.
-
- (Object) step_visited(step)
:nodoc:.
- - (Object) steps(status = nil)
- - (Boolean) unknown_programming_language?
- - (Object) unmatched_step_definitions
- - (Object) with_hooks(scenario, skip_hooks = false)
- - (Object) write_stepdefs_json
Methods included from UserInterface
Methods included from Formatter::Duration
Constructor Details
- (Runtime) initialize(configuration = Configuration.default)
A new instance of Runtime
20 21 22 23 24 25 26 |
# File 'lib/cucumber/runtime.rb', line 20 def initialize(configuration = Configuration.default) require 'cucumber/core_ext/disable_mini_and_test_unit_autorun' @current_scenario = nil @configuration = Configuration.parse(configuration) @support_code = SupportCode.new(self, @configuration) @results = Results.new(@configuration) end |
Instance Attribute Details
- (Object) results (readonly)
Returns the value of attribute results
15 16 17 |
# File 'lib/cucumber/runtime.rb', line 15 def results @results end |
Instance Method Details
- (Object) after(scenario)
:nodoc:
107 108 109 110 111 |
# File 'lib/cucumber/runtime.rb', line 107 def after(scenario) #:nodoc: @current_scenario = nil return if @configuration.dry_run? @support_code.fire_hook(:after, scenario) end |
- (Object) after_step
:nodoc:
113 114 115 116 |
# File 'lib/cucumber/runtime.rb', line 113 def after_step #:nodoc: return if @configuration.dry_run? @support_code.fire_hook(:execute_after_step, @current_scenario) end |
- (Object) around(scenario, skip_hooks = false, &block)
:nodoc:
85 86 87 88 89 90 91 92 |
# File 'lib/cucumber/runtime.rb', line 85 def around(scenario, skip_hooks=false, &block) #:nodoc: if skip_hooks yield return end @support_code.around(scenario, block) end |
- (Object) before(scenario)
:nodoc:
101 102 103 104 105 |
# File 'lib/cucumber/runtime.rb', line 101 def before(scenario) #:nodoc: return if @configuration.dry_run? || @current_scenario @current_scenario = scenario @support_code.fire_hook(:before, scenario) end |
- (Object) before_and_after(scenario, skip_hooks = false) {|scenario| ... }
:nodoc:
94 95 96 97 98 99 |
# File 'lib/cucumber/runtime.rb', line 94 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 |
- (Object) configure(new_configuration)
Allows you to take an existing runtime and change it's configuration
29 30 31 32 33 |
# File 'lib/cucumber/runtime.rb', line 29 def configure(new_configuration) @configuration = Configuration.parse(new_configuration) @support_code.configure(@configuration) @results.configure(@configuration) end |
- (Object) features_paths
49 50 51 |
# File 'lib/cucumber/runtime.rb', line 49 def features_paths @configuration.paths end |
- (Object) load_programming_language(language)
35 36 37 |
# File 'lib/cucumber/runtime.rb', line 35 def load_programming_language(language) @support_code.load_programming_language(language) end |
- (Object) run!
39 40 41 42 43 44 45 46 47 |
# File 'lib/cucumber/runtime.rb', line 39 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#puts tree_walker.visit_features(features) end |
- (Object) scenarios(status = nil)
57 58 59 |
# File 'lib/cucumber/runtime.rb', line 57 def scenarios(status = nil) @results.scenarios(status) end |
- (Object) snippet_text(step_keyword, step_name, multiline_arg_class)
:nodoc:
73 74 75 |
# File 'lib/cucumber/runtime.rb', line 73 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 |
- (Object) step_match(step_name, name_to_report = nil)
:nodoc:
65 66 67 |
# File 'lib/cucumber/runtime.rb', line 65 def step_match(step_name, name_to_report=nil) #:nodoc: @support_code.step_match(step_name, name_to_report) end |
- (Object) step_visited(step)
:nodoc:
53 54 55 |
# File 'lib/cucumber/runtime.rb', line 53 def step_visited(step) #:nodoc: @results.step_visited(step) end |
- (Object) steps(status = nil)
61 62 63 |
# File 'lib/cucumber/runtime.rb', line 61 def steps(status = nil) @results.steps(status) end |
- (Boolean) unknown_programming_language?
118 119 120 |
# File 'lib/cucumber/runtime.rb', line 118 def unknown_programming_language? @support_code.unknown_programming_language? end |
- (Object) unmatched_step_definitions
69 70 71 |
# File 'lib/cucumber/runtime.rb', line 69 def unmatched_step_definitions @support_code.unmatched_step_definitions end |
- (Object) with_hooks(scenario, skip_hooks = false)
77 78 79 80 81 82 83 |
# File 'lib/cucumber/runtime.rb', line 77 def with_hooks(scenario, skip_hooks=false) around(scenario, skip_hooks) do before_and_after(scenario, skip_hooks) do yield scenario end end end |
- (Object) write_stepdefs_json
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/cucumber/runtime.rb', line 122 def write_stepdefs_json if(@configuration.dotcucumber) stepdefs = [] @support_code.step_definitions.sort{|a,b| a.to_hash['source'] <=> a.to_hash['source']}.each do |stepdef| stepdef_hash = stepdef.to_hash steps = [] features.each do |feature| feature.feature_elements.each do |feature_element| feature_element.raw_steps.each do |step| args = stepdef.arguments_from(step.name) if(args) steps << { 'name' => step.name, 'args' => args.map do |arg| { 'offset' => arg.offset, 'val' => arg.val } end } end end end end stepdef_hash['file_colon_line'] = stepdef.file_colon_line stepdef_hash['steps'] = steps.uniq.sort {|a,b| a['name'] <=> b['name']} stepdefs << stepdef_hash end if !File.directory?(@configuration.dotcucumber) FileUtils.mkdir_p(@configuration.dotcucumber) end File.open(File.join(@configuration.dotcucumber, 'stepdefs.json'), 'w') do |io| io.write(JSON.pretty_generate(stepdefs)) end end end |