Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't show Bundler warning when no Gemfile is present. (Fixes #260)

  • Loading branch information...
commit 9abcdf1ccc271e17326be6456c25d745dc1794dc 1 parent 81788d8
@netzpirat netzpirat authored
Showing with 31 additions and 10 deletions.
  1. +1 −1  lib/guard/cli.rb
  2. +30 −9 spec/guard/cli_spec.rb
View
2  lib/guard/cli.rb
@@ -152,7 +152,7 @@ def show
# shows a hint to do so if not.
#
def verify_bundler_presence
- ::Guard::UI.warning "You are using Guard outside of Bundler, this is dangerous and may not work. Using `bundle exec guard` is safer." unless ENV['BUNDLE_GEMFILE']
+ ::Guard::UI.warning "You are using Guard outside of Bundler, this is dangerous and may not work. Using `bundle exec guard` is safer." if File.exists?('Gemfile') && !ENV['BUNDLE_GEMFILE']
end
end
View
39 spec/guard/cli_spec.rb
@@ -13,22 +13,43 @@
subject.start
end
- context 'when running with Bundler' do
+ context 'with a Gemfile in the project dir' do
before do
- @bundler_env = ENV['BUNDLE_GEMFILE']
- ENV['BUNDLE_GEMFILE'] = 'Gemfile'
+ File.should_receive(:exists?).with('Gemfile').and_return true
end
- after { ENV['BUNDLE_GEMFILE'] = @bundler_env }
+ context 'when running with Bundler' do
+ before do
+ @bundler_env = ENV['BUNDLE_GEMFILE']
+ ENV['BUNDLE_GEMFILE'] = 'Gemfile'
+ end
- it 'does not show the Bundler warning' do
- ui.should_not_receive(:warning).with("You are using Guard outside of Bundler, this is dangerous and may not work. Using `bundle exec guard` is safer.")
- subject.start
+ after { ENV['BUNDLE_GEMFILE'] = @bundler_env }
+
+ it 'does not show the Bundler warning' do
+ ui.should_not_receive(:warning).with("You are using Guard outside of Bundler, this is dangerous and may not work. Using `bundle exec guard` is safer.")
+ subject.start
+ end
+ end
+
+ context 'when running without Bundler' do
+ before do
+ @bundler_env = ENV['BUNDLE_GEMFILE']
+ ENV['BUNDLE_GEMFILE'] = nil
+ end
+
+ after { ENV['BUNDLE_GEMFILE'] = @bundler_env }
+
+ it 'does not show the Bundler warning' do
+ ui.should_receive(:warning).with("You are using Guard outside of Bundler, this is dangerous and may not work. Using `bundle exec guard` is safer.")
+ subject.start
+ end
end
end
- context 'when running without Bundler' do
+ context 'without a Gemfile in the project dir' do
before do
+ File.should_receive(:exists?).with('Gemfile').and_return false
@bundler_env = ENV['BUNDLE_GEMFILE']
ENV['BUNDLE_GEMFILE'] = nil
end
@@ -36,7 +57,7 @@
after { ENV['BUNDLE_GEMFILE'] = @bundler_env }
it 'does not show the Bundler warning' do
- ui.should_receive(:warning).with("You are using Guard outside of Bundler, this is dangerous and may not work. Using `bundle exec guard` is safer.")
+ ui.should_not_receive(:warning).with("You are using Guard outside of Bundler, this is dangerous and may not work. Using `bundle exec guard` is safer.")
subject.start
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.