On 9 Apr 2008, at 12:22, Andy Croll wrote:
> it "should increment quantity when it does find a product" do
>
> @cart_item1
> .should_receive(:increment_quantity).once.with(:no_args).and_return(2)
> @cart.should_receive(:find_item_by_name).twice.with("Brown
> Trousers").and_return(nil, @cart_item1)
> @cart.add_product(@product1)
> @cart.add_product(@product1)
> @cart.items.should have(1).item
> end
> end
>
> Which seems to work. I'm right?
Looks good. Don't forget that with that extra mocking your coverage
has dropped on CartItem so you'll need to ensure that it's correctly
tested also.
Cheers
Chris
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users