ヘルパー モジュールのメソッドを使用しようとしていますが、rspec が .NET の下のテストのヘルパーを認識しないようですspec/features。への唯一の変更spec_helper.rbは の追加であることに注意してくださいrequire 'capybara/rspec'。
、、および(テストを含むディレクトリ) に移動しようとしhelper.rbましたが、うまくいきませんでした。テストは、ヘルパー メソッドが未定義であることを示し続けます。spec/supportspec/helpersspec/features
それを「動作」させる唯一の方法は、テストをspec/integration. しかし、現在カピバラは動作しません ( visit undefined) にないためspec/featuresです。
これが私のヘルパーモジュールです(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