Capybara - 未定义的方法制作

时间:2013-04-29 10:01:54

标签: rspec capybara

尝试开始使用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

时,可能会导致此错误

1 个答案:

答案 0 :(得分:3)

SO question开始,make方法似乎来自机械师宝石。确保将它包含在Gemfile中。或者您可以使用User.create

相关问题
最新问题