Do not confuse object and content equality

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the testing category.

Last Updated: 2024-11-23

I had this in a test but it failed

notes_file.data_file_name = "buffy.docx"
new_name = "buffy.docx"
expect(notes_file.data_file_name).to be(new_name)

All this despite, despite the strings having the content.

The issue was that be tests for object equality - the exact same string (===), whereas I just wanted to test on contents eq.

This fix worked:

new_name = "buffy.docx"
expect(notes_file.data_file_name).to eq(new_name)