Oh, and one follow-up, the app works how I expect it to work if I run through the browser.<br><br><div class="gmail_quote">On Jan 23, 2008 9:41 AM, Corey Haines &lt;<a href="mailto:coreyhaines@gmail.com">coreyhaines@gmail.com
</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">All,<br><br>I&#39;m missing something simple, I think. I am writing a spec to say that my CouponController should create a new coupon from the form parameters, then set the current user. Here&#39;s the spec:
<br><br>describe CouponController, &quot;When posting to save_coupon&quot; do
<br><br>&nbsp; before(:each) do<br>&nbsp;&nbsp;&nbsp; @expectedName = &quot;pepper&#39;s&quot;<br>&nbsp;&nbsp;&nbsp; @expectedAmount = 5<br><br>&nbsp;&nbsp;&nbsp; coupon = mock_model Coupon<br>&nbsp;&nbsp;&nbsp; current_user = mock_model User<br>&nbsp;&nbsp;&nbsp; controller.stub!(:current_user).and_return(current_user)
<br>&nbsp;&nbsp;&nbsp; Coupon.should_receive(:new).with({&quot;name&quot;=&gt;@expectedName,&quot;amount&quot;=&gt;@expectedAmount}).and_return(coupon)<br>&nbsp;&nbsp;&nbsp; coupon.should_receive(:user).with(current_user)<br>&nbsp;&nbsp;&nbsp; coupon.should_receive
(:save)
<br>&nbsp; end<br><br>&nbsp; it &quot;should tell the Coupon model to create a new coupon with the given parameters and save&quot; do<br>&nbsp;&nbsp;&nbsp; post &#39;save_coupon&#39;,{:coupon=&gt;{:name=&gt;@expectedName,:amount=&gt;@expectedAmount}}
<br>&nbsp; end<br><br>Here&#39;s the controller method:<br><br>&nbsp; def save_coupon<br>&nbsp;&nbsp;&nbsp; coupon = Coupon.new(params[:coupon])<br>&nbsp;&nbsp;&nbsp; coupon.user = current_user<br>&nbsp;&nbsp;&nbsp; coupon.save<br>&nbsp;&nbsp;&nbsp; redirect_to_index &quot;Coupon Added!&quot;
<br>&nbsp; end<br><br>And, I get the following failure:<br><br>Mock &#39;Coupon_1008&#39; received unexpected message :user= with (#&lt;User:0x221a3e8 @name=&quot;User_1009&quot;&gt;)<br><br>I&#39;m sure that I&#39;m missing something very simple, but I&#39;ve been staring at it for too long.
<br><br>(also, if anyone has commented on my style, please feel free to mention it, as I&#39;m still adjusting my mind to rspec)<br><br>Oh, versions, I almost forgot:<br>rails 2.0.2<br>rspec(_on_rails) plugins just updated from current a couple days ago, not totally sure how to get the versions of the plugins
<br><br><br>Thanks.<br>-Corey<br clear="all"><font color="#888888"><br>-- <br><a href="http://www.coreyhaines.com" target="_blank">http://www.coreyhaines.com</a><br>The Internet&#39;s Premiere source of information about Corey Haines
</font></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.coreyhaines.com">http://www.coreyhaines.com</a><br>The Internet&#39;s Premiere source of information about Corey Haines