Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
run all and run selected paths work
- Loading branch information
Michal Taszycki
committed
Aug 2, 2011
1 parent
c0e8040
commit 0535202
Showing
9 changed files
with
110 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +0,0 @@ | ||
module Guard | ||
module Jessie | ||
# Your code goes here... | ||
end | ||
end | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'guard' | ||
require 'guard/guard' | ||
|
||
module Guard | ||
class Jessie < Guard | ||
autoload :VERSION, 'guard/jessie/version' | ||
autoload :Runner, 'guard/jessie/runner' | ||
|
||
def run_all | ||
puts "Running all specs" | ||
Runner.run %w[spec] | ||
end | ||
|
||
def run_on_change paths | ||
paths_string = paths.map {|path| "#{path}" }.join(' ') | ||
puts "Running #{paths_string}" | ||
Runner.run paths | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Guard | ||
class Jessie | ||
module Runner | ||
def self.run paths | ||
return false if paths.empty? | ||
system(jessie_command(paths)) | ||
end | ||
|
||
private | ||
def self.jessie_command(paths) | ||
cmd_parts = [] | ||
cmd_parts << "jessie" | ||
cmd_parts << "-f progress" | ||
cmd_parts << paths.join(" ") | ||
|
||
cmd_parts.join(" ") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
guard 'jessie' do | ||
|
||
# Standard node project | ||
watch(%r{^spec/.+(_spec|Spec)\.(js|coffee)$}) | ||
watch(%r{^lib/(.+)\.(js|coffee)$}) { |m| "spec/lib/#{m[1]}_spec.js" } | ||
watch('spec/spec_helper.js') { "spec" } | ||
|
||
# Typical Rails (version < 3.1) app | ||
watch(%r{^spec/javascripts/.+(_spec|Spec)\.(js|coffee)$}) | ||
watch(%r{^public/javascripts/(.+)\.(js|coffee)$}) { |m| "spec/javascripts/#{m[1]}_spec.js" } | ||
watch('spec/spec_helper.js') { "spec" } | ||
|
||
# Typical Rails (version >= 3.1) app | ||
watch(%r{^spec/javascripts/.+(_spec|Spec)\.(js|coffee)$}) | ||
# you'll want to make adjustments to the rule below if you don't use coffeescript in your tests ;) | ||
watch(%r{^app/assets/javascripts/(.+)\.(js|coffee)$}) { |m| "spec/javascripts/#{m[1]}_spec.coffee" } | ||
watch('spec/spec_helper.js') { "spec" } | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Guard | ||
module Jessie | ||
class Jessie | ||
VERSION = "0.0.1" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
module Guard | ||
class Jessie | ||
describe Runner do | ||
let(:multiple_paths) { %w[/spec ./spec/something.js ../spec/something_else.js other_thing.js]} | ||
context "when passed an empty paths list" do | ||
it "returns false" do | ||
subject.run([]).should be_false | ||
end | ||
end | ||
|
||
context "when passed multiple paths" do | ||
it "runs jessie with those paths" do | ||
subject.should_receive(:system).with( | ||
"jessie -f progress /spec ./spec/something.js ../spec/something_else.js other_thing.js" | ||
) | ||
subject.run(multiple_paths) | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'spec_helper' | ||
module Guard | ||
describe Jessie do | ||
let(:paths) { %w[array of changed paths]} | ||
|
||
describe "#run_all" do | ||
it "runs all specs" do | ||
Jessie::Runner.should_receive(:run).with(["spec"]) | ||
subject.run_all | ||
end | ||
end | ||
describe "#run_on_change" do | ||
it "runs changed files" do | ||
Jessie::Runner.should_receive(:run).with(paths) | ||
subject.run_on_change paths | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$LOAD_PATH.unshift(File.dirname(__FILE__)) | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
|
||
require 'guard/jessie' |