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:

  1. have validator , validator_spec. re-test entire implementation of validators in every model ensure validator working model.
  2. 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.)
  3. 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

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -