I have the following
it 'should assign a new profile to user' do
get :new
assigns(:user_profile).should ==(Profile.new)
end
But it’s not working. I’ve tried ‘eql?’ and ‘equal?’ respectively. How do I compare it in order to know if the contents of @user_profile is Profile.new?
I used to do a workaround doing a .class of the assigned variable, checking if it’s Profile but I want to stop with these bad practices.
Thanks.
The problem here is that
Object.newinvoked twice by design creates two different objects, which are not equal.One thing you can do here is
Now you’re not actually creating a new profile when the controller action is invoked, but you are still testing that
Profileis receivingnew, and you’re testing that the return value of that method is being assigned by the controller to@user_profile.