0
我在我的集成測試中包含了Capybara。我已經根據文檔設置了我的test_helper文件。在使用Capybara和Rails時機架測試錯誤TestCase
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'capybara'
require 'capybara/dsl'
require 'vcr'
class ActiveSupport::TestCase
include Devise::Test::IntegrationHelpers
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
VCR.configure do |c|
c.hook_into :webmock
c.cassette_library_dir = 'vcr_cassettes'
c.default_cassette_options = { :record => :once }
end
end
class ActionDispatch::IntegrationTest
# Make the Capybara DSL available in all integration tests
include Capybara::DSL
# Reset sessions and driver between tests
# Use super wherever this method is redefined in your individual test classes
def teardown
Capybara.reset_sessions!
Capybara.use_default_driver
end
end
要使用水豚測試我的集成測試,我設置了一個方法,我portfolio_flow_test文件(也需要test_helper.rb中)
test "signed in user can visit portfolio index page" do
@user = users(:nicholas)
sign_in @user
visit portfolios_path
assert_select "h1", "Portfolios"
end
我得到了所有的考試這個錯誤
ArgumentError: rack-test requires a rack application, but none was given
水豚的默認驅動程序是機架測試,所以我不清楚爲什麼我運行測試時失敗。