Ahh, got it! Thanks alot guys.

On Aug 25, 2:09 am, Christoph Schiessl <[email protected]> wrote:
> On Aug 25, 2009, at 1:09 AM, jg wrote:
>
>
>
>
>
> > I have a very fairly simple spec
>
> > it "should assign an instance variable" do
> >   get 'new'
> >   assigns[:city].should == City.new
> > end
>
> > In my controller
>
> > def new
> > �...@city = City.new
> > end
>
> > but when I run it, I get
>
> > 'CitiesController GET 'new' should assign an instance variable' FAILED
> > expected: #<City id: nil, name: nil, created_at: nil, updated_at:
> > nil>,
> >         got: #<City id: nil, name: nil, created_at: nil, updated_at:
> > nil> (using ==)
>
> > Those two things seem to be equal, am I wrong there?
> > _______________________________________________
> > rspec-users mailing list
> > [email protected]
> >http://rubyforge.org/mailman/listinfo/rspec-users
>
> Your controller is okay.
>
> Try to change your test like this:
>
> it "should assign an instance variable" do
>    City.should_receive(:new).and_return(@city = mock_model(City))
>    get 'new'
>    assigns[:city].should == @city
> end
>
> That way, you are comparing the same object instance => it should pass.
>
> Best regards,
> Christoph
>
> _______________________________________________
> 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