3

When I run rspec, I get this included in the console:

ActiveRecord::SchemaMigration Load (0.1ms)  SELECT "schema_migrations".* FROM     "schema_migrations"
   (0.1ms)  begin transaction
   (0.0ms)  commit transaction
   (0.0ms)  begin transaction
Started GET "/" for 127.0.0.1 at 2014-01-28 11:44:06 -0600
Processing by HomeController#index as HTML
Rendered home/index.html.haml within layouts/application (28.1ms)
Completed 200 OK in 54ms (Views: 52.0ms | ActiveRecord: 0.0ms)
   (0.1ms)  rollback transaction

Here is my spec_helper.rb:

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'

Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)

RSpec.configure do |config|
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
  config.use_transactional_fixtures = true

  config.infer_base_class_for_anonymous_controllers = false

  config.order = "random"

  config.use_transactional_fixtures = false

  config.before(:each) do
    DatabaseCleaner.strategy = if example.metadata[:js]
      :truncation
    else
      :transaction
    end
    DatabaseCleaner.start
  end

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

I am also using rbenv, sqlite and Ubuntu if that helps. I am using rails 4.1.0beta1 and I run rspec using the spring command bin/rspec.

4
  • 1
    How are you running rspec? Commented Jan 28, 2014 at 17:47
  • @Jon I just updated the post with more information. Commented Jan 28, 2014 at 18:06
  • Thanks ... but what command and options are you using when you run rspec? Commented Jan 28, 2014 at 19:02
  • I just use bin/rspec Commented Jan 28, 2014 at 23:21

1 Answer 1

10

I'm using rbenv as well, and to silence the logs you can execute the following in console (might be helpful to setup a shortcut):

ActiveRecord::Base.logger.level = Logger::INFO
ActionController::Base.logger.level = Logger::ERROR
Rails.logger.level = Logger::ERROR
Sign up to request clarification or add additional context in comments.

1 Comment

I added this to my rails_helper file, and it worked great. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.