ruby-on-rails – rails app中未初始化的常量Capybara(NameError)

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – rails app中未初始化的常量Capybara(NameError)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

c:/mowes/www/rails_projects/sample_app/spec/spec_helper.rb:4:in `block
in ‘: uninitialized constant Capybara (NameError)

投机/ spec_helper.rb

# This file is copied to spec/ when you run 'rails generate rspec:install'

RSpec.configure do |config|
  config.include Capybara::DSL
end

我的Gemfile中有宝石’capybara’,’2.1.0’所以我不知道发生了什么.

解决方法

我认为这可行.尝试在spec_helper.rb中添加这些行
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
end

猜你在找的Ruby相关文章