5

次のspecサブディレクトリがあるとします。

lib
models
observers
workers

spec_helper.rb ファイルで、rspec に lib サブディレクトリ内のすべての spec ファイルを除外するように指示するにはどうすればよいですか?

Spork.prefork do

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

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

  RSpec.configure do |config|
    config.mock_with :rspec
    config.use_transactional_fixtures = false

    config.before(:suite) do
      DatabaseCleaner.clean_with :truncation
      DatabaseCleaner.strategy = :transaction
    end

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

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

    config.treat_symbols_as_metadata_keys_with_true_values = true
    config.filter_run :focus => true
  end

end

Spork.each_run do
  FactoryGirl.reload
end

参考までに-ガードを使用してテストを自動リロードしています。

4

2 に答える 2

1

除外する方法はわかりませんが、次のようにガードにリストを含めることができます。

guard 'rspec', :spec_paths => ['spec/models', 'spec/workers', 'spec/observers'] do
  # ...
end
于 2012-07-14T17:48:13.380 に答える