class RspecN::Runner
Attributes
command[R]
input[R]
iterations[R]
runs[R]
Public Class Methods
new(options, args)
click to toggle source
# File lib/rspec_n/runner.rb, line 5 def initialize(options, args) @input = Input.new(options, args) @iterations = @input.iterations @command = @input.command @display_formatter = Formatters::TableFormatter.new(runner: self) @file_formatter = Formatters::FileFormatter.new(runner: self) initialize_runs end
Public Instance Methods
avg_duration_seconds()
click to toggle source
# File lib/rspec_n/runner.rb, line 23 def avg_duration_seconds (total_duration_seconds / @iterations).floor end
start()
click to toggle source
# File lib/rspec_n/runner.rb, line 14 def start display_intro @display_formatter.observe { run_tests } end
total_duration_seconds()
click to toggle source
# File lib/rspec_n/runner.rb, line 19 def total_duration_seconds @runs.values.inject(0) { |sum, run| sum + run.duration_seconds } end
total_failed()
click to toggle source
# File lib/rspec_n/runner.rb, line 31 def total_failed @runs.values.count(&:failed?) end
total_passed()
click to toggle source
# File lib/rspec_n/runner.rb, line 27 def total_passed @runs.values.count(&:passed?) end
total_skipped()
click to toggle source
# File lib/rspec_n/runner.rb, line 35 def total_skipped @runs.values.count(&:skipped?) end
Private Instance Methods
display_intro()
click to toggle source
# File lib/rspec_n/runner.rb, line 62 def display_intro iteration_part = @iterations > 1 ? "#{@iterations} times" : "1 time" puts "\nRSpec will execute #{iteration_part.colorize(:yellow)} using #{command.to_s.colorize(:yellow)}\n\n" end
initialize_runs()
click to toggle source
# File lib/rspec_n/runner.rb, line 41 def initialize_runs @runs = {} @iterations.times { |i| @runs[i + 1] = Run.new(iteration: i + 1) } end
run_tests()
click to toggle source
# File lib/rspec_n/runner.rb, line 46 def run_tests found_failure = false @runs.each do |_iteration, run| next run.skip if @input.stop_fast && found_failure run.start_clock @display_formatter.show_pre_run_info(run) run.go(@command) run.stop_clock @display_formatter.show_post_run_info(run) found_failure ||= run.failed? @file_formatter.write(run, @command) end end