From b0306fd6134c592d08696b3af6f57f28ad590961 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 14 May 2015 11:24:48 +1000 Subject: [PATCH] DEV: make autospec compatible with rspec 3 --- lib/autospec/formatter.rb | 25 ++++++++++++------------- lib/autospec/manager.rb | 1 + lib/tasks/autospec.rake | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/autospec/formatter.rb b/lib/autospec/formatter.rb index d3ec0d892..98d872de8 100644 --- a/lib/autospec/formatter.rb +++ b/lib/autospec/formatter.rb @@ -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 diff --git a/lib/autospec/manager.rb b/lib/autospec/manager.rb index 440961e03..03020fcd9 100644 --- a/lib/autospec/manager.rb +++ b/lib/autospec/manager.rb @@ -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 diff --git a/lib/tasks/autospec.rake b/lib/tasks/autospec.rake index 836aa51fc..3df52d0f0 100644 --- a/lib/tasks/autospec.rake +++ b/lib/tasks/autospec.rake @@ -6,7 +6,7 @@ desc "Run all specs automatically as needed" task "autospec" => :environment do 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" } latency = ((ARGV.find { |a| a =~ /l=|latency=/ } || "").split("=")[1] || 3).to_i