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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:57:31+00:00 2026-06-18T04:57:31+00:00

Getting really bizarre rspec behavior in one of my controller specs. It’s best to

  • 0

Getting really bizarre rspec behavior in one of my controller specs.

It’s best to illustrate. In rubymine, when I set a breakpoint, this happens:

#rspec test
describe Api::V1::UsersController do
  let(:user) { FactoryGirl.create(:user) }
  describe "#show" do
    it "responds successfully" do
      get 'show', id: user.id
      response.should be_success
    end
end

#controller
class Api::V1::UsersController < AuthenticatedController
    def show # !!! RubyMine breakpoint will stop execution here !!!
      user = User.find(params[:id])
      user_hash = User.information(user, current_user)

      respond_to do |format|
        format.json { render json: user_hash.to_json }
      end
end

So the above works as expected.

But, now this test fails.

#rspec test
describe UsersController do
  let(:user) { FactoryGirl.create(:user, is_admin: false) }
  describe "#show" do
    it "redirects non-admin" do
      get 'index'
      response.should redirect_to user_path(user)
    end
end

#controller
class UsersController < AuthenticatedController
  def index # !!! Breakpoint is never hit !!!
    @users = User.all
    respond_to do |format|
      if current_user.is_admin
        format.html
        format.json { render json: @users }
      else
        redirect_to user_path(current_user) and return
      end
    end
end
By the way, this is the result:
Expected response to be a redirect to <http://test.host/users/625> but was a redirect to <https://test.host/users>

None of my breakpoints in controller methods in UsersController are hit. BUT all controller methods are hit if I set breakpoints in API::V1::UsersController.

Any guidance is greatly appreciated. I’m really at a loss of how to debug this.

  • 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-18T04:57:32+00:00Added an answer on June 18, 2026 at 4:57 am

    Sorry, this question was more out of frustation than anything. But I finally figured out what was going on. Hint: tailing the test.log is a good idea.

    I was forcing ssl on the controller. The request rspec sent is http. ActionController::ForceSSL redirects the request to https and to the same controller#action. However, at this point, the rspec test was finished and failed the test because it only sees the redirection back to the same controller#action.

    So in a before(:each) or something similar, use this: request.env['HTTPS'] = 'on'. All tests work as expected now.

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

Sidebar

Related Questions

getting really close to running my first stored procedure. This one compiles but when
I am getting really confused with this concept: If I want to implement a
This is really getting to me now.I have a form that loads when the
I'm getting a really strange NPE exception. This is the offending code: private static
I'm not really getting how this code does what it does: char shellcode[] =
Sorry if this is a really basic question but it's been really getting to
I'm getting really tired of trying to figure out why this code works in
I have an NodeJS Express app that is getting really big in just one
I am getting really tired from this problem, and I do not know what
I'm using Compact Framework 3.5 / VS2008. I'm getting really odd behavior with TypeLoadException.

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.