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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:15:07+00:00 2026-06-18T10:15:07+00:00

I have the following rspec2 test case for my controller new action: describe "GET

  • 0

I have the following rspec2 test case for my controller new action:

describe "GET #new" do
  it "should assign new project to @project" do
    project = Project.new
    get :new
    assigns(:project).should eq(project)
  end
end

and I’m getting the following error:

  1) ProjectsController GET #new should assign new project to @project
     Failure/Error: assigns(:project).should eq(project)
       
       expected: #<Project id: nil, name: nil, company_id: nil, created_at: nil, updated_at: nil>
            got: #<Project id: nil, name: nil, company_id: nil, created_at: nil, updated_at: nil>
       
       (compared using ==)
       
       Diff:#<Project:0x007f461c498270>.==(#<Project:0x007f461c801c90>) returned false even though the diff between #<Project:0x007f461c498270> and #<Project:0x007f461c801c90> is empty. Check the implementation of #<Project:0x007f461c498270>.==.
     # ./spec/controllers/projects_controller_spec.rb:19:in `block (3 levels) in <top (required)>'

Finished in 1.21 seconds
13 examples, 1 failure, 10 pending

Failed examples:

rspec ./spec/controllers/projects_controller_spec.rb:16 # ProjectsController GET #new should assign new project to @project

and when I use == instead on eq, I’m getting the following error

  1) ProjectsController GET #new should assign new project to @project
     Failure/Error: assigns(:project).should == project
       expected: #<Project id: nil, name: nil, company_id: nil, created_at: nil, updated_at: nil>
            got: #<Project id: nil, name: nil, company_id: nil, created_at: nil, updated_at: nil> (using ==)
       Diff:#<Project:0x007f461c4f5420>.==(#<Project:0x007f461c63b280>) returned false even though the diff between #<Project:0x007f461c4f5420> and #<Project:0x007f461c63b280> is empty. Check the implementation of #<Project:0x007f461c4f5420>.==.

What am I doing wrong here?

I’m on

  • Rails3
  • Rspec2
  • 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-18T10:15:09+00:00Added an answer on June 18, 2026 at 10:15 am

    You are creating a new project before accessing the new action, this is unnecessary. Your controller actually does that work for you already. The problem you are facing is that you have two new projects created (in your case you have created Project:0x007f461c498270 first and then Project:0x007f461c801c90, they have the same attributes but are different projects). This test should pass:

    describe "GET #new" do
      it "assigns a new Project to @project" do
        get :new
        assigns(:project).should be_a_new(Project)
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following request rspec test: describe CRUD do it should list users
I have the following RSpec example which is passing: describe UsersController do it should
I have the following test block in rspec: describe for signed-in users do let(:user)
My rspec title test is failing with: 1) HomeController Get 'index should have the
Still a bit new to rspec and can't get the following test to pass
I have the following action in my controller: def create @user = current_user @vin
I have following Rspec test: describe Productlimit do before(:each) do @productlimit = Factory.create(:productlimit, :user
I have the following test written in RSpec: describe '#create' do ... it 'redirects
I have the following rspec: require 'spec_helper' describe KnowledgesController do before (:each) do @knowledge
I have following nested objects. I am using @Valid for validation in my controller.

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.