Ruby on rails Capybara 2.0和rspec rails——助手不使用';在规格/特性中不起作用

Ruby on rails Capybara 2.0和rspec rails——助手不使用';在规格/特性中不起作用,ruby-on-rails,ruby,rspec,capybara,helper,Ruby On Rails,Ruby,Rspec,Capybara,Helper,我试图使用helper模块中的方法,但rspec似乎无法识别spec/features下测试的helper。请注意,spec\u helper.rb的唯一更改是添加了require'capybara/rspec' 我尝试将helper.rb移动到spec/support、spec/helpers、和spec/features(包含我的测试的目录),但没有成功。该测试一直指示helper方法未定义 让它“工作”的唯一方法是将我的测试移动到另一个目录,例如spec/integration。但是现在水

我试图使用helper模块中的方法,但rspec似乎无法识别
spec/features
下测试的helper。请注意,
spec\u helper.rb
的唯一更改是添加了
require'capybara/rspec'

我尝试将
helper.rb
移动到
spec/support
spec/helpers
、和
spec/features
(包含我的测试的目录),但没有成功。该测试一直指示helper方法未定义

让它“工作”的唯一方法是将我的测试移动到另一个目录,例如
spec/integration
。但是现在水豚不能工作(
访问未定义的
),因为它不在
规范/功能中

这是我的助手模块(
authentication\u helper.rb
):


将此帮助文件放入规范/支持中/

这一行是spec_helper.rb

  # Requires supporting ruby files with custom matchers and macros, etc,
  # in spec/support/ and its subdirectories.
  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

您是否尝试过:
c.include AuthenticationHelper,type::feature
我刚刚尝试过,但仍然存在相同的问题。我找到了解决方案:我将*\u spec.rb文件移动到spec/integration目录,并将config.include Capybara::DSL添加到spec\u helper。看起来我甚至可以将*u spec.rb文件移动到spec/requests。但我仍然有点认为这不是标准的方法,因为capybara 2建议将spec文件放入spec/features中。但同时,我对软件开发世界还很陌生,所以我可以什么都不用担心。我不知道,你们怎么想?我应该找一个更好的方法还是按原样离开?噢,哇。我很确定我试过了你的建议——我甚至记得是:功能,而不是:功能,因为我检查了两次。这可能与RSpecRails 2.13.1有关,因为在将其更新为2.13.2之后,它工作了!谢谢不幸的是,我不知道如何接受评论作为答案,尽管.spec_helper.rb已经默认了。同样,我对spec_helper.rb文件所做的唯一更改是在执行上述步骤后添加require'capybara/rspec',将'include AuthenticationHelper'添加到require语句中似乎不起作用,但我看到了这一点。遗憾的是,这不是我正在寻找的解决方案,因为可能还有其他测试需要该模块。虽然可行,但我更愿意使用rspec提供的一个功能(这似乎不适合开箱即用的atm),让我和其他人都能更轻松地使用它。
  # Requires supporting ruby files with custom matchers and macros, etc,
  # in spec/support/ and its subdirectories.
  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }