Class: RspecN::Runner

Inherits:
Cri::CommandRunner
  • Object
show all
Defined in:
lib/rspec_n/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, args) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
9
10
11
12
# 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

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



3
4
5
# File 'lib/rspec_n/runner.rb', line 3

def command
  @command
end

#inputObject (readonly)

Returns the value of attribute input.



3
4
5
# File 'lib/rspec_n/runner.rb', line 3

def input
  @input
end

#iterationsObject (readonly)

Returns the value of attribute iterations.



3
4
5
# File 'lib/rspec_n/runner.rb', line 3

def iterations
  @iterations
end

#runsObject (readonly)

Returns the value of attribute runs.



3
4
5
# File 'lib/rspec_n/runner.rb', line 3

def runs
  @runs
end

Instance Method Details

#avg_duration_secondsObject



23
24
25
# File 'lib/rspec_n/runner.rb', line 23

def avg_duration_seconds
  (total_duration_seconds / @iterations).floor
end

#startObject



14
15
16
17
# File 'lib/rspec_n/runner.rb', line 14

def start
  display_intro
  @display_formatter.observe { run_tests }
end

#total_duration_secondsObject



19
20
21
# File 'lib/rspec_n/runner.rb', line 19

def total_duration_seconds
  @runs.values.inject(0) { |sum, run| sum + run.duration_seconds }
end

#total_failedObject



31
32
33
# File 'lib/rspec_n/runner.rb', line 31

def total_failed
  @runs.values.count(&:failed?)
end

#total_passedObject



27
28
29
# File 'lib/rspec_n/runner.rb', line 27

def total_passed
  @runs.values.count(&:passed?)
end

#total_skippedObject



35
36
37
# File 'lib/rspec_n/runner.rb', line 35

def total_skipped
  @runs.values.count(&:skipped?)
end