Clean Hook code

This commit is contained in:
Rémy Coutable 2011-09-04 18:44:42 +02:00
parent 11495687f4
commit 96604060ed
2 changed files with 5 additions and 20 deletions

View File

@ -30,14 +30,12 @@ module Guard
def hook(event, *args)
hook_name = if event.is_a? Symbol
calling_method = caller[0][/`([^']*)'/, 1]
"#{calling_method}_#{event}".to_sym
"#{calling_method}_#{event}"
else
event.to_sym
end
event
end.to_sym
if ENV["GUARD_ENV"] == "development"
UI.info "\nHook :#{hook_name} executed for #{self.class}"
end
UI.debug "\nHook :#{hook_name} executed for #{self.class}"
Hook.notify(self.class, hook_name, *args)
end

View File

@ -85,19 +85,6 @@ describe Guard::Hook do
Guard::Hook.should_receive(:notify).with(guard_class, :special_sauce, 'first_arg', 'second_arg')
@guard.stop
end
context "--UI message--" do
it "is sent when in development mode" do
ENV["GUARD_ENV"] = 'development'
Guard::UI.should_receive(:info)
@guard.start
ENV["GUARD_ENV"] = 'test'
end
it "is not sent when not in development mode" do
Guard::UI.should_not_receive(:info)
@guard.start
end
end
end
end