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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:32:13+00:00 2026-06-04T06:32:13+00:00

I have that rspec test let(:document) { Document.new } let(:residue) { Residue.new } describe

  • 0

I have that rspec test

let(:document) { Document.new }
let(:residue)  { Residue.new  } 

describe "inner_residue=" do
  before do
    document.producer_residue = residue
  end

  it 'dont changes the producer residue' do
    expect { document.inner_residue = residue }.to_not change(document, :producer_residue)
  end
end

That outputs this error:

producer_residue should not have changed, but did change from #<Residue id: nil, un_code: nil, description: "res", created_at: ... > to #<Residue id: nil, un_code: nil, description: "res", created_at: ... >

As you see, there is the same residue.
The method its more complicated, but this one is a simplication that fails too:

def inner_residue=(other)
  return self.producer_residue = self.addressee_residue = nil unless other
  self.producer_residue = producer_residue
end

So… WTF?

Changing a residue for itself makes the assertion fails? I’ve checked if they are the same residue with ==, ===, eq? an its always true. I can’t understand whats wrong with this.

I’m using rspec 1.3 (its an rails 2.3 app, I cant upgrade to 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-04T06:32:15+00:00Added an answer on June 4, 2026 at 6:32 am

    RSpec has no problem with objects that are equal. The problem here is that in ActiveRecord, two unsaved models are not considered equal, even if they have all the same properties. You can see this if you run puts (Residue.new == Residue.new).

    You’ll have to save the Residue object for this to work.

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

Sidebar

Related Questions

My homecontroller has: def about() end And I have a rspec test that does
I have a rspec test that contains about 20 ExampleGroups(defined by the 'describe' keyword).
I'm using RSpec/Capybara as my test suite. I have some javascript that dynamically appends
If I have rspec test like following: context main context do before(:all) do #
I have the following request rspec test: describe CRUD do it should list users
I'm going through a tutorial that has suggested using rspec , but I have
I know I have that my connection to the database works, and a test
In C++11, we have that new syntax for initializing classes which gives us a
I am writing rspec test for my Cars class, and have a question regarding
I have a class with an instance method that runs RSpec using the %x[]

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.