[rspec-users] Testing that named_scope is defined

Pat Maddox pergesu at gmail.com
Tue May 13 20:25:54 EDT 2008


On 5/13/08, Pat Maddox <pergesu at gmail.com> wrote:
> On 5/13/08, Jonathan Linowes <jonathan at parkerhill.com> wrote:
> >
> > On May 13, 2008, at 6:39 PM, Helder Ribeiro wrote:
> >
> > > I'm not actually trying to test its behavior,
> >
> >
> > quick! Duck! INCOMING...!!!!!
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
>
> I wonder why OP doesn't create two records, call #most_recent, and
> verify that the record returned is the one with the larger timestamp.
>
> If the code is "not yours" (and I think you ought to clarify what you
> mean by that), then you should be testing it at a higher level instead
> of directly.
>
> Pat
>

The other answer to your question is that #method_defined looks at the
instance methods. To do what you want, you should do

Foo.singleton_methods.should include("most_recent")

Pat


More information about the rspec-users mailing list