[rspec-devel] Fix for should == mock_model with ActiveRecord

aslak hellesoy aslak.hellesoy at gmail.com
Sat Sep 15 17:27:29 EDT 2007


Thanks for the patch,

Please put this in the tracker on Rubyforge so it stays on our radar.
It's guaranteed to be forgotten here on the list.

Aslak

On 9/15/07, Mike Mangino <mmangino at elevatedrails.com> wrote:
> I've attached a fix for the problems using specs like
>
> it "should belong to a user" do
>    @comment.user.should == @user
> end
>
> where @user is a mock_model.
>
>
> To summarize the issue,
>
> rspec mocks use a proxy (__mock_proxy) to delegate methods to. When
> on the LHS, == is delegated to the proxy. On the RHS, however, we are
> comparing the mock itself to the proxy. There are a couple of
> potential fixes.
>
> We could actually check to see if the RHS is a mock, and if so,
> compare our proxy to its proxy. Alternatively, we could take the
> naive solution and just reverse the comparison.
>
> I've attached the patch. I'm open to other suggestions, but I would
> really like to see this fixed in some form.
>
> Mike
>
>
>
> --
> Mike Mangino
> http://www.elevatedrails.com
>
>
>
>
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>
>


More information about the rspec-devel mailing list