Switched to gem which command to locate gem path rather than open-gem

This commit is contained in:
Thibaud Guillaume-Gentil 2011-02-22 15:15:09 +01:00
parent 17f048d883
commit 59f555e086
4 changed files with 19 additions and 19 deletions

View File

@ -2,6 +2,7 @@
Bugs fixes: Bugs fixes:
- Return unique filenames from Linux listener (Marian Schubert) - Return unique filenames from Linux listener (Marian Schubert)
- Guard.get_guard_class return wrong class when loaded nested class. (koshigoe) - Guard.get_guard_class return wrong class when loaded nested class. (koshigoe)
- Fixed open-gem/gem_open dependency problem by using `gem which` to locate guards gem path
== 0.3.0 (Jan 19, 2011) == 0.3.0 (Jan 19, 2011)

View File

@ -20,7 +20,6 @@ Gem::Specification.new do |s|
s.add_development_dependency 'guard-rspec', '~> 0.1.9' s.add_development_dependency 'guard-rspec', '~> 0.1.9'
s.add_dependency 'thor', '~> 0.14.6' s.add_dependency 'thor', '~> 0.14.6'
s.add_dependency 'open_gem', '~> 1.4.2'
s.files = Dir.glob('{bin,images,lib}/**/*') + %w[LICENSE README.rdoc] s.files = Dir.glob('{bin,images,lib}/**/*') + %w[LICENSE README.rdoc]
s.executable = 'guard' s.executable = 'guard'

View File

@ -88,7 +88,7 @@ module Guard
end end
def locate_guard(name) def locate_guard(name)
`gem open guard-#{name} --latest --command echo`.chomp `gem which guard/#{name}`.chomp
rescue rescue
UI.error "Could not find 'guard-#{name}' gem path." UI.error "Could not find 'guard-#{name}' gem path."
end end

View File

@ -1,34 +1,34 @@
require 'spec_helper' require 'spec_helper'
describe Guard do describe Guard do
describe "Class Methods" do describe "Class Methods" do
describe ".setup" do describe ".setup" do
subject { ::Guard.setup } subject { ::Guard.setup }
it "should retrieve itself for chaining" do it "should retrieve itself for chaining" do
subject.should be_kind_of(Module) subject.should be_kind_of(Module)
end end
it "should init guards array" do it "should init guards array" do
::Guard.guards.should be_kind_of(Array) ::Guard.guards.should be_kind_of(Array)
end end
it "should init options" do it "should init options" do
opts = { :my_opts => true } opts = { :my_opts => true }
::Guard.setup(opts).options.should include(:my_opts) ::Guard.setup(opts).options.should include(:my_opts)
end end
it "should init listener" do it "should init listener" do
::Guard.listener.should be_kind_of(Guard::Listener) ::Guard.listener.should be_kind_of(Guard::Listener)
end end
end end
describe ".get_guard_class" do describe ".get_guard_class" do
it "should return Guard::RSpec" do it "should return Guard::RSpec" do
Guard.get_guard_class('rspec').should == Guard::RSpec Guard.get_guard_class('rspec').should == Guard::RSpec
end end
context 'loaded some nested classes' do context 'loaded some nested classes' do
it "should return Guard::RSpec" do it "should return Guard::RSpec" do
require 'guard/rspec' require 'guard/rspec'
@ -37,7 +37,7 @@ describe Guard do
end end
end end
end end
describe ".locate_guard" do describe ".locate_guard" do
it "should return guard-rspec gem path" do it "should return guard-rspec gem path" do
guard_path = Guard.locate_guard('rspec') guard_path = Guard.locate_guard('rspec')
@ -45,42 +45,42 @@ describe Guard do
guard_path.should == guard_path.chomp guard_path.should == guard_path.chomp
end end
end end
describe ".supervised_task" do describe ".supervised_task" do
subject { ::Guard.setup } subject { ::Guard.setup }
before(:each) do before(:each) do
@g = mock(Guard::Guard) @g = mock(Guard::Guard)
subject.guards.push(@g) subject.guards.push(@g)
end end
describe "tasks that succeed" do describe "tasks that succeed" do
before(:each) do before(:each) do
@g.stub!(:regular) { true } @g.stub!(:regular) { true }
@g.stub!(:regular_with_arg).with("given_path") { "i'm a success" } @g.stub!(:regular_with_arg).with("given_path") { "i'm a success" }
end end
it "should not fire the guard with a supervised method without argument" do it "should not fire the guard with a supervised method without argument" do
lambda { subject.supervised_task(@g, :regular) }.should_not change(subject.guards, :size) lambda { subject.supervised_task(@g, :regular) }.should_not change(subject.guards, :size)
end end
it "should not fire the guard with a supervised method with argument" do it "should not fire the guard with a supervised method with argument" do
lambda { subject.supervised_task(@g, :regular_with_arg, "given_path") }.should_not change(subject.guards, :size) lambda { subject.supervised_task(@g, :regular_with_arg, "given_path") }.should_not change(subject.guards, :size)
end end
it "should return the result of the supervised method" do it "should return the result of the supervised method" do
::Guard.supervised_task(@g, :regular).should be_true ::Guard.supervised_task(@g, :regular).should be_true
::Guard.supervised_task(@g, :regular_with_arg, "given_path").should == "i'm a success" ::Guard.supervised_task(@g, :regular_with_arg, "given_path").should == "i'm a success"
end end
end end
describe "tasks that raise an exception" do describe "tasks that raise an exception" do
before(:each) { @g.stub!(:failing) { raise "I break your system" } } before(:each) { @g.stub!(:failing) { raise "I break your system" } }
it "should fire the guard" do it "should fire the guard" do
lambda { subject.supervised_task(@g, :failing) }.should change(subject.guards, :size).by(-1) lambda { subject.supervised_task(@g, :failing) }.should change(subject.guards, :size).by(-1)
subject.guards.should_not include(@g) subject.guards.should_not include(@g)
end end
it "should return the exception object" do it "should return the exception object" do
failing_result = ::Guard.supervised_task(@g, :failing) failing_result = ::Guard.supervised_task(@g, :failing)
failing_result.should be_kind_of(Exception) failing_result.should be_kind_of(Exception)
@ -89,5 +89,5 @@ describe Guard do
end end
end end
end end
end end