musaffa / file_validators

Adds file validators to ActiveModel.
MIT License
260 stars 25 forks source link

How to use validators in our own specs? #10

Open vfonic opened 8 years ago

vfonic commented 8 years ago

Hi,

Great work on the gem!

I'm trying to use the gem's validators in my own rspec suite, so that I'm able to say something like:

  it { is_expected.to allow_file_size(1.5.megabyes, :image) }

...or similar. Is there any way to include the validators in the rspec?

musaffa commented 8 years ago

file_validators currently doesn't have any rspec matcher. It would be great to have some. Wanna give a hand for this feature? shoulda-matchers code can be an inspiration.

stephen-puiszis commented 8 years ago

:+1:

ehannes commented 8 years ago

What about the matchers defined in https://github.com/musaffa/file_validators/tree/master/spec/support/matchers? Maybe I'm wrong, but what if these were moved to lib/file_validators/test, like Carrierwave has done, wouldn't these be available then?

musaffa commented 8 years ago

@ehannes Those are some dummy matchers. As you can see, they use test doubles. Real matchers will be more complicated.