Sha256: 2f0e9cc1da3014c44c66ffe3b80c1dbb5a201c84a60cb0709076f2f591be76c4

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

RSpec.describe Rule::Check do
  subject(:rule) do
    Rule::Check::Unary.new(:name, other.(input).curry(predicate), [:name])
  end

  include_context 'predicates'

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

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-logic-0.1.3 spec/unit/rule/check_spec.rb