commit 3f7d19cba2af07d99cb633f0c64c60e2ab1a82e0 Author: John Bintz Date: Wed Aug 3 18:49:53 2011 -0400 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4040c6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.gem +.bundle +Gemfile.lock +pkg/* diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..72aa9ea --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source "http://rubygems.org" + +# Specify your gem's dependencies in guard-rspec-hydra.gemspec +gemspec diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..c702cfc --- /dev/null +++ b/Rakefile @@ -0,0 +1 @@ +require 'bundler/gem_tasks' diff --git a/guard-rspec-hydra.gemspec b/guard-rspec-hydra.gemspec new file mode 100644 index 0000000..3d0c52d --- /dev/null +++ b/guard-rspec-hydra.gemspec @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) + +Gem::Specification.new do |s| + s.name = "guard-rspec-hydra" + s.version = '0.0.1' + s.authors = ["John Bintz"] + s.email = ["john@coswellproductions.com"] + s.homepage = "" + s.summary = %q{Extend Guard::RSpec to use Hydra to run all specs. Super-fast!} + s.description = %q{Extend Guard::RSpec to use Hydra to run all specs. Super-fast!} + + s.rubyforge_project = "guard-rspec-hydra" + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib"] + + s.add_dependency 'guard', '>= 0.5.0' + s.add_dependency 'guard-rspec' +end diff --git a/lib/guard-rspec-hydra.rb b/lib/guard-rspec-hydra.rb new file mode 100644 index 0000000..e69de29 diff --git a/lib/guard/rspec-hydra.rb b/lib/guard/rspec-hydra.rb new file mode 100644 index 0000000..96d2a48 --- /dev/null +++ b/lib/guard/rspec-hydra.rb @@ -0,0 +1,36 @@ +require 'guard' +require 'guard/guard' +require 'guard/rspec' + +module Guard + class RSpecHydra < Guard::RSpec + def initialize(watchers = [], options = {}) + super + + @options = { + :rails_env => 'test', + :rake_task => 'hydra:spec', + :runner_log => 'hydra-runner.log', + :show_runner_log => true + }.merge(@options) + end + + def start + UI.info "Guard::Hydra is giving Guard::RSpec super run_all powers. Whoa!" + super + end + + def run_all + File.unlink(@options[:runner_log]) if runner_log? + + system %{rake RAILS_ENV=#{@options[:rails_env]} #{@options[:rake_task]}} + + puts File.read(@options[:runner_log]) if runner_log? && @options[:show_runner_log] + end + + private + def runner_log? + File.exist?(@options[:runner_log]) + end + end +end