Reputation: 11153
I am getting an error that my method is not defined. The error is "undefined local variable or method 'mock_auth_hash', despite including the module which defined mock_auth_hash in the spec_helper.
I'm trying to do some rspec integration testing with omniauth and I'm following this link https://gist.github.com/kinopyo/1338738
Please help me figure out what's wrong because I've spent way too many hours trying to figure this one out...maybe I need a fresh pair of eyes on it...
Here are my files
spec->support->omniauth_macros.rb
module OmniauthMacros
def mock_auth_hash
OmniAuth.config.mock_auth[:facebook] = {'provider' =>"facebook",
'uid' =>"12345",
'info'=>{'name'=>"John Doe"},
'credentials'=>{'token'=>"AAABBBCCC"}}
end
end
spec->spec_helper.rb
RSpec.configure do |config|
.
.
.
config.include OmniauthMacros #I've also tried putting config.include(OmniauthMacros)
.
.
end
OmniAuth.config.test_mode = true
spec->requests->game_pages_spec.rb
describe "signing in" do
before {visit root_url}
mock_auth_hash
before {click_button "Login with Facebook"}
it {should have_selector('h1',text: 'Welcome')}
end
Upvotes: 1
Views: 189
Reputation: 18567
Your call to mock_auth_hash
has to go within a before
or it
.
Upvotes: 1