[rspec-users] describe AddressesController, "handling GET /addresses" do
Pat Maddox
pergesu at gmail.com
Wed Nov 21 04:35:48 EST 2007
On Nov 21, 2007 1:35 AM, Pat Maddox <pergesu at gmail.com> wrote:
> On Nov 21, 2007 1:15 AM, Sahyoun <osahyoun at gmail.com> wrote:
> > Thanks. That helped. I now have:
> >
> > before do
> > @address = mock_model(Address)
> > @company = mock_model(Company)
> > Company.stub!(:find_by_id).and_return(@company)
> >
> > @company.stub!(:addresses).and_return(@addresses)
> > end
> >
> >
> > with only one error remaining:
> >
> > 'AddressesController handling GET /addresses should assign the found
> > addresses for the view' FAILED
> > expected: [nil],
> > got: nil (using ==)
> >
> > Spec:
> > it "should assign the found addresses for the view" do
> > do_get
> > assigns[:addresses].should == [@addresses]
> > end
> >
> >
> > I thought @company.stub!(:addresses).and_return(@addresses) would be
> > sufficient for the above to pass. My understanding of mocking and stubbing
> > is sketchy at the moment. Any explanation on how to get this to pass would
> > be appreciated.
>
> @company.stub!(:addresses).and_return([@addresses])
>
> If you're expecting an array, then you need the stub to return an array.
>
> Pat
>
Guh, sorry, should have looked a bit more closely:
@company.stub!(:addresses).and_return([@address])
Pat
More information about the rspec-users
mailing list