class Nitra::Workers::Cucumber
Public Class Methods
filename_match?(filename)
click to toggle source
# File lib/nitra/workers/cucumber.rb, line 7 def self.filename_match?(filename) filename =~ /\.feature/ end
files()
click to toggle source
# File lib/nitra/workers/cucumber.rb, line 3 def self.files Dir["features/**/*.feature"].sort_by {|f| File.size(f)}.reverse end
new(runner_id, worker_number, configuration)
click to toggle source
Calls superclass method
Nitra::Workers::Worker::new
# File lib/nitra/workers/cucumber.rb, line 11 def initialize(runner_id, worker_number, configuration) super(runner_id, worker_number, configuration) end
Public Instance Methods
clean_up()
click to toggle source
# File lib/nitra/workers/cucumber.rb, line 58 def clean_up @cuke_runtime.reset end
load_environment()
click to toggle source
# File lib/nitra/workers/cucumber.rb, line 15 def load_environment require 'cucumber' require 'nitra/ext/cucumber' end
minimal_file()
click to toggle source
# File lib/nitra/workers/cucumber.rb, line 20 def minimal_file <<-EOS Feature: cucumber preloading Scenario: a fake scenario Given every step is unimplemented When we run this file Then Cucumber will load it's environment EOS end
run_file(filename, preloading = false)
click to toggle source
Run a Cucumber
file and write the results back to the runner.
Doesn’t write back to the runner if we mark the run as preloading.
# File lib/nitra/workers/cucumber.rb, line 35 def run_file(filename, preloading = false) @cuke_runtime ||= ::Cucumber::ResetableRuntime.new # This runtime gets reused, this is important as it's the part that loads the steps... begin result = 1 cuke_config = ::Cucumber::Cli::Configuration.new(io, io) cuke_config.parse!(["--no-color", "--require", "features", filename]) @cuke_runtime.configure(cuke_config) @cuke_runtime.run! result = 0 unless @cuke_runtime.results.failure? rescue LoadError => e io << "\nCould not load file #{filename}: #{e.message}\n\n" rescue Exception => e io << "Exception when running #{filename}: #{e.message}" io << e.backtrace[0..7].join("\n") end if preloading puts(io.string) else channel.write("command" => "result", "filename" => filename, "return_code" => result.to_i, "text" => io.string, "worker_number" => worker_number) end end