Clean Hook code
This commit is contained in:
parent
11495687f4
commit
96604060ed
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user