Skip to content

Commit

Permalink
Fixed path locations.
Browse files Browse the repository at this point in the history
Added preliminary specs
  • Loading branch information
suranyami committed May 23, 2011
1 parent 62aed5a commit 72383de
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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).
30 changes: 30 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions lib/guard/delayed_job.rb
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions spec/guard/delayed_job_spec.rb
Original file line number Diff line number Diff line change
@@ -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.