mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-24 23:44:09 -05:00
DEV: make autospec compatible with rspec 3
This commit is contained in:
parent
82cc467d93
commit
b0306fd613
3 changed files with 14 additions and 14 deletions
|
@ -4,6 +4,8 @@ module Autospec; end
|
||||||
|
|
||||||
class Autospec::Formatter < RSpec::Core::Formatters::BaseTextFormatter
|
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"
|
RSPEC_RESULT = "./tmp/rspec_result"
|
||||||
|
|
||||||
def initialize(output)
|
def initialize(output)
|
||||||
|
@ -17,30 +19,27 @@ class Autospec::Formatter < RSpec::Core::Formatters::BaseTextFormatter
|
||||||
@fail_file = File.open(RSPEC_RESULT,"w")
|
@fail_file = File.open(RSPEC_RESULT,"w")
|
||||||
end
|
end
|
||||||
|
|
||||||
def example_passed(example)
|
def example_passed(_notification)
|
||||||
super
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap('.', :success)
|
||||||
output.print success_color(".")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def example_pending(example)
|
def example_pending(_notification)
|
||||||
super
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap('*', :pending)
|
||||||
output.print pending_color("*")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def example_failed(example)
|
def example_failed(notification)
|
||||||
super
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap('F', :failure)
|
||||||
output.print failure_color("F")
|
@fail_file.puts(notification.example.metadata[:location] + " ")
|
||||||
@fail_file.puts(example.metadata[:location] + " ")
|
|
||||||
@fail_file.flush
|
@fail_file.flush
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_dump
|
def start_dump(notification)
|
||||||
super
|
|
||||||
output.puts
|
output.puts
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close(filename)
|
||||||
@fail_file.close
|
@fail_file.close
|
||||||
|
super(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -134,6 +134,7 @@ class Autospec::Manager
|
||||||
@queue.shift if current[0] == "focus"
|
@queue.shift if current[0] == "focus"
|
||||||
# focus on the first 10 failed specs
|
# focus on the first 10 failed specs
|
||||||
failed_specs = runner.failed_specs[0..10]
|
failed_specs = runner.failed_specs[0..10]
|
||||||
|
puts "@@@@@@@@@@@@ failed_spces --> #{failed_specs}" if @debug
|
||||||
# focus on the failed specs
|
# focus on the failed specs
|
||||||
@queue.unshift ["focus", failed_specs.join(" "), runner] if failed_specs.length > 0
|
@queue.unshift ["focus", failed_specs.join(" "), runner] if failed_specs.length > 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ desc "Run all specs automatically as needed"
|
||||||
task "autospec" => :environment do
|
task "autospec" => :environment do
|
||||||
require 'autospec/manager'
|
require 'autospec/manager'
|
||||||
|
|
||||||
debug = ARGV.any? { |a| a == "d" || a == "debug" }
|
debug = ARGV.any?{ |a| a == "d" || a == "debug" } || ENV["DEBUG"]
|
||||||
force_polling = ARGV.any? { |a| a == "p" || a == "polling" }
|
force_polling = ARGV.any? { |a| a == "p" || a == "polling" }
|
||||||
latency = ((ARGV.find { |a| a =~ /l=|latency=/ } || "").split("=")[1] || 3).to_i
|
latency = ((ARGV.find { |a| a =~ /l=|latency=/ } || "").split("=")[1] || 3).to_i
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue