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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:48:03+00:00 2026-05-27T03:48:03+00:00

I have a Posts controller and I have just installed Devise to add some

  • 0

I have a Posts controller and I have just installed Devise to add some authentication quickly and easily. Before I installed Devise, I had created some tests for the ‘new’ action of my Posts controller. After installing Devise, my tests were failing until i added the

config.include Devise::TestHelpers, :type => :controller

line to my spec_helper.rb file.

I also have the line

before_filter :authenticate_user!, :except => [:show, :index]

in my PostsController.

Now when I run my tests, they all pass except these 2:

it "should be successful" do
     get :new
     response.should be_success
  end

  it "should have the right title" do
     get :new
     response.should have_selector('title', :content => @base_title + " | New post")
  end

I’m using Factory girl as well. The error is cause by the before_filter except parameter. I need to be able to sign in the user in rspec with a factory user. How do I sign the Factory user in from within the Rspec controller test? How do I define the Factory user?

I have tried this in my factories.rb:

Factory.define :user do |user|  
  user.name                  "Test User"
  user.email                 "user@example.com"
  user.password              "password"
  user.password_confirmation "password"
end

But then I get the error:

NoMethodError:
   undefined method `password_salt=' for #<User:0x00000103cac958>

Any help would be much appreciated. Thanks.

  • 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-27T03:48:03+00:00Added an answer on May 27, 2026 at 3:48 am

    I highly recommend removing your controller tests and using Cucumber stories instead — RSpec is not as convenient for testing user-facing stuff as Cucumber is.

    In Cucumber, you’d want to log in through the UI to mimic exactly what the user will do. I would tend to do the same thing in a controller spec, though some people might prefer mocking things out instead.

    As for undefined method password_salt=, did you migrate your test DB?

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

Sidebar

Related Questions

I just installed Ruby on Rails and created a scaffold called posts . RoR
I just successfully installed WysiHat in my rails blog. Seems that the 'add a
I have the following controller view method for my posts: function view($id = null)
Using Ruby on Rails, I have created a blog. The blog has posts, and
I have a POST controller action like: if (ModelState.IsValid) { try { //.. save
At the moment I have a jQuery do a POST to a Controller which
I have a controller defined as: [AcceptVerbs(HttpVerbs.Post)] public JsonResult PostMoreData(DataContracts.Address address, DataContracts.GeoLocation geoLocation) {
I have a controller method with the following signature: [AcceptVerbs(HttpVerbs.Post)] public ActionResult UpdateValues(int id,
I have a controller insert action: <AcceptVerbs(HttpVerbs.Post)> _ Function InsertObject(<Bind(Exclude:=Id)> <ModelBinder(GetType(CustomModelBinder))> ByVal object As
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public

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.