尝试开始使用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。任何想法究竟会导致什么。我的宝石文件中包含了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