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
|
require 'spec_helper'
require 'puppet/util/multi_match'
describe "The Puppet::Util::MultiMatch" do
let(:not_nil) { Puppet::Util::MultiMatch::NOT_NIL }
let(:mm) { Puppet::Util::MultiMatch }
it "matches against not nil" do
expect(not_nil === 3).to be(true)
end
it "matches against multiple values" do
expect(mm.new(not_nil, not_nil) === [3, 3]).to be(true)
end
it "matches each value using ===" do
expect(mm.new(3, 3.14) === [Integer, Float]).to be(true)
end
it "matches are commutative" do
expect(mm.new(3, 3.14) === mm.new(Integer, Float)).to be(true)
expect(mm.new(Integer, Float) === mm.new(3, 3.14)).to be(true)
end
it "has TUPLE constant for match of array of two non nil values" do
expect(mm::TUPLE === [3, 3]).to be(true)
end
it "has TRIPLE constant for match of array of two non nil values" do
expect(mm::TRIPLE === [3, 3, 3]).to be(true)
end
it "considers length of array of values when matching" do
expect(mm.new(not_nil, not_nil) === [6, 6, 6]).to be(false)
expect(mm.new(not_nil, not_nil) === [6]).to be(false)
end
end
|