我使用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
解决方法@H_403_20@
我最近经历了这个,将
rails_12factor宝石添加到我的Gemfile中,以在Heroku上启用静态资产服务.其中一个依赖是
rails_stdout_logging(顾名思义)将您的应用程序配置为登录到stdout.一种解决这个问题的方法是指定gem(在您的Gemfile中)仅用于生产,如:gem’rails_12factor’,group::production或现有的生产组块.
如果您不使用rails_12factor,或者不知道在应用程序中使用的rails_stdout_logging gem,请打开Gemfile.lock并搜索“rails_stdout_logging”.确保此宝石仅在您的生产环境中使用时,应停止在运行规格时输出上述请求.
如果您不使用rails_12factor,或者不知道在应用程序中使用的rails_stdout_logging gem,请打开Gemfile.lock并搜索“rails_stdout_logging”.确保此宝石仅在您的生产环境中使用时,应停止在运行规格时输出上述请求.