Class: RSpec::Conductor::SuiteRun

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/conductor/suite_run.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSuiteRun

Returns a new instance of SuiteRun.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rspec/conductor/suite_run.rb', line 8

def initialize
  @examples_passed = 0
  @examples_failed = 0
  @examples_pending = 0
  @worker_crashes = 0
  @errors = []
  @started_at = Time.now
  @specs_started_at = nil
  @specs_completed_at = nil
  @spec_files_total = 0
  @spec_files_processed = 0
  @example_stats = []
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/rspec/conductor/suite_run.rb', line 6

def errors
  @errors
end

#example_statsObject

Returns the value of attribute example_stats.



6
7
8
# File 'lib/rspec/conductor/suite_run.rb', line 6

def example_stats
  @example_stats
end

#examples_failedObject

Returns the value of attribute examples_failed.



6
7
8
# File 'lib/rspec/conductor/suite_run.rb', line 6

def examples_failed
  @examples_failed
end

#examples_passedObject

Returns the value of attribute examples_passed.



6
7
8
# File 'lib/rspec/conductor/suite_run.rb', line 6

def examples_passed
  @examples_passed
end

#examples_pendingObject

Returns the value of attribute examples_pending.



6
7
8
# File 'lib/rspec/conductor/suite_run.rb', line 6

def examples_pending
  @examples_pending
end

#spec_files_processedObject

Returns the value of attribute spec_files_processed.



6
7
8
# File 'lib/rspec/conductor/suite_run.rb', line 6

def spec_files_processed
  @spec_files_processed
end

#spec_files_totalObject

Returns the value of attribute spec_files_total.



6
7
8
# File 'lib/rspec/conductor/suite_run.rb', line 6

def spec_files_total
  @spec_files_total
end

#started_atObject

Returns the value of attribute started_at.



6
7
8
# File 'lib/rspec/conductor/suite_run.rb', line 6

def started_at
  @started_at
end

#worker_crashesObject

Returns the value of attribute worker_crashes.



6
7
8
# File 'lib/rspec/conductor/suite_run.rb', line 6

def worker_crashes
  @worker_crashes
end

Instance Method Details

#example_failed(message) ⇒ Object



31
32
33
34
35
# File 'lib/rspec/conductor/suite_run.rb', line 31

def example_failed(message)
  @example_stats << message.slice(:location, :run_time, :description)
  @examples_failed += 1
  @errors << message
end

#example_passed(message) ⇒ Object



26
27
28
29
# File 'lib/rspec/conductor/suite_run.rb', line 26

def example_passed(message)
  @example_stats << message.slice(:location, :run_time, :description)
  @examples_passed += 1
end

#example_pendingObject



37
38
39
# File 'lib/rspec/conductor/suite_run.rb', line 37

def example_pending
  @examples_pending += 1
end

#spec_file_assignedObject



41
42
43
# File 'lib/rspec/conductor/suite_run.rb', line 41

def spec_file_assigned
  @specs_started_at ||= Time.now
end

#spec_file_completeObject



45
46
47
# File 'lib/rspec/conductor/suite_run.rb', line 45

def spec_file_complete
  @spec_files_processed += 1
end

#spec_file_error(message) ⇒ Object



49
50
51
# File 'lib/rspec/conductor/suite_run.rb', line 49

def spec_file_error(message)
  @errors << message
end

#spec_file_processed_percentageObject



53
54
55
56
57
# File 'lib/rspec/conductor/suite_run.rb', line 53

def spec_file_processed_percentage
  return 0.0 if @spec_files_total.zero?

  @spec_files_processed.to_f / @spec_files_total
end

#specs_runtimeObject



67
68
69
# File 'lib/rspec/conductor/suite_run.rb', line 67

def specs_runtime
  ((@specs_completed_at || Time.now) - (@specs_started_at || @started_at)).to_f
end

#success?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rspec/conductor/suite_run.rb', line 22

def success?
  @examples_failed.zero? && @errors.empty? && @worker_crashes.zero? && @spec_files_total == @spec_files_processed
end

#suite_completeObject



63
64
65
# File 'lib/rspec/conductor/suite_run.rb', line 63

def suite_complete
  @specs_completed_at ||= Time.now
end

#total_runtimeObject



71
72
73
# File 'lib/rspec/conductor/suite_run.rb', line 71

def total_runtime
  ((@specs_completed_at || Time.now) - @started_at).to_f
end

#worker_crashedObject



59
60
61
# File 'lib/rspec/conductor/suite_run.rb', line 59

def worker_crashed
  @worker_crashes += 1
end