mongoid-enum icon indicating copy to clipboard operation
mongoid-enum copied to clipboard

Testing enum?

Open Bartuz opened this issue 10 years ago • 3 comments

How should I test enum setup in my app?

Bartuz avatar Oct 04 '15 17:10 Bartuz

@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.

thetron avatar Oct 07 '15 22:10 thetron

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?

Bartuz avatar Oct 07 '15 22:10 Bartuz

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.

thetron avatar Oct 07 '15 22:10 thetron