2012-11-23 17:00:04 +01:00
|
|
|
#! /usr/bin/env ruby -S rspec
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "the min function" do
|
|
|
|
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
|
|
|
|
|
|
it "should exist" do
|
2014-06-04 20:38:37 +02:00
|
|
|
expect(Puppet::Parser::Functions.function("min")).to eq("function_min")
|
2012-11-23 17:00:04 +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_min([]) }.to( raise_error(Puppet::ParseError))
|
2012-11-23 17:00:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be able to compare strings" do
|
2014-06-04 20:38:37 +02:00
|
|
|
expect(scope.function_min(["albatross","dog","horse"])).to(eq("albatross"))
|
2012-11-23 17:00:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be able to compare numbers" do
|
2014-06-04 20:38:37 +02:00
|
|
|
expect(scope.function_min([6,8,4])).to(eq(4))
|
2012-11-23 17:00:04 +01:00
|
|
|
end
|
2013-03-20 16:36:20 +01:00
|
|
|
|
|
|
|
it "should be able to compare a number with a stringified number" do
|
2014-06-04 20:38:37 +02:00
|
|
|
expect(scope.function_min([1,"2"])).to(eq(1))
|
2013-03-20 16:36:20 +01:00
|
|
|
end
|
2012-11-23 17:00:04 +01:00
|
|
|
end
|