[rspec-users] Constraints / Global requirements

Steve Molitor stevemolitor at gmail.com
Thu Jan 8 15:15:23 EST 2009


Sorry.  I was responding to this from Pat Maddox:
>> Another idea I had is to potentially introduce a ValidatedDate class,
>> and then your "should be a valid date" step checks that the field is
>> an instance of ValidatedDate.  That has the affect of ensuring that
>> people use your validation code in those spots where you want them to.
>>  How does that sound?

Steve

On Thu, Jan 8, 2009 at 12:52 PM, Zach Dennis <zach.dennis at gmail.com> wrote:

> On Thu, Jan 8, 2009 at 11:32 AM, Steve Molitor <stevemolitor at gmail.com>
> wrote:
> > I guess that would work.
>
> What would work? You top-posted, any way you can inline post to the
> spot you're responding to? Sorry to be an email nazi, but you're
> making me do all of the work for wanting to hopefully participate in
> this thread,
>
> Zach
>
> > But a method would probably work too, if I'm
> > understanding correctly (often a bad assumption!).   I.e. /"(.*)" should
> be
> > a valid date/ would call valid_date?(date), or something.  Anyway, yes
> that
> > sounds promising.
> > Steve
> >
> >
> > On Wed, Jan 7, 2009 at 8:09 PM, Pat Maddox <pergesu at gmail.com> wrote:
> >>
> >> Another idea I had is to potentially introduce a ValidatedDate class,
> >> and then your "should be a valid date" step checks that the field is
> >> an instance of ValidatedDate.  That has the affect of ensuring that
> >> people use your validation code in those spots where you want them to.
> >>  How does that sound?
> >>
> >> Pat
> >>
> >> On Wed, Jan 7, 2009 at 5:58 PM, Steve Molitor <stevemolitor at gmail.com>
> >> wrote:
> >> > Yeah I thought of something like that.  Actually we do something like
> >> > that
> >> > in one step now that I think about it.  But I really wanted to execute
> >> > the
> >> > same exact date feature (for example) doc that the user verified to
> make
> >> > sure nothing got lost in translation.  Which I could do if I
> >> > programmatically ran the date feature file inside the Given /(.*) date
> >> > is
> >> > vaild/ step.  But all those results would clutter up the report
> output.
> >> >  I
> >> > like your approach best: simple and doesn't require a funky technical
> >> > solution.
> >> > Steve
> >> >
> >> > On Wed, Jan 7, 2009 at 7:26 PM, Pat Maddox <pergesu at gmail.com> wrote:
> >> >>
> >> >> > From a testing perspective it would be nice if cucumber could
> >> >> > actually
> >> >> > run
> >> >> > the date validation feature everywhere it applies.
> >> >>
> >> >> Sure, and you can have a step like
> >> >>
> >> >> Given birth date is valid
> >> >>
> >> >> Given /(.*) date is valid/ do |field|
> >> >>  TestData.valid_dates.each do |date|
> >> >>    @it.send "#{field}_date=", date
> >> >>    @it.should be_valid
> >> >>  end
> >> >>
> >> >>  TestData.invalid_dates.each do |date|
> >> >>    @it.send "#{field}_date=", date
> >> >>    @it.should_not be_valid
> >> >>  end
> >> >> end
> >> >>
> >> >> That gets you technical validation everywhere you need it.  Then you
> >> >> have another individual feature file that describes date formats.
> >> >>
> >> >>
> >> >> > P.S. Date validation really isn't that important in my application;
> >> >> > that's
> >> >> > just an example.  A real example would be the sales tax calculation
> >> >> > in
> >> >> > the
> >> >> > leasing app I worked on.  That was very important, it was a global
> >> >> > requirement with some important exceptions.  But I think your
> >> >> > approach
> >> >> > would
> >> >> > have worked there as well.
> >> >>
> >> >> Same ideas apply.
> >> >>
> >> >> Pat
> >> >>
> >> >> p.s. I didn't realize you were also the author of the other thread I
> >> >> linked to :)
> >> >> _______________________________________________
> >> >> rspec-users mailing list
> >> >> rspec-users at rubyforge.org
> >> >> http://rubyforge.org/mailman/listinfo/rspec-users
> >> >
> >> >
> >> > _______________________________________________
> >> > rspec-users mailing list
> >> > rspec-users at rubyforge.org
> >> > http://rubyforge.org/mailman/listinfo/rspec-users
> >> >
> >> _______________________________________________
> >> rspec-users mailing list
> >> rspec-users at rubyforge.org
> >> http://rubyforge.org/mailman/listinfo/rspec-users
> >
> >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
>
>
>
> --
> Zach Dennis
> http://www.continuousthinking.com
> http://www.mutuallyhuman.com
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090108/ca9b4cbb/attachment-0001.html>


More information about the rspec-users mailing list