尝试开始使用 Capybara 并进行非常简单的测试:
require 'spec_helper'
describe 'the login process', :type => :feature do
before :each do
User.make(:email => 'example@example.com', :password => 'password')
end
it 'signs them in' do
visit '/sessions/new'
within("#session") do
fill_in 'Login', :with => 'example@example.com'
fill_in 'Password', :with => 'password'
end
click_link 'Sign in'
page.should have_content 'Signed in successfully.'
end
end
我似乎收到以下错误:Imgur。任何想法究竟会导致这种情况。我的 gemfile 中包含 Capybara:
group :development, :test do
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'pry-debugger'
gem 'quiet_assets'
gem 'capybara'
end
并在我的spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.include Capybara::DSL
config.include FactoryGirl::Syntax::Methods
end
那么,当我运行时,究竟是什么导致了这个错误bundle exec rspec spec/requests/user_test.rb