From bf8c75dfe3ff180f5c77480e306ad5924c9aa4a9 Mon Sep 17 00:00:00 2001 From: Nick Gauthier Date: Tue, 6 Apr 2010 10:13:32 -0400 Subject: [PATCH] extracted the spec override from the formatter and change the requirement style so as not to kill test::unit files --- hydra.gemspec | 3 ++- lib/hydra/runner.rb | 2 ++ lib/hydra/spec/autorun_override.rb | 12 ++++++++++++ lib/hydra/spec/hydra_formatter.rb | 7 ------- lib/hydra/tasks.rb | 2 +- test/fixtures/write_file_alternate_spec.rb | 1 + test/fixtures/write_file_spec.rb | 1 + 7 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 lib/hydra/spec/autorun_override.rb diff --git a/hydra.gemspec b/hydra.gemspec index 62c43b8..e36f66d 100644 --- a/hydra.gemspec +++ b/hydra.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Nick Gauthier"] - s.date = %q{2010-04-05} + s.date = %q{2010-04-06} s.description = %q{Spread your tests over multiple machines to test your code faster.} s.email = %q{nick@smartlogicsolutions.com} s.extra_rdoc_files = [ @@ -46,6 +46,7 @@ Gem::Specification.new do |s| "lib/hydra/pipe.rb", "lib/hydra/runner.rb", "lib/hydra/safe_fork.rb", + "lib/hydra/spec/autorun_override.rb", "lib/hydra/spec/hydra_formatter.rb", "lib/hydra/ssh.rb", "lib/hydra/stdio.rb", diff --git a/lib/hydra/runner.rb b/lib/hydra/runner.rb index f4ddbb8..2f48d03 100644 --- a/lib/hydra/runner.rb +++ b/lib/hydra/runner.rb @@ -107,6 +107,8 @@ module Hydra #:nodoc: begin require 'spec' require 'hydra/spec/hydra_formatter' + # Ensure we override rspec's at_exit + require 'hydra/spec/autorun_override' rescue LoadError => ex return ex.to_s end diff --git a/lib/hydra/spec/autorun_override.rb b/lib/hydra/spec/autorun_override.rb new file mode 100644 index 0000000..bf00179 --- /dev/null +++ b/lib/hydra/spec/autorun_override.rb @@ -0,0 +1,12 @@ +if defined?(Spec) + module Spec + module Runner + class << self + # stop the auto-run at_exit + def run + return 0 + end + end + end + end +end diff --git a/lib/hydra/spec/hydra_formatter.rb b/lib/hydra/spec/hydra_formatter.rb index 36bdc2f..c31c8a5 100644 --- a/lib/hydra/spec/hydra_formatter.rb +++ b/lib/hydra/spec/hydra_formatter.rb @@ -1,13 +1,6 @@ -require 'spec/autorun' require 'spec/runner/formatter/progress_bar_formatter' module Spec module Runner - class << self - # stop the auto-run at_exit - def run - return 0 - end - end module Formatter class HydraFormatter < ProgressBarFormatter # Stifle the post-test summary diff --git a/lib/hydra/tasks.rb b/lib/hydra/tasks.rb index 4db699e..0365dcc 100644 --- a/lib/hydra/tasks.rb +++ b/lib/hydra/tasks.rb @@ -73,7 +73,7 @@ module Hydra #:nodoc: yield self if block_given? # Ensure we override rspec's at_exit - require 'hydra/spec/hydra_formatter' + require 'hydra/spec/autorun_override' @config = find_config_file diff --git a/test/fixtures/write_file_alternate_spec.rb b/test/fixtures/write_file_alternate_spec.rb index f0e611a..543858a 100644 --- a/test/fixtures/write_file_alternate_spec.rb +++ b/test/fixtures/write_file_alternate_spec.rb @@ -1,4 +1,5 @@ require 'tmpdir' +require 'spec' context "file writing" do it "writes to a file" do File.open(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'), 'a') do |f| diff --git a/test/fixtures/write_file_spec.rb b/test/fixtures/write_file_spec.rb index 0340cfa..ea617f0 100644 --- a/test/fixtures/write_file_spec.rb +++ b/test/fixtures/write_file_spec.rb @@ -1,4 +1,5 @@ require 'tmpdir' +require 'spec' context "file writing" do it "writes to a file" do File.open(File.join(Dir.tmpdir, 'hydra_test.txt'), 'a') do |f|