class RspecLogFormatter::Formatter
Attributes
clock[R]
Public Class Methods
new(output, opts={})
click to toggle source
Calls superclass method
# File lib/rspec_log_formatter/formatter.rb, line 23 def initialize(output, opts={}) super(output) @clock = opts[:clock] @build_number = opts[:build_number] @limit_history = opts[:limit_history] @history_manager = RspecLogFormatter::HistoryManager.new(FILENAME) end
Public Instance Methods
dump_summary(_,_,_,_)
click to toggle source
# File lib/rspec_log_formatter/formatter.rb, line 43 def dump_summary(_,_,_,_) return unless @limit_history @history_manager.truncate(@limit_history) end
example_failed(example)
click to toggle source
# File lib/rspec_log_formatter/formatter.rb, line 39 def example_failed(example) record("failed", example, clock.now, clock.now - @clock_start, example.exception) end
example_passed(example)
click to toggle source
# File lib/rspec_log_formatter/formatter.rb, line 35 def example_passed(example) record("passed", example, clock.now, clock.now - @clock_start) end
example_started(example)
click to toggle source
# File lib/rspec_log_formatter/formatter.rb, line 31 def example_started(example) @clock_start = clock.now end
Private Instance Methods
record(outcome, example, time, duration, exception=nil)
click to toggle source
# File lib/rspec_log_formatter/formatter.rb, line 52 def record(outcome, example, time, duration, exception=nil) if exception exception_data = [ exception.message.gsub(/\r|\n|\t/, " "), exception.class, ] else exception_data = [nil,nil] end example_data = [ @build_number, time, outcome, example.full_description.to_s.gsub(/\r|\n|\t/, " "), example.file_path, ] + exception_data + [duration] File.open(FILENAME, "a") do |f| f.puts example_data.to_csv(col_sep: "\t") end end