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

Posted by 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
Posted by Pat Maddox (Guest)
on 2011-09-27 00:06
(Received via mailing list)
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.