On Aug 25, 2009, at 6:39 PM, Joaquin Rivera Padron wrote:
hey there,
I have a question that may be raised from some misunderstanding of
my current problem. But the answer might well serve me for other
things.
The issue is I would like to be able to metaprogramatically (this
may be a bad chosen word) generate spec examples to check a model is
valid against its 'validates_presence_of' declarations, do something
like http://gist.github.com/175083
where you iterate over an array of known required attributes and
then generate the typical %{it 'should require required attribute'}
spec example. That's easy with shoulda, but in this case the
validations are contextual, they have the :if => xxx option, and
shoulda doesn't support them (yet)
If not answering my former question: how you attack normally this
problem? any ideas? I know I could go the common finger-hurting way
of writing lots of alike examples :-) and also that there are
concerns regarding spec-ing my specs and mostly when using this kind
of artifacts, but well...
what would you do?
I use a series of "shoulda-ish" macros that look something like this:
http://gist.github.com/e4193a685a7f2fc0b4ab
Scott
thanks in advance
joaquin
--
www.least-significant-bit.com
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users