Sha256: 0c23d0f0b5eb8a30f6760820f9a6618dfb6f2b971162fe378bd2bef053973249
Contents?: true
Size: 734 Bytes
Versions: 6
Compression:
Stored size: 734 Bytes
Contents
require 'dry/validation/rule' RSpec.describe Dry::Validation::Rule::Key do include_context 'predicates' subject(:rule) { Dry::Validation::Rule::Key.new(:name, key?) } describe '#call' do it 'applies predicate to the value' do expect(rule.(name: 'Jane')).to be_success expect(rule.({})).to be_failure end end describe '#and' do let(:other) { Dry::Validation::Rule::Value.new(:name, str?) } it 'returns conjunction rule where value is passed to the right' do present_and_string = rule.and(other) expect(present_and_string.(name: 'Jane')).to be_success expect(present_and_string.({})).to be_failure expect(present_and_string.(name: 1)).to be_failure end end end
Version data entries
6 entries across 6 versions & 1 rubygems