0
出於某種原因,我的團隊不希望我們的驗收測試存在於spec/requests目錄中。相反,他們希望將它們放置在spec目錄結構之外的名爲acceptance的新目錄中。所以,我的第一個問題是,使用RSpec,Capybara和capybara-webkit,這甚至有可能嗎?如何將RSpec/Capybara測試放在spec/requests目錄之外?
這裏是我的acceptance_spec_helper.rb文件
require 'rubygems'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
require 'capybara/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}
# Capybara.javascript_driver = :webkit
RSpec.configure do |config|
config.include RSpec::Rails::RequestExampleGroup, :type => :request, :example_group => {
:file_path => config.escaped_path(%w[acceptance])
}
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# 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
end
然而,它似乎並沒有應用程序實際上是被爲了運行進行測試。
另外,請不要只是說,把測試放回規格/要求目錄沒有一些非常強大的參數來備份爲什麼這是唯一的選擇。