module RSpec::Core::Hooks

Public Instance Methods

after(*args, &block) click to toggle source
# File lib/rspec/four_phase/hooks.rb, line 12
def after(*args, &block)
  if in_spec_dir?(self.send(:caller))
    info_message("after")
  else
    register_hook :prepend, :after, *args, &block
  end
end
around(*args, &block) click to toggle source
# File lib/rspec/four_phase/hooks.rb, line 20
def around(*args, &block)
  if in_spec_dir?(self.send(:caller))
    info_message("around")
  else
    register_hook :prepend, :around, *args, &block
  end
end
before(*args, &block) click to toggle source
# File lib/rspec/four_phase/hooks.rb, line 4
def before(*args, &block)
  if in_spec_dir?(self.send(:caller))
    info_message("before")
  else
    register_hook :append, :before, *args, &block
  end
end

Private Instance Methods

in_spec_dir?(trace) click to toggle source
# File lib/rspec/four_phase/hooks.rb, line 30
def in_spec_dir?(trace)
  trace.first.match(/\/spec\//)
end
info_message(type) click to toggle source
# File lib/rspec/four_phase/hooks.rb, line 34
def info_message(type)
  Rspec::FourPhase.log.info "You should not use #{type} blocks. Use methods that you call explicitly, instead."
end