[rspec-devel] stubs

David Chelimsky dchelimsky at gmail.com
Tue Oct 3 16:12:21 EDT 2006


On 10/3/06, David Chelimsky <dchelimsky at gmail.com> wrote:
> On 10/3/06, Brian Takita <brian.takita at gmail.com> wrote:
> > I fixed it. I noticed that you where using
> > assigns[:person].should_be person
> > instead of
> > assigns(:person).should_be person
>
> Doh!
>
> >
> > Anyways, the context looks like:
> >
> > context "/person/show/3" do
> >    fixtures :people
> >   controller_name :person
> >
> >   specify "should get person with id => 3 from model" do
> >      person = mock("person")
> >
> >
> > Person.should_receive(:find).with("3").and_return(person)
> >     #Person.stub!(:find).with(person)
> >      get 'show', :id => 3
> >
> >      assigns(:person).should_be person
> >   end
> >  end
>
> OK - There's still a problem, and it turns out the problem is a bit sinister.
>
> Here's the test that exposes the problem:
>
> class EmptyClass
> end
> class SubclassOfEmptyClass
> end
>
> def test_reset_proxied_methods_should_revert_to_original_when_method_already_exists_in_base_class
>   class << EmptyClass
>     def foobar
>       :original_value
>     end
>   end
>   SubclassOfEmptyClass.stub!(:foobar).with(:return_value)
>   SubclassOfEmptyClass.reset_proxied_methods!
>   assert :original_value, SubclassOfEmptyClass.foobar
> end
>
> I've got that test committed and I'm working on the problem this
> afternoon. I'll follow up when it's resovled!

OK - this works now. I've committed the changes to the stubs branch.

I'll follow up in a separate email re: next steps.

David


More information about the rspec-devel mailing list