Permalink
Browse files

Fixed path locations.

Added preliminary specs
  • Loading branch information...
1 parent 62aed5a commit 72383de2d6fb68423bf098d66be44732ba9e232c @suranyami suranyami committed May 23, 2011
Showing with 97 additions and 0 deletions.
  1. +2 −0 README.markdown
  2. +30 −0 Rakefile
  3. +45 −0 lib/guard/delayed_job.rb
  4. +20 −0 spec/guard/delayed_job_spec.rb
View
@@ -42,3 +42,5 @@ you make.
== Authors
[David Parry](http://github.com/suranyami)
+
+This gem is based on [Guard::WEBrick](http://github.com/fnichol/guard-webrick).
View
@@ -1,2 +1,32 @@
require 'bundler'
Bundler::GemHelper.install_tasks
+
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec)
+task :default => :spec
+
+namespace(:spec) do
+ desc "Run all specs on multiple ruby versions (requires rvm)"
+ task(:portability) do
+ rubies = if ENV['RUBIES']
+ ENV['RUBIES'].split(' ')
+ else
+ %w[1.8.7 1.9.2 ree jruby]
+ end
+ rubies.each do |version|
+ rvm_ruby = if ENV['GEMSET']
+ "#{version}@#{ENV['GEMSET']}"
+ else
+ version
+ end
+ system <<-BASH
+ bash -c '
+ source ~/.rvm/scripts/rvm;
+ rvm #{rvm_ruby};
+ echo "--------- version #{rvm_ruby} ----------\n";
+ bundle install;
+ rake spec'
+ BASH
+ end
+ end
+end
View
@@ -0,0 +1,45 @@
+require 'guard'
+require 'guard/guard'
+
+module Guard
+ class DelayedJob < Guard
+
+ def initialize(watchers = [], options = {})
+ super
+ end
+
+ def start
+ UI.info "Starting up DelayedJob..."
+ system('script/delayed_job', 'start')
+ end
+
+ # Called on Ctrl-C signal (when Guard quits)
+ def stop
+ UI.info "Starting up DelayedJob..."
+ system('script/delayed_job', 'stop')
+ end
+
+ # Called on Ctrl-Z signal
+ # This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
+ def reload
+ restart
+ end
+
+ # Called on Ctrl-/ signal
+ # This method should be principally used for long action like running all specs/tests/...
+ def run_all
+ restart
+ end
+
+ # Called on file(s) modifications
+ def run_on_change(paths)
+ restart
+ end
+
+ private
+
+ def restart
+ system('script/delayed_job', 'restart')
+ end
+ end
+end
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe Guard::DelayedJob do
+ subject { Guard::DelayedJob.new }
+
+ describe "start" do
+ before do
+ subject = Guard::DelayedJob.new
+ end
+
+ after do
+ subject.stop
+ end
+
+ it "should create a pid in /tmp/pids" do
+ subject.start
+ Dir.glob("tmp/pids/delayed_job*.pid").should_not be_empty
+ end
+ end
+end

0 comments on commit 72383de

Please sign in to comment.