RSpec Stubs The Object In Memory - Kevin Murphy
20-Sep-2024 110
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 #Stubs #Object #Memory #Kevin #Murphy #rspec https://www.rubyonrails.ba/link/rspec-stubs-the-object-in-memory-kevin-murphy