[rspec-users] Does anyone know how to mock the Rails Logger then set expectations with should_receive?

john eagerwombat at gmail.com
Thu Jun 12 19:03:17 EDT 2008

Hey Guys,

I'm trying to mock the Rails Logger for the following code:

    rescue TimeoutError => error
      $logger.error("#{self.name} Timeout for #{path}: #{error}") and return
    rescue SocketError => error
      $logger.error("#{self.name} SocketError for #{path}: #{error}") and
    rescue StandardError => error
      $logger.error("#{self.name} Error for #{path}: #{error}") and return

my failed attempt to spec:

   logger = mock_model(Logger)

Do you know of any solution for mocking this?

Also, do you think the Rails Logger is worth mocking?

Thanks very much in Advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080612/841a230f/attachment-0001.html>

More information about the rspec-users mailing list