class Cucumber::Runtime

This is the meaty part of Cucumber that ties everything together.

Attributes

results[R]

Public Class Methods

new(configuration = Configuration.default) click to toggle source
# File lib/cucumber/runtime.rb, line 23
def initialize(configuration = Configuration.default)
  @current_scenario = nil
  @configuration = Configuration.parse(configuration)
  @support_code = SupportCode.new(self, @configuration)
  @results = Results.new(@configuration)
end

Public Instance Methods

configure(new_configuration) click to toggle source

Allows you to take an existing runtime and change it's configuration

# File lib/cucumber/runtime.rb, line 31
def configure(new_configuration)
  @configuration = Configuration.parse(new_configuration)
  @support_code.configure(@configuration)
  @results.configure(@configuration)
end
doc_string(string_without_triple_quotes, content_type='', line_offset=0) click to toggle source

Returns Ast::DocString for string_without_triple_quotes.

# File lib/cucumber/runtime.rb, line 164
def doc_string(string_without_triple_quotes, content_type='', line_offset=0)
  Ast::DocString.new(string_without_triple_quotes,content_type)
end
features_paths() click to toggle source
# File lib/cucumber/runtime.rb, line 52
def features_paths
  @configuration.paths
end
load_programming_language(language) click to toggle source
# File lib/cucumber/runtime.rb, line 37
def load_programming_language(language)
  @support_code.load_programming_language(language)
end
run!() click to toggle source
# File lib/cucumber/runtime.rb, line 41
def run!
  load_step_definitions
  disable_minitest_test_unit_autorun
  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
scenarios(status = nil) click to toggle source
# File lib/cucumber/runtime.rb, line 60
def scenarios(status = nil)
  @results.scenarios(status)
end
steps(status = nil) click to toggle source
# File lib/cucumber/runtime.rb, line 64
def steps(status = nil)
  @results.steps(status)
end
unknown_programming_language?() click to toggle source
# File lib/cucumber/runtime.rb, line 121
def unknown_programming_language?
  @support_code.unknown_programming_language?
end
unmatched_step_definitions() click to toggle source
# File lib/cucumber/runtime.rb, line 72
def unmatched_step_definitions
  @support_code.unmatched_step_definitions
end
with_hooks(scenario, skip_hooks=false) { |scenario| ... } click to toggle source
# File lib/cucumber/runtime.rb, line 80
def with_hooks(scenario, skip_hooks=false)
  around(scenario, skip_hooks) do
    before_and_after(scenario, skip_hooks) do
      yield scenario
    end
  end
end
write_stepdefs_json() click to toggle source
# File lib/cucumber/runtime.rb, line 125
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(MultiJson.dump(stepdefs, :pretty => true))
    end
  end
end

Private Instance Methods

disable_minitest_test_unit_autorun() click to toggle source
# File lib/cucumber/runtime.rb, line 187
def disable_minitest_test_unit_autorun
  MultiTest.disable_autorun
end
features() click to toggle source
# File lib/cucumber/runtime.rb, line 174
def features
  @loader ||= Runtime::FeaturesLoader.new(
    @configuration.feature_files,
    @configuration.filters,
    @configuration.tag_expression)
  @loader.features
end
fire_after_configuration_hook() click to toggle source
# File lib/cucumber/runtime.rb, line 170
def fire_after_configuration_hook #:nodoc
  @support_code.fire_hook(:after_configuration, @configuration)
end
load_step_definitions() click to toggle source
# File lib/cucumber/runtime.rb, line 182
def load_step_definitions
  files = @configuration.support_to_load + @configuration.step_defs_to_load
  @support_code.load_files!(files)
end
log() click to toggle source
# File lib/cucumber/runtime.rb, line 191
def log
  Cucumber.logger
end