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 8299907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:20:35+00:00 2026-06-08T16:20:35+00:00

Here is my feature : Scenario: Professor is not signed up and tries to

  • 0

Here is my feature:

 Scenario: Professor is not signed up and tries to sign in with Facebook
      Given I do not exist as a professor
      When I sign in as a professor with Facebook
      Then I should see a successful sign in message
      When I return to the site
      Then I should be signed in as a professor

Here is the step definition for When I sign in as a professor with Facebook

When /^I sign in as a professor with Facebook$/ do
  set_omniauth
  visit "/professors/auth/facebook"
end

And here is the definition of set_omniauth helper:

def set_omniauth(opts = {})
  default = {:provider => :facebook,
             :uuid     => "1234",
             :facebook => {
                            :email => "foobar@example.com",
                          }
            }

  credentials = default.merge(opts)
  provider = credentials[:provider]
  user_hash = credentials[provider]

  OmniAuth.config.test_mode = true

  OmniAuth.config.mock_auth[provider] = {
    'uid' => credentials[:uuid],
    "extra" => {
    "user_hash" => {
      "email" => user_hash[:email],
      }
    }
  }
end

So… When I visit /professors/auth/facebook, this action is called

def facebook
    @professor = Professor.find_for_facebook_oauth(request.env["omniauth.auth"], current_professor)
    if @professor.persisted?
      flash[:notice] = "Welcome! You have signed up successfully."
      sign_in_and_redirect @professor, :event => :authentication
    else
      session["devise.facebook_data"] = request.env["omniauth.auth"]
      redirect_to new_professor_registration_url
    end
  end

And finally, the method find_for_facebook_oauth definition is:

def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
    data = access_token["extra"]["raw_info"]
    if professor = self.find_by_email(data.email)
      professor
    else # Create a professor with a stub password. 
      self.create(:email => data.email, :password => Devise.friendly_token[0,20]) 
    end
  end

When running this feature, I get the following error message:

undefined method `email' for {"email"=>"foobar@example.com"}:Hash (NoMethodError)

So, I checked what Facebook actually returns:

#<Hashie::Mash email="myemail@gmail.com" ...

But this is a different object than a normal hash set in:

OmniAuth.config.mock_auth[provider] = {
    'uid' => credentials[:uuid],
    "extra" => {
    "user_hash" => {
      "email" => user_hash[:email],
      }
    }

So, my question is: How would I test this properly? I followed OmniAuth Integration Tetsing and they set a Hash, and not a Hashie.

  • 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-08T16:20:36+00:00Added an answer on June 8, 2026 at 4:20 pm

    You need to create your Hash using a built in OmniAuth method for creating a Hashie object:

    OmniAuth.config.mock_auth[provider] = OmniAuth::AuthHash.new({
    'uid' => credentials[:uuid],
    "extra" => {
    "user_hash" => {
      "email" => user_hash[:email],
      }
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not very familiar with publish feature.But here is the scenario I have
Scenario: Then I should see movies with ratings PG and R displayed Step definition:
I have a simple feature: Feature: User can see the welcome page Scenario: User
The TextWrapping feature in Silverlight is described here . However, I'm trying to find
Here's a problem. Developers have some kind of a task (develop certain feature), which
Im using sql server 2012 and its replication feature. Here im trying to manually
I'm playing around with the html5 contentEditable=true feature. The best example therefor is here
I can't seem to get PIE.htc working on this site. Here's my CSS: section#feature
Here's my scenario: My project is following the topic branching pattern. I create a
I'm trying to apply autofac decorator support feature to my scenario with no success.

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.