Sha256: 19564c96e8b59e62d409e853d799c0d2df99b78e41a8ac9eaa7aba365c15d1f0

Contents?: true

Size: 696 Bytes

Versions: 9

Compression:

Stored size: 696 Bytes

Contents

require 'dry/logic/predicate'

RSpec.describe Dry::Logic::Predicate do
  describe '#call' do
    it 'returns result of the predicate function' do
      is_empty = Dry::Logic::Predicate.new(:is_empty) { |str| str.empty? }

      expect(is_empty.('')).to be(true)

      expect(is_empty.('filled')).to be(false)
    end
  end

  describe '#curry' do
    it 'returns curried predicate' do
      min_age = Dry::Logic::Predicate.new(:min_age) { |age, input| input >= age }

      min_age_18 = min_age.curry(18)

      expect(min_age_18.args).to eql([18])

      expect(min_age_18.(18)).to be(true)
      expect(min_age_18.(19)).to be(true)
      expect(min_age_18.(17)).to be(false)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dry-logic-0.2.3 spec/unit/predicate_spec.rb
dry-logic-0.2.2 spec/unit/predicate_spec.rb
dry-logic-0.2.1 spec/unit/predicate_spec.rb
dry-logic-0.2.0 spec/unit/predicate_spec.rb
dry-logic-0.1.4 spec/unit/predicate_spec.rb
dry-logic-0.1.3 spec/unit/predicate_spec.rb
dry-logic-0.1.2 spec/unit/predicate_spec.rb
dry-logic-0.1.1 spec/unit/predicate_spec.rb
dry-logic-0.1.0 spec/unit/predicate_spec.rb