Permalink
Browse files

Add a `--no-bundler-warning` option to Guard.

  • Loading branch information...
1 parent c9299db commit 69b8a52762cd68f188ffe009ee9c396427293a9f @netzpirat netzpirat committed Mar 12, 2012
Showing with 24 additions and 3 deletions.
  1. +9 −0 README.md
  2. +7 −1 lib/guard/cli.rb
  3. +8 −2 spec/guard/cli_spec.rb
View
@@ -339,6 +339,15 @@ $ guard start -I
$ guard start --no-vendor
```
+### `-B`/`--no-bundler-warning` option
+
+Skip Bundler warning when a Gemfile exists in the project directory but Guard is not run with Bundler.
+
+```bash
+$ guard start -B
+$ guard start --no-bundler-warning
+```
+
### List
You can list the available Guards with the `list` task:
View
@@ -65,13 +65,19 @@ class CLI < Thor
:aliases => '-i',
:banner => 'Turn off completely any guard terminal interactions'
+ method_option :no_bundler_warning,
+ :type => :boolean,
+ :default => false,
+ :aliases => '-B',
+ :banner => 'Turn off warning when Bundler is not present'
+
# Start Guard by initialize the defined Guards and watch the file system.
# This is the default task, so calling `guard` is the same as calling `guard start`.
#
# @see Guard.start
#
def start
- verify_bundler_presence
+ verify_bundler_presence unless options[:no_bundler_warning]
::Guard.start(options)
rescue Interrupt
::Guard.stop
View
@@ -15,7 +15,7 @@
context 'with a Gemfile in the project dir' do
before do
- File.should_receive(:exists?).with('Gemfile').and_return true
+ File.stub(:exists?).with('Gemfile').and_return true
end
context 'when running with Bundler' do
@@ -40,10 +40,16 @@
after { ENV['BUNDLE_GEMFILE'] = @bundler_env }
- it 'does not show the Bundler warning' do
+ it 'does 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
+
+ it 'does not show the Bundler warning with the :no_bundler_warning flag' 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.options = { :no_bundler_warning => true }
+ subject.start
+ end
end
end

0 comments on commit 69b8a52

Please sign in to comment.