Forum: RSpec how to test identical behavior without being redundant?

648553f5c693d93c9ea2e042857ad22c?d=identicon&s=25 Patrick Collins (patrick99e99)
on 2011-09-26 23:37
(Received via mailing list)
I've got many models that have this declared:
  has_many :notifications, :as => :notifiable, :dependent => :destroy


...  And so I have many model specs such as:

describe Reply do

  it "should eliminate any associated notification records when
destroyed" do
    reply = create_reply
    reply.notifications.should_not be_blank

    reply.destroy
    reply.notifications.reload.should be_blank
  end

end

describe Post do

  it "should eliminate any associated notification records when
destroyed" do
    post = create_post
    post.notifications.should_not be_blank

    post.destroy
    post.notifications.reload.should be_blank
  end

end

etc...

Is there an ideal way to dynamically generate this for any models that
respond
to notificaions so that I don't have redundant noisy tests?


Thanks.

Patrick J. Collins
http://collinatorstudios.com
112ce0021890da348d6e337b1d94b9ef?d=identicon&s=25 Pat Maddox (Guest)
on 2011-09-27 00:06
(Received via mailing list)
This topic is locked and can not be replied to.