Rooktone
Rooktone

Reputation: 109

How to turn off Rspec's verbose logging?

When running our rspec suite of tests

bundle exec rspec spec/

The logs are cluttered with far to many log statements. In particular, the controller specs show things like this multiple times:

{"controller"=>"myController", "action"=>"create"}

I would like to get rid of these but can't find the source. There are no puts statements which match anything like this nor are there any Rails.logger calls. I'm assuming this is a log level issue but I could be wrong. Setting config.log_level in environment/test.rb has no effect.

The current rspec configuration looks like this

RSpec.configure do |config|
  config.include Devise::TestHelpers, :type => :controller
  config.mock_with :rspec


  config.before(:suite) do
    DatabaseCleaner.strategy = :truncation
    DatabaseCleaner.orm = "mongoid"
  end

  config.before(:each) do
    DatabaseCleaner.clean
  end

  config.color_enabled = true
  config.tty = true
  config.formatter =  :documentation # :progress, :html, :textmate
end

Any thoughts on how I might disable these type of logs?

Side note: Gemfile is using 'rails', '3.2.13' and 'rspec-rails', '2.14.0'

Upvotes: 3

Views: 4585

Answers (2)

Shadowcat
Shadowcat

Reputation: 423

In case someone comes across this same thread later on, I found that I had the same problem the author described, however, it came from having the Heroku rails_12factor gem in my Gemfile.

Another user said that the gem was causing double output for them: Double console output?

As soon as I either commented it out or put it in the :production group, all of the verbose SQL output in my console went away.

So just another thing to check if you have the same problem, but the author's solution isn't what fixes it for you.

Upvotes: 31

Rooktone
Rooktone

Reputation: 109

The issue was not with Rspec after all. Instead Someone had written 'p params' in a controller helper. This question is not really valid due to this.

Relishapp's docs were very useful in uncovering this

https://www.relishapp.com/rspec/rspec-rails/docs

Upvotes: 2

Related Questions