Trying to test OmniAuth with RSpec and Capybara is completely unsuccessful.
So far, spec_helper.rb has:
# Enable omniauth testing mode OmniAuth.config.test_mode = true OmniAuth.config.mock_auth[:google] = OmniAuth::AuthHash.new({ :provider => 'google', :uid => '1337', :info => { 'name' => 'JonnieHallman', 'email' => ' jon@test.com ' } })
And I know that I need to put Capybara tests under spec/features . Therefore, I have:
require 'spec_helper' describe "Authentications" do context "without signing into app" do it "sign in button should lead to Google authentication page" do visit root_path click_link "Login" Authentication.last.uid.should == '1337' end end end
But I get:
1) Authentications without signing into app sign in button should lead to Google authentication page Failure/Error: Authentication.last.uid.should == '1337' NameError: uninitialized constant Authentication # ./spec/features/omniauth_spec.rb:10:in `block (3 levels) in <top (required)>'
Absolutely, completely lost. Went through the OmniAuth wiki and it really didn't help; searched for over an hour through Stack Overflow, no luck. Help?
source share