mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 12:45:24 +08:00
DEV: make autospec compatible with rspec 3
This commit is contained in:
@ -4,6 +4,8 @@ module Autospec; end
|
||||
|
||||
class Autospec::Formatter < RSpec::Core::Formatters::BaseTextFormatter
|
||||
|
||||
RSpec::Core::Formatters.register self, :example_passed, :example_pending, :example_failed, :start_dump
|
||||
|
||||
RSPEC_RESULT = "./tmp/rspec_result"
|
||||
|
||||
def initialize(output)
|
||||
@ -17,30 +19,27 @@ class Autospec::Formatter < RSpec::Core::Formatters::BaseTextFormatter
|
||||
@fail_file = File.open(RSPEC_RESULT,"w")
|
||||
end
|
||||
|
||||
def example_passed(example)
|
||||
super
|
||||
output.print success_color(".")
|
||||
def example_passed(_notification)
|
||||
output.print RSpec::Core::Formatters::ConsoleCodes.wrap('.', :success)
|
||||
end
|
||||
|
||||
def example_pending(example)
|
||||
super
|
||||
output.print pending_color("*")
|
||||
def example_pending(_notification)
|
||||
output.print RSpec::Core::Formatters::ConsoleCodes.wrap('*', :pending)
|
||||
end
|
||||
|
||||
def example_failed(example)
|
||||
super
|
||||
output.print failure_color("F")
|
||||
@fail_file.puts(example.metadata[:location] + " ")
|
||||
def example_failed(notification)
|
||||
output.print RSpec::Core::Formatters::ConsoleCodes.wrap('F', :failure)
|
||||
@fail_file.puts(notification.example.metadata[:location] + " ")
|
||||
@fail_file.flush
|
||||
end
|
||||
|
||||
def start_dump
|
||||
super
|
||||
def start_dump(notification)
|
||||
output.puts
|
||||
end
|
||||
|
||||
def close
|
||||
def close(filename)
|
||||
@fail_file.close
|
||||
super(filename)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -134,6 +134,7 @@ class Autospec::Manager
|
||||
@queue.shift if current[0] == "focus"
|
||||
# focus on the first 10 failed specs
|
||||
failed_specs = runner.failed_specs[0..10]
|
||||
puts "@@@@@@@@@@@@ failed_spces --> #{failed_specs}" if @debug
|
||||
# focus on the failed specs
|
||||
@queue.unshift ["focus", failed_specs.join(" "), runner] if failed_specs.length > 0
|
||||
end
|
||||
|
Reference in New Issue
Block a user