Permalink
Browse files

List plugins embedded in non dedicated gem

  • Loading branch information...
1 parent 2921ab6 commit d4aaca42f7452eed065c11eb81da3e903935709a @schmurfy schmurfy committed Dec 11, 2012
Showing with 22 additions and 1 deletion.
  1. +8 −1 lib/guard.rb
  2. +14 −0 spec/guard_spec.rb
View
@@ -404,7 +404,14 @@ def locate_guard(name)
#
def guard_gem_names
if Gem::Version.create(Gem::VERSION) >= Gem::Version.create('1.8.0')
- Gem::Specification.find_all.select { |x| x.name =~ /^guard-/ }
+ Gem::Specification.find_all.select do |x|
+ if x.name =~ /^guard-/
+ true
+ elsif x.name != "guard"
+ guard_plugin_path = File.join(x.full_gem_path, "lib/guard/#{x.name}.rb")
+ File.exists?( guard_plugin_path )
+ end
+ end
else
Gem.source_index.find_name(/^guard-/)
end.map { |x| x.name.sub(/^guard-/, '') }
View
@@ -780,6 +780,20 @@ class Inline < Guard
gems = Guard.guard_gem_names
gems.should include("rspec")
end
+
+ it "returns the list of embedded guard gems" do
+ gem1 = stub(:gem, :name => "gem1", :full_gem_path => '/gem1' )
+ gem2 = stub(:gem, :name => "gem2", :full_gem_path => '/gem2' )
+ gem3 = stub(:gem, :name => "guard", :full_gem_path => '/guard' )
+
+ File.should_receive(:exists?).with('/gem1/lib/guard/gem1.rb').and_return(false)
+ File.should_receive(:exists?).with('/gem2/lib/guard/gem2.rb').and_return(true)
+
+ Gem::Specification.should_receive(:find_all).and_return([gem1, gem2, gem3])
+
+ Guard.guard_gem_names.should == ['gem2']
+ end
+
end
describe ".debug_command_execution" do

0 comments on commit d4aaca4

Please sign in to comment.