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.

  1. you should have code on top of file

    require 'spec_helper'

  2. the place put file spec/support, not spec/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

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -