ruby on rails - RSpec: Shared examples for Validators? -
i have several models have start_time
, end_time
, have custom validator has special rules these fields. testing, feel i've got 3 options:
- have validator , validator_spec. re-test entire implementation of validators in every model ensure validator working model.
- have validator , validator_spec. in each model, somehow check already-tested validator being included in model. (maybe means testing 1 condition arise validator being included.)
- creating shared example validator test, , include in each model's test (although
it_behaves_like somevalidator
looks kind of weird)
any thoughts? validator has several conditions i'd find taxes , not dry implement #1.
i propose option:
4.) implement validator_spec , build custom matcher can reused in every model using validator
maybe can find inspiration @ https://github.com/thoughtbot/shoulda-matchers
Comments
Post a Comment