Sha256: 5913303a11e3f6cb7f1d1ffbd2c1e96359c4461b27282354cc2d79ebb6c31fda

Contents?: true

Size: 722 Bytes

Versions: 4

Compression:

Stored size: 722 Bytes

Contents

require 'dry/logic/rule'

RSpec.describe Dry::Logic::Rule::Set do
  include_context 'predicates'

  subject(:rule) do
    Dry::Logic::Rule::Set.new([is_string, min_size.curry(6)])
  end

  let(:is_string) { Dry::Logic::Rule::Value.new(str?) }
  let(:min_size) { Dry::Logic::Rule::Value.new(min_size?) }

  describe '#call' do
    it 'applies its rules to the input' do
      expect(rule.('Address')).to be_success
      expect(rule.('Addr')).to be_failure
    end
  end

  describe '#to_ast' do
    it 'returns an array representation' do
      expect(rule.to_ast).to eql([
        :set, [
          [:val, [:predicate, [:str?, []]]],
          [:val, [:predicate, [:min_size?, [6]]]]
        ]
      ])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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