未初始化的常量Capybara(NameError)运行RoR测试

时间:2014-08-07 21:44:51

标签: ruby-on-rails ruby

在我的spec_helper.rb中,我有:

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

然后我正在跑步:

bundle exec rspec spec/requests/static_pages_spec.rb

******-C02MGBVJFD57:myapp ********$ bundle exec rspec spec/requests/static_pages_spec.rb
/Users/*********/workspace/myapp/spec/spec_helper.rb:18:in `block in <top (required)>': uninitialized constant Capybara (NameError)

为什么我收到此错误,我该如何解决?谢谢

1 个答案:

答案 0 :(得分:6)

您需要加入capybara gem。

您可以在Gemfile中添加它并运行bundle install

gem 'capybara'

之后在您的帮助文件中包含以下内容:

require 'capybara'
require 'capybara/dsl'