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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:21:09+00:00 2026-05-20T20:21:09+00:00

Using Rails 3.0.5, RSpec 2 and Capybara 0.4.1.2 and I’am trying to write a

  • 0

Using Rails 3.0.5, RSpec 2 and Capybara 0.4.1.2 and I’am trying to write a controller spec for my SessionsController#new action.

it "assigns the empty session to a variable" do
  get :new
  assigns(:session).should == ActiveRecord::Base::Session.new
end

I’m using the ActiveRecord::Base namespace as it seems to clash with the Capybara Session class when I don’t.

Here is the SessionsController:

class SessionsController < ApplicationController
  def new
     @session = Session.new
  end
end

RSpec doesn’t seem to understand these are the same objects. Here is what my test returns:

 Failure/Error: assigns(:session).should == ActiveRecord::Base::Session.new
   expected: #<Session id: nil, session_id: nil, data: nil, created_at: nil, updated_at: nil>
        got: #<Session id: nil, session_id: nil, data: nil, created_at: nil, updated_at: nil> (using ==)
   Diff:
 # ./spec/controllers/sessions_controller_spec.rb:17:in `block (3 levels) in <top (required)>'

Any hints?

  • 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-20T20:21:10+00:00Added an answer on May 20, 2026 at 8:21 pm

    The problem is that if you do

    ActiveRecord::Base::Session.new == ActiveRecord::Base::Session.new
    

    You would get false, as both these objects have a separate object_id.

    Try this:

    assigns(:session).should be_an(ActiveRecord::Base::Session)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a spec for a controller in Rails 3 project using RSpec and
I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1, capybara-1.1.2 and factory_girl-2.6.3. I have
I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1 and capybara-1.1.2 with the Selenium
I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1 and capybara-1.1.2 with the Selenium
Using Rails v2.1, lets say you have an action for a controller that is
I'm writing an integration test for a rails application using Capybara within Rspec. After
I am using Capybara in combination with rspec for integration testing of rails apps.
I'm still on Rails 2.3.x and using Rspec, Capybara and Steak to do some
I'm trying to test a link that calls a controller action using ajax. Essentially,
I'm using Capybara 1.1.2, Rails 3.1.3, rspec-rails 2.9.0, and Ruby 1.9.3p0. Assume an app

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.