Sha256: 7c32591599fc773fb9f97f17986d45d2b057fabe3d7882bb0151814d1252e2a8

Contents?: true

Size: 1.21 KB

Versions: 19

Compression:

Stored size: 1.21 KB

Contents

RSpec.describe Schema::Rule do
  include_context 'predicate helper'

  let(:filled) { p(:filled?) }
  let(:format) { p(:format?, /regex/) }

  let(:left) { Schema::Rule.new(filled, name: :email, target: target) }
  let(:right) { Schema::Rule.new(format, name: :email, target: target) }
  let(:target) { double(:target, id: :user) }

  describe '#and' do
    it 'returns a conjunction' do
      expect(left.and(right).to_ast).to match_array(
        [:rule, [:email, [:and, [[:rule, [:email, filled]], [:rule, [:email, format]]]]]]
      )
    end
  end

  describe '#or' do
    it 'returns a disjunction' do
      expect(left.or(right).to_ast).to match_array(
        [:rule, [:email, [:or, [[:rule, [:email, filled]], [:rule, [:email, format]]]]]]
      )
    end
  end

  describe '#xor' do
    it 'returns an exclusive disjunction' do
      expect(left.xor(right).to_ast).to match_array(
        [:rule, [:email, [:xor, [[:rule, [:email, filled]], [:rule, [:email, format]]]]]]
      )
    end
  end

  describe '#then' do
    it 'returns an implication' do
      expect(left.then(right).to_ast).to match_array(
        [:rule, [:email, [:implication, [[:rule, [:email, filled]], [:rule, [:email, format]]]]]]
      )
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
dry-validation-0.13.3 spec/unit/schema/rule_spec.rb
dry-validation-0.13.2 spec/unit/schema/rule_spec.rb
dry-validation-0.13.1 spec/unit/schema/rule_spec.rb
dry-validation-0.11.2 spec/unit/schema/rule_spec.rb
dry-validation-0.12.3 spec/unit/schema/rule_spec.rb
dry-validation-0.13.0 spec/unit/schema/rule_spec.rb
dry-validation-0.12.2 spec/unit/schema/rule_spec.rb
dry-validation-0.12.1 spec/unit/schema/rule_spec.rb
dry-validation-0.12.0 spec/unit/schema/rule_spec.rb
dry-validation-0.11.1 spec/unit/schema/rule_spec.rb
dry-validation-0.11.0 spec/unit/schema/rule_spec.rb
dry-validation-0.10.7 spec/unit/schema/rule_spec.rb
dry-validation-0.10.6 spec/unit/schema/rule_spec.rb
dry-validation-0.10.5 spec/unit/schema/rule_spec.rb
dry-validation-0.10.4 spec/unit/schema/rule_spec.rb
dry-validation-0.10.3 spec/unit/schema/rule_spec.rb
dry-validation-0.10.2 spec/unit/schema/rule_spec.rb
dry-validation-0.10.1 spec/unit/schema/rule_spec.rb
dry-validation-0.10.0 spec/unit/schema/rule_spec.rb