undefined local variable or method ‘xxx’ for #错误解决方案

官方文档如下:

https://github.com/rspec/rspec-rails/blob/master/Capybara.md

Capybara 2.0

To use Capybara 2.0, you need rspec-rails-2.11.1 or greater.

Capybara::DSL is added to examples in:

  • spec/features

Capybara::RSpecMatchers is added to examples in:

  • spec/features
  • spec/controllers
  • spec/views
  • spec/helpers
  • spec/mailers

问题原因:Capybara2.0以后,集成测试的目录变了

解决方案为:默认生成的RSpec集成测试目录为requests目录,改为features目录即可解决问题

参考原文:https://github.com/rspec/rspec-rails/issues/360

你可能感兴趣的:(undefined)