我正在尝试使用来自helper模块的方法,但是rspec似乎不认识在spec/features下的测试所需的helper。请注意,spec_helper.rb唯一的更改是添加了require 'capybara/rspec'。
我尝试将helper.rb移动到spec/support、spec/helpers和spec/features(包含我的测试的目录),但都没有成功。测试表明helper方法未定义。
唯一能够“工作”的方法是将我的测试移动到其他目录,例如spec/integration。但现在capybara无法工作(visit undefined),因为它不在spec/features中。
这是我的helper模块(authentication_helper.rb):
我尝试将helper.rb移动到spec/support、spec/helpers和spec/features(包含我的测试的目录),但都没有成功。测试表明helper方法未定义。
唯一能够“工作”的方法是将我的测试移动到其他目录,例如spec/integration。但现在capybara无法工作(visit undefined),因为它不在spec/features中。
这是我的helper模块(authentication_helper.rb):
module AuthenticationHelper
def sign_in_as!(user)
visit '/users/sign_in'
fill_in "Email", with: user.email
fill_in "Password", with: "password"
click_button "Sign in"
page.should have_content("Signed in successfully.")
end
end
RSpec.configure do |c|
c.include AuthenticationHelper, type: :request
end
c.include AuthenticationHelper, type: :feature
- apneadiving