This is the meaty part of Cucumber that ties everything together.
# 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
Allows you to take an existing runtime and change it's configuration
# File lib/cucumber/runtime.rb, line 29 def configure(new_configuration) @configuration = Configuration.parse(new_configuration) @support_code.configure(@configuration) @results.configure(@configuration) end
# File lib/cucumber/runtime.rb, line 49 def features_paths @configuration.paths end
# File lib/cucumber/runtime.rb, line 35 def load_programming_language(language) @support_code.load_programming_language(language) end
# 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
# File lib/cucumber/runtime.rb, line 57 def scenarios(status = nil) @results.scenarios(status) end
# File lib/cucumber/runtime.rb, line 61 def steps(status = nil) @results.steps(status) end
# File lib/cucumber/runtime.rb, line 118 def unknown_programming_language? @support_code.unknown_programming_language? end
# File lib/cucumber/runtime.rb, line 69 def unmatched_step_definitions @support_code.unmatched_step_definitions end
# 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
# 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
Generated with the Darkfish Rdoc Generator 2.