Added some specs,and some lines in README/CHANGELOG for dry-run option.
And added support for Kernel.#` and %x literal.
This commit is contained in:
parent
49d14b1360
commit
847b2b8740
@ -6,6 +6,7 @@
|
||||
|
||||
## Improvements
|
||||
|
||||
- Pull request [#95](https://github.com/guard/guard/pull/95): Do a dry run without executing actions when the `:clear` option is given. ([@uk-ar][])
|
||||
- Pull request [#94](https://github.com/guard/guard/pull/94): Show backtrace in terminal when a problem with a watch action occurs. ([@capotej][])
|
||||
- Pull request [#88](https://github.com/guard/guard/pull/88): Write exception trace in the terminal when a supervised task fail. ([@mcmire][])
|
||||
- Color in red the "ERROR:" flag when using `UI.error`. ([@rymai][])
|
||||
|
@ -163,6 +163,15 @@ $ guard --debug
|
||||
$ guard -d # shortcut
|
||||
```
|
||||
|
||||
### `--dry-run` option
|
||||
|
||||
Do a dry run without executing actions:
|
||||
|
||||
``` bash
|
||||
$ guard --dry-run
|
||||
$ guard -y # shortcut
|
||||
```
|
||||
|
||||
An exhaustive list of options is available with:
|
||||
|
||||
``` bash
|
||||
|
@ -19,10 +19,15 @@ module Guard
|
||||
|
||||
@options[:notify] && ENV["GUARD_NOTIFY"] != 'false' ? Notifier.turn_on : Notifier.turn_off
|
||||
|
||||
if @options[:"dry-run"]
|
||||
Kernel.send(:define_method, :system ) do
|
||||
|program, *args| print program + ' ' + args.join(' ') + "\n"
|
||||
end if options.dry_run
|
||||
|program, *args| Kernel.print program + ' ' + args.join(' ') + "\n"
|
||||
end
|
||||
|
||||
Kernel.send(:define_method, :"`" ) do
|
||||
|command| Kernel.print command + "\n"
|
||||
end
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -9,7 +9,7 @@ module Guard
|
||||
method_option :notify, :type => :boolean, :default => true, :aliases => '-n', :banner => "Notifications feature (growl/libnotify)"
|
||||
method_option :debug, :type => :boolean, :default => false, :aliases => '-d', :banner => "Print debug messages"
|
||||
method_option :group, :type => :array, :default => [], :aliases => '-g', :banner => "Run only the passed groups"
|
||||
method_option :dry_run, :type => :boolean, :default => false, :aliases => '-y', :banner => "Do a dry run without executing actions"
|
||||
method_option :"dry-run", :type => :boolean, :default => false, :aliases => '-y', :banner => "Do a dry run without executing actions"
|
||||
|
||||
desc "start", "Starts Guard"
|
||||
def start
|
||||
|
@ -39,6 +39,44 @@ describe Guard do
|
||||
::Guard::Notifier.should_receive(:turn_off)
|
||||
::Guard.setup(:notify => true)
|
||||
end
|
||||
|
||||
context do
|
||||
before do
|
||||
@original_system = Kernel.method(:system)
|
||||
@original_command = Kernel.method(:"`")
|
||||
end
|
||||
|
||||
after do
|
||||
Kernel.send(:define_method, :system, @original_system.to_proc )
|
||||
Kernel.send(:define_method, :"`", @original_command.to_proc )
|
||||
end
|
||||
|
||||
it "overwrites Kernel.#system method if the dry-run option is false" do
|
||||
::Guard.setup(:"dry-run" => false)
|
||||
::Kernel.should_not_receive(:print).with("command arg1 arg2\n")
|
||||
system("command","arg1","arg2")
|
||||
end
|
||||
|
||||
it "overwrites Kernel.#system method if the dry-run option is true" do
|
||||
::Guard.setup(:"dry-run" => true)
|
||||
::Kernel.should_receive(:print).with("command arg1 arg2\n")
|
||||
system("command","arg1","arg2")
|
||||
end
|
||||
|
||||
it "overwrites Kernel.#` method if the dry-run option is false" do
|
||||
::Guard.setup(:"dry-run" => false)
|
||||
::Kernel.should_not_receive(:print).with("command\n")
|
||||
`command`
|
||||
%x{command}
|
||||
end
|
||||
|
||||
it "overwrites Kernel.#` method if the dry-run option is false" do
|
||||
::Guard.setup(:"dry-run" => true)
|
||||
::Kernel.should_receive(:print).twice.with("command\n")
|
||||
`command`
|
||||
%x{command}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe ".get_guard_class" do
|
||||
|
Loading…
Reference in New Issue
Block a user