Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7732581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:45:58+00:00 2026-06-01T06:45:58+00:00

My Rails 3.2 app uses OmniAuth and Devise to sign in with Twitter. The

  • 0

My Rails 3.2 app uses OmniAuth and Devise to sign in with Twitter. The authentication system works fine. I would like to write an integration test in rspec to make sure everything works. Using the information in the wiki, I’ve written the following, but I know I’m missing things.

Under test.rb in config/environments, I have the following lines

OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:twitter] = {:provider => 'twitter', :uid => '123545'}

My rspec test looks like this:

describe "Authentications" do
  context "without signing into app" do

    it "twitter sign in button should lead to twitter authentication page" do
      visit root_path
      click_link "Sign in with Twitter"
      Authentication.last.uid.should == '123545'
    end

  end
end

Authentication is the name of my model and calling .uid in rails console returns the string fine.

I’m getting the following error when I run this test:

Failure/Error: Authentication.last.uid.should == '123545'
NoMethodError:
undefined method `uid' for nil:NilClass

Can anyone help me figure out how to use the OmniAuth mocks that are provided? An explanation for why and how it works would be appreciated as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:45:59+00:00Added an answer on June 1, 2026 at 6:45 am

    I run into something similar.

    After changing my mock object from using symbol keys:

    OmniAuth.config.mock_auth[:twitter] = {
        :uid => '1337',
        :provider => 'twitter',
        :info => {
          :name => 'JonnieHallman'
        }
      }
    

    to using string keys:

    OmniAuth.config.mock_auth[:twitter] = {
        'uid' => '1337',
        'provider' => 'twitter',
        'info' => {
          'name' => 'JonnieHallman'
        }
      }
    

    it worked.

    And do you have

      request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:twitter] 
    

    somewhere in your testcase?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails 3.1.3 app which uses devise for users authentication and soft-deletes
My rails 3.0.3 app uses devise gem (1.1.5) for authentication and before I wasn't
I've got a rails 3 production app that uses devise to deal with authentication.
I have a Rails app that uses activescaffold and I would like to hide
I am working on a Rails App that uses Devise as the authentication module,
I have a ruby on rails app that uses highcharts. Locally it works like
I've been working on a rails app that uses the restful authentication plugin. It
My rails 3 app uses devise, and we have it set so a user
I have a rails app that uses partials and in development everything works great
I'm looking to migrate users of a rails app which uses the Restful Authentication

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.