Thanks for your reply, I did move the code to before

before(:each) do
  Logo.stub!(:new).and_return(mock_logo(:save => true, :company= => nil))
end

2008/10/30 Hans de Graaff <[EMAIL PROTECTED]>

> On Thu, 2008-10-30 at 14:47 +0800, Leon Du wrote:
> > The spec
> >
> --------------------------------------------------------------------------------------------------------------------------------------------------------
> > it "should expose a newly created logo as @logo" do
> >   Logo.should_receive(:new).with({'these' =>
> > 'params'}).and_return(mock_logo(:save => true))
> >   Logo.should_receive(:company=).with(mock_model(Company))
> >   post :create, :logo => {:these => 'params'}
> >   assigns(:logo).should equal(mock_logo)
> > end
>
> The instance of Logo should receive the company= method, not the class,
> so:
>
> @logo = mock_logo
> Logo.should_receive(:new).and_return(@logo)
> @logo.should_receive(:company=)
>
> I would probably use stub! instead here and move this code into a before
> block, and just keep the post and assigns lines in the it block.
>
> Hans
>
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to