These are chat archives for dry-rb/chat

7th
Dec 2016
George Millo
@georgemillo
Dec 07 2016 13:44
how do people test their dry-v schemas, if at all?
I started writing some custom RSpec matchers, then I realised that my spec files were practically identical to my schemas themselves:
# schema:
required(:name).filled
optional(:age).maybe

# spec:
expect(schema).to have_required_key(:name).filled
expect(schema).to have_optional_key(:age).maybe
which is better than no tests at all, but tests take time to write, and now I'm writing 2x as much code for very little extra benefit
what are people's thoughts on writing tests for their schemas? do you find it worth the effort?
George Millo
@georgemillo
Dec 07 2016 13:50
(I'm thinking that if I'm going to create custom matchers, my time is probably better spent creating them for Reform validations, which of course use dry-v anyway, but the matchers themselves will have to be different)
Christopher Dennl-Ortega Arrieta
@cdennl
Dec 07 2016 14:12
@georgemillo don't test the schema but the instance which uses the schema
George Millo
@georgemillo
Dec 07 2016 14:13
@cdennl I thought as much. In my case that would be Reform
Christopher Dennl-Ortega Arrieta
@cdennl
Dec 07 2016 14:13
the schema alone is pretty meaningless
@georgemillo yes
or the model / op which uses the schema
George Millo
@georgemillo
Dec 07 2016 14:13
there's a gaping hole in the Reform ecosystem for some smart RSpec matchers that test the validations