I can't get the timecop to work in my application.
I hope you guys know what's wrong. I've used Ryans code.
What I see is that the reloaded object has nil for the password_reset_sent_at attribute.
I get:
1) User#send_password_reset saves the time the password reset was sent
Failure/Error: user.reload.password_reset_sent_at.should eq(Time.zone.now)
expected Fri, 31 Dec -0001 23:40:28 UTC +00:00
got nil
(compared using ==)
# ./spec/models/user_spec.rb:24:in `block (3 levels) in <top (required)>'
ruby
# user_spec.rb
it "saves the time the password reset was sent"doTimecop.freeze
user.send_password_reset
puts 'printing user password_reset_sent_at'
p user.password_reset_sent_at
puts 'printing reloaded user password_reset_sent_at'
p user.reload.password_reset_sent_at
puts 'printing last user password_reset_sent_at'
p User.last.password_reset_sent_at
user.reload.password_reset_sent_at.should eq(Time.zone.now)
end# user.rb (model)defsend_password_reset
generate_token(:password_reset_token)
self.password_reset_sent_at = Time.zone.now
save!
UserMailer.password_reset(self).deliver
end
stdout:
printing user password_reset_sent_at
Fri, 31 Dec -0001 23:40:28 UTC +00:00
printing reloaded user password_reset_sent_at
nil
printing last user password_reset_sent_at
nil
I've been trying and trying to start with testing, but it's very easy to get lost. Thanks for this great railscast! I will definately pick up on testing again!
I watch all your eps and love them!
I can't get the timecop to work in my application.
I hope you guys know what's wrong. I've used Ryans code.
What I see is that the reloaded object has nil for the password_reset_sent_at attribute.
I get:
1) User#send_password_reset saves the time the password reset was sent
Failure/Error: user.reload.password_reset_sent_at.should eq(Time.zone.now)
stdout:
printing user password_reset_sent_at
Fri, 31 Dec -0001 23:40:28 UTC +00:00
printing reloaded user password_reset_sent_at
nil
printing last user password_reset_sent_at
nil
Hi Ryan,
I've been trying and trying to start with testing, but it's very easy to get lost. Thanks for this great railscast! I will definately pick up on testing again!
I watch all your eps and love them!