On Mon, Dec 20, 2010 at 9:28 PM, daze <[email protected]> wrote:

> I'm using thoughtbot's shoulda, and I have this in a model:
>
> validates_inclusion_of :year, :in => %w[ 09-10 10-11 ]
>
> where :year is of type string.  How do I test this in shoulda?  Is it
> with
> (1) should ensure_inclusion_of
> or do I have to do
> (2) should allow_value('09-10').for(:year) and the should_not
> equivalents?
>
>
> So?  (2) seems verbose... I mean, having to do a bunch of should's and
> should_not's?
>

I would be curious if there was another way if I understand exactly what you
are doing, but I think (2) is what you have to do... seems to me it is
similar to validating the format of an attribute.

Although, you might have to change your structure but seems that somehow you
could use "should include_value_in_range"...

(see
http://rubydoc.info/github/thoughtbot/shoulda/master/Shoulda/ActiveRecord/Macros
)


>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to