puppetlabs-stdlib/spec/functions/sort_spec.rb

25 lines
647 B
Ruby
Raw Normal View History

#! /usr/bin/env ruby -S rspec
require 'spec_helper'
describe "the sort function" do
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
it "should exist" do
expect(Puppet::Parser::Functions.function("sort")).to eq("function_sort")
end
2011-07-24 01:39:17 +02:00
it "should raise a ParseError if there is not 1 arguments" do
expect { scope.function_sort(['','']) }.to( raise_error(Puppet::ParseError))
2011-07-24 01:39:17 +02:00
end
it "should sort an array" do
result = scope.function_sort([["a","c","b"]])
expect(result).to(eq(['a','b','c']))
end
2011-07-29 01:10:31 +02:00
it "should sort a string" do
result = scope.function_sort(["acb"])
expect(result).to(eq('abc'))
2011-07-29 01:10:31 +02:00
end
end