[rspec-users] State Based vs. Behaviour Based Spec/Testing

Scott Taylor mailing_lists at railsnewbie.com
Sun Mar 25 02:37:15 EDT 2007

On Mar 25, 2007, at 2:25 AM, Pat Maddox wrote:

> On 3/24/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
>> 1.  Should you test protected and private methods in your specs?
> No.  You're specifying the behavior of an object as seen by the
> outside world.  Of course protected and private methods aren't
> available to the world, so why would you need to test them?  When
> you're doing state-based testing, just call a method and then verify
> that it returns the expected value or leaves your object in an
> expected state.

How about if your writing code that is *only* meant to be reused?   
E.g., you are writing some class which is only meant to be derived  
from (ruby metaprogramming - Spec'ing rails would be a good example)?



More information about the rspec-users mailing list