Hi,<br><br>I&#39;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 &lt; AR:B<br>&nbsp; has_many :clippings<br>&nbsp; various validates_presence_of etc
<br>end<br><br>class Clip &lt;&nbsp; AR:B<br>&nbsp; has_many :clippings<br>&nbsp; various validates_presence_of etc<br>end<br><br>class Clipping &lt; AR:B<br>&nbsp; belongs_to :book<br>&nbsp; belongs_to :clip<br>&nbsp; <br>&nbsp; validates_uniqueness_of :clip_id, :scope =&gt; :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.&nbsp; <br><br>So if I was using fixtures I would do something like<br>
<br>it &quot;should not allow duplicate clips in the same book&quot; do<br>&nbsp; clip = clips( :some_clip )<br>&nbsp; book = books( :some_book )<br><br>&nbsp; lambda do<br>&nbsp;&nbsp;&nbsp; clipping = Clipping.create( :clip =&gt; clip, :book =&gt; book )
<br>&nbsp; end.should change( Clipping, :count ).by( 1 )<br>&nbsp;<br>&nbsp; lambda do<br>&nbsp;&nbsp;&nbsp; clipping = Clipping.create( :clip =&gt; clip, :book =&gt; )<br>&nbsp;&nbsp;&nbsp; clipping.should_not be_valid<br>&nbsp; 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>