Sha256: 4b38f0f2a734bb92a9167c66c3dc9aa85f5a25ab873578da126b75315a9e73ed

Contents?: true

Size: 977 Bytes

Versions: 5

Compression:

Stored size: 977 Bytes

Contents

RSpec.describe Schema::Rule do
  let(:filled) { [:val, [:email, [:predicate, [:filled?, []]]]] }
  let(:format) { [:val, [:email, [:predicate, [: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([:and, [filled, format]])
    end
  end

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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-validation-0.7.4 spec/unit/schema/rule_spec.rb
dry-validation-0.7.3 spec/unit/schema/rule_spec.rb
dry-validation-0.7.2 spec/unit/schema/rule_spec.rb
dry-validation-0.7.1 spec/unit/schema/rule_spec.rb
dry-validation-0.7.0 spec/unit/schema/rule_spec.rb