Don't modify a frozen hash.
This commit is contained in:
parent
5352528530
commit
9cfe8d3635
@ -16,8 +16,7 @@ module Guard
|
|||||||
@listener = Listener.select_and_init
|
@listener = Listener.select_and_init
|
||||||
@guards = []
|
@guards = []
|
||||||
|
|
||||||
options[:notify] = false if ENV["GUARD_NOTIFY"] == 'false'
|
!@options[:notify] || ENV["GUARD_NOTIFY"] == 'false' ? Notifier.turn_off : Notifier.turn_on
|
||||||
options[:notify] ? Notifier.turn_on : Notifier.turn_off
|
|
||||||
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
@ -61,7 +60,7 @@ module Guard
|
|||||||
guard.send(task_to_supervise, *args)
|
guard.send(task_to_supervise, *args)
|
||||||
rescue Exception
|
rescue Exception
|
||||||
UI.error("#{guard.class.name} guard failed to achieve its <#{task_to_supervise.to_s}> command: #{$!}")
|
UI.error("#{guard.class.name} guard failed to achieve its <#{task_to_supervise.to_s}> command: #{$!}")
|
||||||
::Guard.guards.delete guard
|
guards.delete guard
|
||||||
UI.info("Guard #{guard.class.name} has just been fired")
|
UI.info("Guard #{guard.class.name} has just been fired")
|
||||||
return $!
|
return $!
|
||||||
end
|
end
|
||||||
@ -83,7 +82,7 @@ module Guard
|
|||||||
|
|
||||||
def get_guard_class(name)
|
def get_guard_class(name)
|
||||||
try_to_load_gem name
|
try_to_load_gem name
|
||||||
self.const_get(self.constants.find{|klass_name| klass_name.to_s.downcase == name.downcase })
|
self.const_get(self.constants.find{ |klass_name| klass_name.to_s.downcase == name.downcase })
|
||||||
rescue TypeError
|
rescue TypeError
|
||||||
UI.error "Could not find load find gem 'guard-#{name}' or find class Guard::#{name}"
|
UI.error "Could not find load find gem 'guard-#{name}' or find class Guard::#{name}"
|
||||||
end
|
end
|
||||||
|
@ -38,14 +38,14 @@ describe Guard::Notifier do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe ".turn_off" do
|
describe ".turn_off" do
|
||||||
|
before(:each) { subject.turn_off }
|
||||||
|
|
||||||
if mac? && growl_installed?
|
if mac? && growl_installed?
|
||||||
it "does nothing" do
|
it "does nothing" do
|
||||||
Growl.should_not_receive(:notify)
|
Growl.should_not_receive(:notify)
|
||||||
subject.notify 'great', :title => 'Guard'
|
subject.notify 'great', :title => 'Guard'
|
||||||
end
|
end
|
||||||
end
|
elsif linux? && libnotify_installed?
|
||||||
|
|
||||||
if linux? && libnotify_installed?
|
|
||||||
it "does nothing" do
|
it "does nothing" do
|
||||||
Libnotify.should_not_receive(:show)
|
Libnotify.should_not_receive(:show)
|
||||||
subject.notify 'great', :title => 'Guard'
|
subject.notify 'great', :title => 'Guard'
|
||||||
|
@ -4,6 +4,12 @@ describe Guard do
|
|||||||
|
|
||||||
describe "Class Methods" do
|
describe "Class Methods" do
|
||||||
describe ".setup" do
|
describe ".setup" do
|
||||||
|
before(:each) do
|
||||||
|
# set ENV["GUARD_NOTIFY"] to nil in case the user has ENV["GUARD_NOTIFY"] = 'false' set
|
||||||
|
@old_env_guard_notify = ENV["GUARD_NOTIFY"]
|
||||||
|
ENV["GUARD_NOTIFY"] = nil
|
||||||
|
end
|
||||||
|
after(:each) { ENV["GUARD_NOTIFY"] = @old_env_guard_notify }
|
||||||
subject { ::Guard.setup }
|
subject { ::Guard.setup }
|
||||||
|
|
||||||
it "should retrieve itself for chaining" do
|
it "should retrieve itself for chaining" do
|
||||||
@ -36,7 +42,7 @@ describe Guard do
|
|||||||
it "should turn off notifier if env[GUARD_NOTIFY] is false" do
|
it "should turn off notifier if env[GUARD_NOTIFY] is false" do
|
||||||
::Guard::Notifier.should_receive(:turn_off)
|
::Guard::Notifier.should_receive(:turn_off)
|
||||||
ENV["GUARD_NOTIFY"] = 'false'
|
ENV["GUARD_NOTIFY"] = 'false'
|
||||||
::Guard.setup(:notify => true)
|
::Guard.setup({ :notify => true }.freeze)
|
||||||
ENV["GUARD_NOTIFY"] = nil
|
ENV["GUARD_NOTIFY"] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,6 @@ RSpec.configure do |config|
|
|||||||
config.run_all_when_everything_filtered = true
|
config.run_all_when_everything_filtered = true
|
||||||
|
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
Guard::Notifier.turn_off
|
|
||||||
@fixture_path = Pathname.new(File.expand_path('../fixtures/', __FILE__))
|
@fixture_path = Pathname.new(File.expand_path('../fixtures/', __FILE__))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user