[rspec-users] More on collection proxies

Matthijs Langenberg mlangenberg at gmail.com
Sat Jan 27 06:59:36 EST 2007

Why shouldn't private methods be tested? I use Object#send all the
time to test private methods, otherwise I've got the idea the step to
implement the spec is too big, for example look at the specs of my
SMSer project (http://pastie.caboo.se/36044).

On 1/26/07, Jay Levitt <lists-rspec at shopwatch.org> wrote:
> David Chelimsky wrote:
> >> Jay Levitt wrote:
> >>
> >> validates_presence_of is a bad example, because the two methods are
> >> practically interchangeable.  But consider a validation that uses a
> >> regex to verify a legal IP address.  Do you want your specs to repeat
> >> the regex, or do you want to test various legal and illegal IP-address
> >> strings and see what breaks?  To me, it's the second one that's actually
> >> testing the behavior of the application.
> >
> > Another view would be that the Regexp is a separate component that
> > you'd want to test separately from the use of that component. So the
> > test that your model validates_format_of using a Regexp uses the right
> > one and then have other tests just for that Regexp.
> I'd counter that the Regexp is essentially a private method that
> shouldn't be tested.  It's never directly used by the outside world;
> only the validation is.
> Jay
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list