我正在使用 Rspec 功能规范,当我运行它们时,我会得到如下输出:
.............Started GET "/sign_up" for 127.0.0.1 at 2013-08-08 10:52:00 -0700
Started POST "/accounts" for 127.0.0.1 at 2013-08-08 10:52:01 -0700
Started GET "/" for 127.0.0.1 at 2013-08-08 10:52:01 -0700
.Started GET "/sign_in" for 127.0.0.1 at 2013-08-08 10:52:02 -0700
Started POST "/users/sign_in" for 127.0.0.1 at 2013-08-08 10:52:02 -0700
Started GET "/" for 127.0.0.1 at 2013-08-08 10:52:02 -0700
................................. (etc...)
如何在输出中抑制来自请求的消息?我试过设置日志级别无济于事。任何想法,将不胜感激。谢谢!
编辑:
这是一个使用 Ruby 2.0 的 Rails 4 项目。
规范/spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'factory_girl'
require 'capybara/rails'
require 'capybara/rspec'
require 'webmock/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.mock_with :mocha
config.include FactoryGirl::Syntax::Methods
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
end
规格/功能/sign_in_spec.rb
require "spec_helper"
feature "Sign in" do
background do
account = create(:account)
@admin = account.admin
end
scenario "User signs into the application" do
visit sign_in_path
fill_in "user_email", with: @admin.email
fill_in "user_password", with: @admin.password
click_button "Sign in"
expect(page).to have_content "Signed in successfully"
end
end