discourse/lib/autospec/formatter.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2013-11-01 18:57:50 -04:00
require "rspec/core/formatters/base_text_formatter"
require "parallel_tests/rspec/logger_base"
module Autospec
end
2013-11-01 18:57:50 -04:00
class Autospec::Formatter < RSpec::Core::Formatters::BaseTextFormatter
RSpec::Core::Formatters.register self,
:example_passed,
:example_pending,
:example_failed,
:start_dump
2013-11-01 18:57:50 -04:00
RSPEC_RESULT = "./tmp/rspec_result"
def initialize(output)
super
FileUtils.mkdir_p("tmp") unless Dir.exist?("tmp")
File.delete(RSPEC_RESULT) if File.exist?(RSPEC_RESULT)
2013-11-01 18:57:50 -04:00
@fail_file = File.open(RSPEC_RESULT, "w")
end
def example_passed(_notification)
output.print RSpec::Core::Formatters::ConsoleCodes.wrap(".", :success)
2013-11-01 18:57:50 -04:00
end
def example_pending(_notification)
output.print RSpec::Core::Formatters::ConsoleCodes.wrap("*", :pending)
end
def example_failed(notification)
output.print RSpec::Core::Formatters::ConsoleCodes.wrap("F", :failure)
@fail_file.puts(notification.example.location + " ")
@fail_file.flush
end
def start_dump(notification)
2013-11-01 18:57:50 -04:00
output.puts
end
def close(filename)
2013-11-01 18:57:50 -04:00
@fail_file.close
super(filename)
2013-11-01 18:57:50 -04:00
end
end