Hi,
On Sat, Jan 8, 2011 at 01:58, Ants Pants <[email protected]> wrote:
> I thought that the controller.stub(:require_member).and_return(member) would
> suffice for the require_member stuff but I'm obviously wrong. I've even
> replaced the member for @member in my spec but to no avail.
> Here's the describe example ....
> describe "PUT edit" do
> context "Product cut-off has passed" do
> let(:member) { mock_model(Member).as_null_object }
> let(:product) { mock_model(Product).as_null_object }
> ## I just want it to create a @product object from
> it "creates a product object" do
> controller.stub(:require_member).and_return(member)
> member.should_receive(:products)
> get :edit, :id => "1"
> end
> end
> end
> If anyone would be able to untangle me, I'd be greatly appreciative.
Your stub returns member, but require_member sets the @member instance
variable. Try modifying your stub to something like this (untested):
controller.stub(:require_member) { assigns(:member) = member }
HTH,
Mike
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users