Sha256: 3c69528d9186989a655387d2a9f650b54db2a53c4a27fdf1a22401b75b223335
Contents?: true
Size: 823 Bytes
Versions: 4
Compression:
Stored size: 823 Bytes
Contents
RSpec.describe Operations::Attr do subject(:operation) { Operations::Attr.new(Rule::Predicate.new(str?), name: :name) } include_context 'predicates' let(:model) { Struct.new(:name) } describe '#call' do it 'applies predicate to the value' do expect(operation.(model.new('Jane'))).to be_success expect(operation.(model.new(nil))).to be_failure end end describe '#and' do let(:other) { Operations::Attr.new(Rule::Predicate.new(min_size?).curry(3), name: :name) } it 'returns and where value is passed to the right' do present_and_string = operation.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
4 entries across 4 versions & 1 rubygems