Sha256: c6e7de1b21862af2dcbb18716ca1ff4f9ecb5d453ca659b3b4915319d6affee1
Contents?: true
Size: 811 Bytes
Versions: 5
Compression:
Stored size: 811 Bytes
Contents
require 'dry/logic/rule' RSpec.describe Dry::Logic::Rule::Attr do include_context 'predicates' let(:model) { Struct.new(:name) } subject(:rule) { described_class.new(str?, name: :name) } describe '#call' do it 'applies predicate to the value' do expect(rule.(model.new('Jane'))).to be_success expect(rule.(model.new(nil))).to be_failure end end describe '#and' do let(:other) { Dry::Logic::Rule::Attr.new(min_size?.curry(3), name: :name) } it 'returns conjunction rule where value is passed to the right' do present_and_string = rule.and(other) expect(present_and_string.(model.new('Jane'))).to be_success expect(present_and_string.(model.new('Ja'))).to be_failure expect(present_and_string.(model.new(1))).to be_failure end end end
Version data entries
5 entries across 5 versions & 1 rubygems