Sha256: 305525ee4c418bb14dd17761fdd423ee8c508052ea50a266f3f458edc46e62a1

Contents?: true

Size: 669 Bytes

Versions: 5

Compression:

Stored size: 669 Bytes

Contents

RSpec.describe Rule::Check do
  subject(:rule) { Rule::Check.new(:name, other.(input).curry(predicate)) }

  include_context 'predicates'

  let(:other) do
    Rule::Value.new(:name, none?).or(Rule::Value.new(:name, filled?))
  end

  describe '#call' do
    context 'when a given predicate passed' do
      let(:input) { 'Jane' }
      let(:predicate) { :filled? }

      it 'returns a success' do
        expect(rule.()).to be_success
      end
    end

    context 'when a given predicate did not pass' do
      let(:input) { nil }
      let(:predicate) { :filled? }

      it 'returns a failure' do
        expect(rule.()).to be_failure
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
dry-logic-0.1.2 spec/unit/rule/check_spec.rb
dry-logic-0.1.1 spec/unit/rule/check_spec.rb
dry-logic-0.1.0 spec/unit/rule/check_spec.rb
dry-validation-0.4.1 spec/unit/rule/check_spec.rb
dry-validation-0.4.0 spec/unit/rule/check_spec.rb