thetron / mongoid-enum

Sweet enum sugar for your Mongoid documents
MIT License
117 stars 166 forks source link

Testing enum? #26

Open Bartuz opened 9 years ago

Bartuz commented 9 years ago

How should I test enum setup in my app?

thetron commented 9 years ago

@Bartuz The library is tested - so you don't need to test any of the features that you get from mongoid-enum, so I would just be testing your enums the same way you would test any attribute on your Mongoid documents.

Bartuz commented 9 years ago

Ok, but there are rspec matchers which I can use this way: it { is_expected.to have_fields(:birthdate, :registered_at).of_type(DateTime) }

there is not anything likee this for this gem, right?

thetron commented 9 years ago

No, the library doesn't come with any RSpec matchers, but the fields are (at this point in time) just strings (or symbols - I can't quite remember precisely), so:

it { is expected.to have_fields(:foobar_enum).of_type(String)

Would be adequate here, IMHO.