[rspec-users] How much test data to use in specs
Nick Hoffman
nick at deadorange.com
Thu Aug 28 12:37:51 EDT 2008
On 2008-08-28, at 08:31, David Chelimsky wrote:
> On Wed, Aug 27, 2008 at 2:24 PM, Nick Hoffman <nick at deadorange.com>
> wrote:
>> On 2008-08-27, at 14:46, David Chelimsky wrote:
>>>
>>> If you want to (not necessarily advising this, but I've seen it
>>> done) you
>>> can do this:
>>>
>>> ['!','(',')','&'].each do |char|
>>> it "can't have #{char}" do
>>> ...
>>> end
>>> end
>>>
>>> That makes the output very verbose, but the spec file is easy to
>>> grok.
>>
>> Hi David. I ended up creating valid and invalid test data, as well
>> as a
>> method to iterate over them and write the descriptions and examples
>> for me.
>> You can have a look at it at http://pastie.org/261175 . If you have
>> any
>> suggestions for improvements, I'd love to hear them.
>
> Hey Nick,
>
> I can definitely see some value in this, though there are a few things
> that I'd do differently. Have a look at http://pastie.org/261642 and
> let me know if you have any questions/comments. The only thing I'm not
> sure about is the actual method name - it's not speaking to me, but
> I'm at a loss for a better one. Maybe after some coffee ...
>
> Cheers,
> David
Thanks for taking a look and making some suggestions, David. Much
appreciated. I've incorporated some of them into the method.
The method's name was "describe_property_attributes" because it was
being used to describe the Property (as in "real estate") model in my
application. I've just finished abstracting it out so that it can now
be used with any model class. If you're interested, I've pasted it at http://pastie.org/261829
More information about the rspec-users
mailing list