Sha256: aaa50f2d72cad83ec2a7393516b3c9bdcede608b704e5fb655eb8cd9c73488d5

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

RSpec.describe Rule::Composite::Disjunction do
  include_context 'predicates'

  subject(:rule) { Rule::Composite::Disjunction.new(left, right) }

  let(:left) { Rule::Value.new(none?) }
  let(:right) { Rule::Value.new(gt?.curry(18)) }

  let(:other) do
    Rule::Value.new(int?) & Rule::Value.new(lt?.curry(14))
  end

  describe '#call' do
    it 'calls left and right' do
      expect(rule.(nil)).to be_success
      expect(rule.(19)).to be_success
      expect(rule.(18)).to be_failure
    end
  end

  describe '#and' do
    it 'creates conjunction with the other' do
      expect(rule.and(other).(nil)).to be_failure
      expect(rule.and(other).(19)).to be_failure
      expect(rule.and(other).(13)).to be_failure
      expect(rule.and(other).(14)).to be_failure
    end
  end

  describe '#or' do
    it 'creates disjunction with the other' do
      expect(rule.or(other).(nil)).to be_success
      expect(rule.or(other).(19)).to be_success
      expect(rule.or(other).(13)).to be_success
      expect(rule.or(other).(14)).to be_failure
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-logic-0.3.0 spec/unit/rule/disjunction_spec.rb
dry-logic-0.2.3 spec/unit/rule/disjunction_spec.rb
dry-logic-0.2.2 spec/unit/rule/disjunction_spec.rb
dry-logic-0.2.1 spec/unit/rule/disjunction_spec.rb
dry-logic-0.2.0 spec/unit/rule/disjunction_spec.rb