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

  • Home
  • SEARCH
  • 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 9173141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:31:12+00:00 2026-06-17T16:31:12+00:00

I have run into a problem with Rspec while writing tests for my Omniauth

  • 0

I have run into a problem with Rspec while writing tests for my Omniauth authorizations controller.

Heres my routes.rb

MyWebApp::Application.routes.draw do

  get "static/index"

  match "login" =>  'user_sessions#new'

  match 'logout' => 'user_sessions#destroy'

  match "api" => "api#content", :via => :get
  match "api/node_tree" => "api#node_tree", :via => :get

  match "/auth/:provider/callback" => "oauth_authorizations#create"
  match "/auth/failure" => "oauth_authorizations#failure"
  match "/auth/:provider" => "oauth_authorizations#blank"

  resources :users do
    resources :apps do
      resources :nodes
    end
  end

  resources :user_sessions
end

oauth_authorization_controller_spec.rb

it "should create a new authorization entry for the user" do
  expect {get :create }.to change(Authorization, :count).by(1)
end

oauth_authorization_controller.rb

class OauthAuthorizationsController < ApplicationController

  def create

  end

end

When i am running my spec, I get the following error

Failures: 

  1) OauthAuthorizationsController when a current user session already exists should create a new authorization entry for the user
     Failure/Error: expect {get :create }.to change(Authorization, :count).by(1)
     ActionController::RoutingError:
       No route matches {:controller=>"oauth_authorizations", :action=>"create"}

Could any one please help me find out whats the reason behind this, because as its clear from the controller code, {:controller=>”oauth_authorizations”, :action=>”create”} does exist.

  • 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-17T16:31:13+00:00Added an answer on June 17, 2026 at 4:31 pm

    The problem was that the provider parameter specified in the route,

    match "/auth/:provider/callback" => "oauth_authorizations#create"
    

    was not passed from the test.

    Passing it fixed the test.

    get :create, :provider => omniauth_hash['provider']
    

    So the test would be re written as.

    it "should create a new authorization entry for the user" do
      expect {get :create, provider => omniauth_hash['provider'] }.to change(Authorization, :count).by(1)
    end
    

    May be this would help some one.

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

Sidebar

Related Questions

I have run into a problem while writing my server program. I need to
I have run into a problem while writing C++ code that needs to compile
I have run into a problem... I'm trying to use QTKit in an application
I am developing an xbap application and have run into a problem with users
I'm writing an own container class and have run into a problem I can't
Working on a console application using Delphi 7, and have run into a problem.
I am writing a Windows Api wrapper and I have run into a problem.
When writing a sitemap I have run into this problem: JSTL fmt tag does
I am writing an app and I have run into a problem. The first
I have run into a problem with Eclipse Indigo, attempting to start up my

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.