How to test the following example?
class Post < ActiveRecord::Base
belongs_to :discussion, touch: true
end
You can set a message expectation:
it "should touch the discussion" do
post = Factory.build(:post)
post.discussion.should_receive(:touch)
post.save!
end
This examples uses Factory Girl, but you could use fixtures or mocks as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With