[rspec-users] a better "should have valid associations"
dchelimsky at gmail.com
Thu Mar 29 11:44:58 EDT 2007
On 3/29/07, Josh Knowles <joshknowles at gmail.com> wrote:
> On 3/29/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > How about this?
> > project.should belong_to(:manager)
> > manager.should have_many(:projects)
> > etc
> > This would involve more matchers, but could be implemented in the same
> > fashion as have_association is above.
> I've implenented the first pass at the following rails matchers:
> should belong_to(association)
> should have_many(association)
> should validate_confirmation_of(attribute)
> should validate_format_of(attribute, valid => , invalid => )
> should validate_lendth_of(attribute, range)
> should validate_presence_of(attribute)
> should validate_uniqueness_of(attribute)
> Plugin available here:
> I haven't had a chance to get the README done, or any rdoc, but there are
> specs for the majority of the matchers.
> Comments / Suggestions Welcome!
AWESOME! I'm so psyched to see a plugin emerging for this.
Looks like have_many and belong_to don't really specify the specific
type of association, so you could get false positives. Also, it
probably needs a have_one and have_and_belong_to_many matchers is well
to round it out, no?
> Josh Knowles
> joshknowles at gmail.com
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users