bcardarella / valid_attribute

Minimalist validation BDD for ActiveModel specs
178 stars 18 forks source link

Add minitest support #13

Closed wojtekmach closed 13 years ago

wojtekmach commented 13 years ago

minitest is a drop-in replacement for test/unit. It's already in 1.9 and Rails is using it when possible.

wojtekmach commented 13 years ago

It propably needs some more work as we might not be able to get rid of test/unit just yet. valid_attribute test/unit mode basically depends on shoulda, and shoulda (shoulda-context) depends on test/unit

bcardarella commented 13 years ago

I would actually prefer the minitest solution over test/unit. Dropping any Shoulda dependency would be great.

wojtekmach commented 13 years ago

I did a minimal implementation to make this work: https://gist.github.com/1176601. It leverages minitest 2.5+ subject and uses upstream valid_attribute. What's your thoughts on this?

wojtekmach commented 13 years ago

Hello, following discussion in https://github.com/seattlerb/minitest/issues/33, I created minitest-matchers gem: https://rubygems.org/gems/minitest-matchers. I updated the commit to reflect changes.

You can see it in action here: https://gist.github.com/1192809

bcardarella commented 13 years ago

Can you update the README so I can pull all of this in with one clean commit?

wojtekmach commented 13 years ago

It pretty much works except one feature. In minitest-matchers right now we can't have matcher description with values from subject becasuse we define must_ in context of spec class not spec instance (spec instance has access to subject). So the last example from README won't pass: wont { have_valid(:title) }

It's a nice feature worth taking look at tho.