File: predicates.rb

package info (click to toggle)
ruby-dry-logic 1.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 728 kB
  • sloc: ruby: 4,929; makefile: 6
file content (59 lines) | stat: -rw-r--r-- 1,391 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# frozen_string_literal: true

require "dry/logic/predicates"

RSpec.shared_examples "predicates" do
  let(:nil?) { Dry::Logic::Predicates[:nil?] }

  let(:array?) { Dry::Logic::Predicates[:array?] }

  let(:empty?) { Dry::Logic::Predicates[:empty?] }

  let(:str?) { Dry::Logic::Predicates[:str?] }

  let(:true?) { Dry::Logic::Predicates[:true?] }

  let(:hash?) { Dry::Logic::Predicates[:hash?] }

  let(:int?) { Dry::Logic::Predicates[:int?] }

  let(:filled?) { Dry::Logic::Predicates[:filled?] }

  let(:min_size?) { Dry::Logic::Predicates[:min_size?] }

  let(:lt?) { Dry::Logic::Predicates[:lt?] }

  let(:gt?) { Dry::Logic::Predicates[:gt?] }

  let(:key?) { Dry::Logic::Predicates[:key?] }

  let(:attr?) { Dry::Logic::Predicates[:attr?] }

  let(:eql?) { Dry::Logic::Predicates[:eql?] }

  let(:size?) { Dry::Logic::Predicates[:size?] }

  let(:case?) { Dry::Logic::Predicates[:case?] }

  let(:equal?) { Dry::Logic::Predicates[:equal?] }
end

RSpec.shared_examples "a passing predicate" do
  let(:predicate) { Dry::Logic::Predicates[predicate_name] }

  it do
    arguments_list.each do |args|
      expect(predicate.call(*args)).to be(true)
    end
  end
end

RSpec.shared_examples "a failing predicate" do
  let(:predicate) { Dry::Logic::Predicates[predicate_name] }

  it do
    arguments_list.each do |args|
      expect(predicate.call(*args)).to be(false)
    end
  end
end