Sha256: 12bc5270ef23feac49023911a684ff52acec7610b00baf10d8c80f41d7d24f4a

Contents?: true

Size: 703 Bytes

Versions: 4

Compression:

Stored size: 703 Bytes

Contents

# frozen_string_literal: true

require 'dry/logic/predicates'

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

    context 'when value responds to the attr name' do
      let(:arguments_list) do
        [
          [:name, Struct.new(:name).new('John')],
          [:age, Struct.new(:age).new(18)]
        ]
      end

      it_behaves_like 'a passing predicate'
    end

    context 'with value does not respond to the attr name' do
      let(:arguments_list) do
        [
          [:name, Struct.new(:age).new(18)],
          [:age, Struct.new(:name).new('Jill')]
        ]
      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/attr_spec.rb
dry-logic-1.0.4 spec/unit/predicates/attr_spec.rb
dry-logic-1.0.3 spec/unit/predicates/attr_spec.rb
dry-logic-1.0.2 spec/unit/predicates/attr_spec.rb