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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:13:53+00:00 2026-05-27T05:13:53+00:00

I have a spec: it should redirect to the log_books_controller#new action when a user

  • 0

I have a spec:

it "should redirect to the log_books_controller#new action when a user logs in who owns zero LogBooks" do    
  visit '/auth/facebook'

  response.should redirect_to new_log_book_path
end

and it fails, with the following error:

1) LogBooksController should redirect to the log_books_controller#new action when a user logs in who owns zero LogBooks
     Failure/Error: response.should redirect_to new_log_book_path
       Expected response to be a <:redirect>, but was <200>.
     # ./spec/controllers/log_books_controller_spec.rb:7

But according to my log/test.log file, there IS actually a redirect. Am I missing something here? I feel like the spec should be passing.

log/test.log file:

Started GET "/auth/facebook/callback" for 127.0.0.1 at Thu Nov 24 10:24:01 -0600 2011
  Processing by SessionsController#create as HTML
  Parameters: {"provider"=>"facebook"}
  User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."uid" = '1234' AND "users"."provider" = 'facebook' LIMIT 1
   (0.0ms)  SAVEPOINT active_record_1
   (0.1ms)  SELECT 1 FROM "users" WHERE ("users"."uid" = '1234' AND "users"."provider" = 'facebook') LIMIT 1
  SQL (1.3ms)  INSERT INTO "users" ("created_at", "name", "nickname", "provider", "uid", "updated_at") VALUES (?, ?, ?, ?, ?, ?)  [["created_at", Thu, 24 Nov 2011 16:24:01 UTC +00:00], ["name", "Foo Man"], ["nickname", "fooman"], ["provider", "facebook"], ["uid", "1234"], ["updated_at", Thu, 24 Nov 2011 16:24:01 UTC +00:00]]
   (0.1ms)  RELEASE SAVEPOINT active_record_1
   (0.1ms)  SELECT COUNT(*) FROM "log_books" WHERE "log_books"."user_id" = 17
Redirected to http://rpglogger.com/log_books/new
Completed 302 Found in 35ms

I’ve also tried adding a debugger line after the visit '/auth/facebook' line, and at that point in the spec response.code returns :success, so I see why the test is failing, but what I don’t know is why the response is set to :success when the log clearly shows a redirect.

  • 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-05-27T05:13:54+00:00Added an answer on May 27, 2026 at 5:13 am

    My guess is that Capybara follows the redirect and fetches the page specified by the location in the 302 response, which generates the 200 status code.

    You could handle this by either testing for the content of the page at the redirected location, or using a controller spec with rack-test instead of Capybara.

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

Sidebar

Related Questions

I have following spec to test controller method: context #create do it should redirect
I have my google news sitemap, which according to google's spec, should contain articles
i have created an rspec test like : it should redirect to '/tavern' with
I'm starting on a fresh new project--should I look at my spec and decide
I have a spec in my current project that requires us to advise the
I have almost the worst spec in the world. An application that exists and
Hi I have a file try.SPEC. This file contains a word Version: 1.0.0.1 .
In a branch spec, I have the following view: //depot/dev/t/a/g/... //depot/dev/t/r/g/... -//depot/dev/t/a/g/p/o*/... //depot/dev/t/r/g/p/... Perforce
The JDBC 3.0 spec talks about Connection (and Prepared Statement) pooling. We have several
Let's say that I have an Erlang function, with spec. -spec foo(integer(), string()) ->

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.