Sha256: 0e23b635e37b602554bf824faeef0ef3d98f8af02ce5f20bcc421822d04a1ccd
Contents?: true
Size: 1.17 KB
Versions: 5
Compression:
Stored size: 1.17 KB
Contents
require 'dry/validation/hint_compiler' RSpec.describe HintCompiler, '#call' do subject(:compiler) { HintCompiler.new(Messages.default, rules: rules) } let(:rules) do [ [ :and, [ [:val, [:predicate, [:key?, [:age]]]], [ :or, [ [:key, [:age, [:predicate, [:none?, []]]]], [ :and, [ [:key, [:age, [:predicate, [:int?, []]]]], [:key, [:age, [:predicate, [:gt?, [18]]]]] ] ] ] ] ], ], [ :and, [ [:val, [:predicate, [:attr?, [:height]]]], [ :or, [ [:attr, [:height, [:predicate, [:none?, []]]]], [ :and, [ [:attr, [:height, [:predicate, [:int?, []]]]], [:attr, [:height, [:predicate, [: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
5 entries across 5 versions & 1 rubygems