discourse/lib/autospec/formatter.rb

47 lines
852 B
Ruby
Raw Normal View History

2013-11-02 06:57:50 +08:00
require "rspec/core/formatters/base_text_formatter"
module Autospec; end
2013-11-02 06:57:50 +08:00
class Autospec::Formatter < RSpec::Core::Formatters::BaseTextFormatter
RSPEC_RESULT = "./tmp/rspec_result"
def initialize(output)
super
2013-11-02 06:57:50 +08:00
FileUtils.mkdir_p("tmp") unless Dir.exists?("tmp")
end
2013-11-02 06:57:50 +08:00
def start(example_count)
super
File.delete(RSPEC_RESULT) if File.exists?(RSPEC_RESULT)
@fail_file = File.open(RSPEC_RESULT,"w")
end
2013-11-02 06:57:50 +08:00
def example_passed(example)
super
output.print success_color(".")
end
def example_pending(example)
super
2013-11-02 06:57:50 +08:00
output.print pending_color("*")
end
def example_failed(example)
2013-11-02 06:57:50 +08:00
super
output.print failure_color("F")
@fail_file.puts(example.metadata[:location] + " ")
@fail_file.flush
end
2013-11-02 06:57:50 +08:00
def start_dump
super
output.puts
end
def close
@fail_file.close
end
end