RSpec Stubs The Object In Memory - Kevin Murphy

This test fails. We put a breakpoint in our test. We confirm that a post with the same database ID as draft does get the publish method called on it.Even though these objects pass the equality check, the issue is that they are not the same object in memory. Compare the object_id of the draft object to the object pulled out of the database. They’re different. The post published in DraftPost.publish_all does not have the stub applied to it.The stub operates on that draft object in memory, and only that object. Even though the other object is equal to the draft object, it is not the same as the draft object. Because of that, our assertion does not pass.
RSpec Stubs The Object In Memory - Kevin Murphy #ruby #rubydeveloper #rubyonrails #rspec https://rubyonrails.ba/single/rspec-stubs-the-object-in-memory-kevin-murphy

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles