Hi,<br><br>I'm a bit stuck with mocking a unit test of a join model with regards to a validates_uniqueness_of clause.<br><br>I have<br><br>class Book < AR:B<br> has_many :clippings<br> various validates_presence_of etc
<br>end<br><br>class Clip < AR:B<br> has_many :clippings<br> various validates_presence_of etc<br>end<br><br>class Clipping < AR:B<br> belongs_to :book<br> belongs_to :clip<br> <br> validates_uniqueness_of :clip_id, :scope => :book_id
<br>end<br><br>What I want to do is just confirm that the validates uniqueness_of clause is set and functioning correctly in the spec for the clipping model. <br><br>So if I was using fixtures I would do something like<br>
<br>it "should not allow duplicate clips in the same book" do<br> clip = clips( :some_clip )<br> book = books( :some_book )<br><br> lambda do<br> clipping = Clipping.create( :clip => clip, :book => book )
<br> end.should change( Clipping, :count ).by( 1 )<br> <br> lambda do<br> clipping = Clipping.create( :clip => clip, :book => )<br> clipping.should_not be_valid<br> end.should_not change( Clipping, :count )
<br><br>end<br><br>Any hints as to how to do this without using fixtures?<br><br>Cheers<br>Daniel<br><br><br><br><br><br>