Sha256: aba897c9eae10927f0d5b90bb1220f6fac0df0ea03aaaa9d8b11074f4d6a451f

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require 'dry/logic/predicates'

RSpec.describe Dry::Logic::Predicates do
  describe '#excludes?' do
    let(:predicate_name) { :excludes? }

    context 'with input excludes value' do
      let(:arguments_list) do
        [
          ['Jack', ['Jill', 'John']],
          [0, 1..2],
          [3, 1..2],
          ['foo', 'Hello World'],
          [:foo, { bar: 0 }],
          [true, [nil, false]]
        ]
      end

      it_behaves_like 'a passing predicate'
    end

    context 'with input of invalid type' do
      let(:arguments_list) do
        [
          [2, 1],
          [1, nil],
          ["foo", 1],
          [1, "foo"],
          [1..2, "foo"],
          ["foo", 1..2],
          [:key, "foo"]
        ]
      end

      it_behaves_like 'a passing predicate'
    end

    context 'when input includes value' do
      let(:arguments_list) do
        [
          ['Jill', ['Jill', 'John']],
          ['John', ['Jill', 'John']],
          [1, 1..2],
          [2, 1..2],
          ['Hello', 'Hello World'],
          ['World', 'Hello World'],
          [:bar, { bar: 0 }],
          [nil, [nil, false]],
          [false, [nil, false]]
        ]
      end

      it_behaves_like 'a failing predicate'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-logic-1.0.5 spec/unit/predicates/excludes_spec.rb
dry-logic-1.0.4 spec/unit/predicates/excludes_spec.rb
dry-logic-1.0.3 spec/unit/predicates/excludes_spec.rb
dry-logic-1.0.2 spec/unit/predicates/excludes_spec.rb