2012-11-28 19:13:57 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "the reject function" do
|
|
|
|
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
|
|
|
|
|
|
it "should exist" do
|
2014-06-04 20:38:37 +02:00
|
|
|
expect(Puppet::Parser::Functions.function("reject")).to eq("function_reject")
|
2012-11-28 19:13:57 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should raise a ParseError if there is less than 1 arguments" do
|
2014-06-04 20:38:37 +02:00
|
|
|
expect { scope.function_reject([]) }.to( raise_error(Puppet::ParseError))
|
2012-11-28 19:13:57 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should reject contents from an array" do
|
|
|
|
result = scope.function_reject([["1111", "aaabbb","bbbccc","dddeee"], "bbb"])
|
2014-06-04 20:38:37 +02:00
|
|
|
expect(result).to(eq(["1111", "dddeee"]))
|
2012-11-28 19:13:57 +01:00
|
|
|
end
|
|
|
|
end
|