Class: Spec::Runner::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/rasta/extensions/rspec_extensions.rb

Constant Summary collapse

@@started_formatters =
false

Instance Method Summary collapse

Instance Method Details

#dumpObject



44
# File 'lib/rasta/extensions/rspec_extensions.rb', line 44

def dump; end

#example_finished(*args) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rasta/extensions/rspec_extensions.rb', line 65

def example_finished(*args)
  error = args[1]
  if error
    if ::Spec::Matchers.rasta_error
      error.set_backtrace(::Spec::Matchers.rasta_error.backtrace) 
    else
      error.set_backtrace(nil) 
    end
  end
  old_example_finished(*args)
end

#failure_countObject

Expose the failure count to Rasta



60
61
62
# File 'lib/rasta/extensions/rspec_extensions.rb', line 60

def failure_count
  @failures.length
end

#initialize_spreadsheetObject

Initialize the start time and set up the superclass’ dump method to run after we’re all done



29
30
31
32
# File 'lib/rasta/extensions/rspec_extensions.rb', line 29

def initialize_spreadsheet
  @start_time = Time.new
  #at_exit {original_dump}
end

#old_example_finishedObject



64
# File 'lib/rasta/extensions/rspec_extensions.rb', line 64

alias :old_example_finished :example_finished

#original_dumpObject

Stub out the dump method and call it after all tests are run



43
# File 'lib/rasta/extensions/rspec_extensions.rb', line 43

alias  :original_dump :dump

#original_startObject

Change so we don’t clear the state after each run and don’t reset the start time



48
# File 'lib/rasta/extensions/rspec_extensions.rb', line 48

alias  :original_start :start

#set_current_spreadsheet_cell=(cell_reference) ⇒ Object

Call the formatter’s method and pass in the reference to the spreadsheet cell so it can use it for updating the cell contents based on the test result



37
38
39
# File 'lib/rasta/extensions/rspec_extensions.rb', line 37

def set_current_spreadsheet_cell=(cell_reference)
  formatters.each { |f| f.cell=(cell_reference) if f.methods.include?('cell=') }
end

#start(number_of_examples) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/rasta/extensions/rspec_extensions.rb', line 49

def start(number_of_examples)
  
  #clear                   [REMOVED so we keep state across tests]
  #@start_time = Time.new  [MOVED to initialize_spreadsheet]
  if !@@started_formatters
    formatters.each{|f| f.start(number_of_examples)} 
    @@started_formatters = true
  end
end