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