jeudi 19 février 2015

a == b returns true, a.attribute == b.attribute returns false; ruby

I'm testing this line of a controller:



@channel.update_attribute(:active, true)

expect(channel.active).to be_true fails (my variable is named 'channel')
expect(assigns[:channel].active).to be_true passes

assigns[:channel] == channel
=> true

assigns[:channel].active == channel.active
=> false

assigns[:channel].active == channel.reload.active
=> true


I don't understand why the comparison operator says that assigns[:channel] == channel, but that their "active" attribute is different.


Aucun commentaire:

Enregistrer un commentaire