【发布时间】:2014-10-28 18:37:32
【问题描述】:
我一直在使用 rspec 和 guard 来自动运行我的测试 我保存了文件,但是 guard 每次运行两次我不知道为什么,我在另一篇文章中看到这可能是因为spec_helper.rb 中有一个重复的配置选项,但我认为这不是我的情况。我离开了我的 spec_helper 文件内容。希望知道如何解决这个问题,它开始需要很长时间等待警卫运行两次相同
谢谢
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.include Devise::TestHelpers, type: :controller
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
config.include FactoryGirl::Syntax::Methods
config.before(:suite) do
FactoryGirl.lint
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.before(:all) do
DatabaseCleaner.start
end
config.before(:each) do
reset_email
end
config.after(:all) do
DatabaseCleaner.clean
end
config.include(MailerMacros)
config.include Rails.application.routes.url_helpers
end
【问题讨论】:
-
同时显示您的 Guardfile。它是否总是每次都重复所有规格?还是只有一些?
标签: ruby-on-rails rspec guard