Sha256: 5aa941db1664960b9d02a17234978213f857f5859bb364b7dfd00649fb78ec9c
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'dry/validation/hint_compiler' RSpec.describe HintCompiler, '#call' do subject(:compiler) { HintCompiler.new(Messages.default, rules: rules) } let(:rules) do [ [ :and, [ [:key, [:age, [:predicate, [:key?, []]]]], [ :or, [ [:val, [:age, [:predicate, [:none?, []]]]], [ :and, [ [:val, [:age, [:predicate, [:int?, []]]]], [:val, [:age, [:predicate, [:gt?, [18]]]]] ] ] ] ] ], ], [ :and, [ [:attr, [:height, [:predicate, [:attr?, []]]]], [ :or, [ [:val, [:height, [:predicate, [:none?, []]]]], [ :and, [ [:val, [:height, [:predicate, [:int?, []]]]], [:val, [:height, [:predicate, [:gt?, [180]]]]] ] ] ] ] ] ] ] end it 'returns hint messages for given rules' do expect(compiler.call).to eql( age: ['age must be an integer', 'age must be greater than 18'], height: ['height must be an integer', 'height must be greater than 180'], ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-validation-0.6.0 | spec/unit/hint_compiler_spec.rb |