ruby on rails - should this code work for including in a helper file to rspec? -
i have following sample code using vanilla spec_helper. i'm trying use sign_in_as getting error saying doesn't exist. hadn't seen config syntax before i'm not sure if being used right. appreciated? thx
in helpers/sign_in_helpers.rb
module signinhelpers def say_hello puts 'hello' end def sign_in sign_in_as 'person@example.com' end def sign_in_as email visit root_path fill_in 'email address', with: email click_button 'sign in' end end rspec.configure |config| config.include signinhelpers end
some errors in code.
you should have code on top of file
require 'spec_helper'
the place put file
spec/support, notspec/helpers
also, following code, better keep them inside spec/spec_helper.rb inside configure block, though way should work well.
rspec.configure |config| config.include signinhelpers end by way, better define type helper features only, , not going work in controller tests.
config.include signinhelpers type: :feature
Comments
Post a Comment