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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:49:34+00:00 2026-06-04T04:49:34+00:00

I am trying to write a RSpec before filter to log a user in.

  • 0

I am trying to write a RSpec before filter to log a user in. I have a products controller. In order to view products, a user must be logged in. I added a login method to spec/support/utilities like so:

def login(user)
  post login_path, email: user.email, password: "password"
end

Then I called the method in a before filter in my spec/controllers/products test:

before :each do
  user = FactoryGirl.create(:user)
  login(user)
end

When I run the test I get the following error:

The action '/login' could not be found for ProductsController

I have a route for /login and my user authentication is simple – just like Railscasts #250 Authentication from Scratch. What am I missing?

  • 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-04T04:49:36+00:00Added an answer on June 4, 2026 at 4:49 am

    If this is a controller spec, then the problem is that Routes are not available when unit testing controllers. The point is to test in isolation, which means no routes

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

Sidebar

Related Questions

I'm trying to write an rspec for my Rooms controller to test permissions with
Im trying to write something to get my images to show correctly. I have
I am trying to write an interface between RSPEC (ruby flavoured BDD) and a
I'm trying to write a custom RSpec matcher for cucumber. I require cucumber/rails/rspec in
I'm new to Rspec and trying to set up a test for a User
I'm trying write a query to find records which don't have a matching record
I have a check_user_access_control before_filter in my ApplicationController that checks the logged user's roles
Using Rails 3.0.5, RSpec 2 and Capybara 0.4.1.2 and I'am trying to write a
I'm trying to write spec for inherited_resources controller. I decided to mock all integration
I'm new to rails and trying to write my first app. I have a

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.