]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Added tests for each function, fixing functions as we hit bugs.
authorKen Barber <ken@bob.sh>
Wed, 29 Jun 2011 20:21:55 +0000 (21:21 +0100)
committerKen Barber <ken@bob.sh>
Wed, 29 Jun 2011 20:21:55 +0000 (21:21 +0100)
74 files changed:
.gitignore
lib/puppet/parser/functions/date.rb
lib/puppet/parser/functions/delete.rb
lib/puppet/parser/functions/grep.rb
lib/puppet/parser/functions/is_float.rb
lib/puppet/parser/functions/is_integer.rb
lib/puppet/parser/functions/is_numeric.rb
lib/puppet/parser/functions/is_valid_domain_name.rb
lib/puppet/parser/functions/is_valid_ip_address.rb
lib/puppet/parser/functions/is_valid_mac_address.rb
lib/puppet/parser/functions/is_valid_netmask.rb
lib/puppet/parser/functions/load_json.rb
lib/puppet/parser/functions/load_yaml.rb
lib/puppet/parser/functions/rand.rb
lib/puppet/parser/functions/sort.rb
lib/puppet/parser/functions/squeeze.rb
lib/puppet/parser/functions/time.rb
spec/unit/parser/functions/abs_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/bool2num_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/capitalize_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/chomp_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/chop_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/count_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/date_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/delete_at_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/delete_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/downcase_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/empty_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/fact_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/flatten_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/grep_spec.rb [new file with mode: 0755]
spec/unit/parser/functions/hash_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/is_array_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/is_float_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/is_hash_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/is_integer_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/is_numeric_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/is_string_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/is_valid_domain_name_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/is_valid_ip_address_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/is_valid_mac_address_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/is_valid_netmask_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/join_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/join_with_prefix_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/keys_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/kwalify_spec.rb
spec/unit/parser/functions/load_json_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/load_variables_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/load_yaml_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/lstrip_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/member_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/num2bool_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/persistent_crontab_minutes_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/prefix_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/rand_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/random_crontab_minutes_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/range_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/reverse_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/rstrip_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/shuffle_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/size_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/sort_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/squeeze_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/str2bool_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/strftime_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/strip_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/swapcase_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/time_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/type_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/unique_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/upcase_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/values_at_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/values_spec.rb [new file with mode: 0644]
spec/unit/parser/functions/zip_spec.rb [new file with mode: 0644]

index 01d0a0845874df7d1ecf23683b7477b9f2777f00..7ad8fcada42ed498294e227c8c45ce7a75a3e7c0 100644 (file)
@@ -1 +1,2 @@
 pkg/
+coverage/
index ea1126599721575e2d1e525d9255e98730eec1a5..4d0543eee14811c8e1c8847797e76b58026fa039 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:date, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "is_valid_netmask(): Wrong number of arguments "+
+        "given #{arguments.size} for 1")
+    end
+
   end
 end
 
index b8376d1e865c61bd13efc3d32cd9b8f952a261a6..88f3448e5759bc55bd493ac4bf35308d7819c6e6 100644 (file)
@@ -9,6 +9,12 @@ module Puppet::Parser::Functions
   newfunction(:delete, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 2) then
+      raise(Puppet::ParseError, "is_valid_netmask(): Wrong number of arguments "+
+        "given #{arguments.size} for 2")
+    end
+
   end
 end
 
index 1663fe787ad89f9373d51a11aa3d133be495989a..8549218972f60288d6ac350d3461a8e5bbd804d1 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:grep, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 2) then
+      raise(Puppet::ParseError, "grep(): Wrong number of arguments "+
+        "given #{arguments.size} for 2")
+    end
+
   end
 end
 
index 2a5a923cf8efcf5b555f5c4894d22e8846edc603..39d097f8e8f94c9e3fe51a7ac245558c08e05a8e 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:is_float, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+
+        "given #{arguments.size} for 1")
+    end
+
   end
 end
 
index 44337f016418b64e4bdcd35d74791cf7c5adc78a..9813cf19aac6a762d4ffa1ac9f97383fafec9991 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:is_integer, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "is_integer(): Wrong number of arguments "+
+        "given #{arguments.size} for 1")
+    end
+
   end
 end
 
index 7a640918c915b6a7fae2d638fb68246e81aef172..96e867469b35b07b0631f60f0c4fc46b3acfa46e 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+
+        "given #{arguments.size} for 1")
+    end
+
   end
 end
 
index 05d64bed45b042df349dd038566d174ef899a2e4..c0b319c16c87a0ef0e17116ffcd5d713739b8952 100644 (file)
@@ -1,11 +1,17 @@
 #
-# is_valid_doman_name.rb
+# is_valid_domain_name.rb
 #
 
 module Puppet::Parser::Functions
-  newfunction(:is_valid_doman_name, :type => :rvalue, :doc => <<-EOS
+  newfunction(:is_valid_domain_name, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "is_valid_domain_name(): Wrong number of arguments "+
+        "given #{arguments.size} for 1")
+    end
+
   end
 end
 
index e6b68a8df58f2fbfdba84b3326a98139bdb649f6..e91dda8c2e4ccd4d5c9e563c007e0b949d2b2696 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:is_valid_ip_address, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "is_valid_ip_address(): Wrong number of arguments "+
+        "given #{arguments.size} for 1")
+    end
+
   end
 end
 
index 5e354c9a97f53544d2f0c7bf66c54e20eafa4a7d..0b91d0ddb6ca9843abb2cca3f53c6d4b30589775 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:is_valid_mac_address, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "is_valid_mac_address(): Wrong number of arguments "+
+        "given #{arguments.size} for 1")
+    end
+
   end
 end
 
index 2aeb3743d5ec10c0b509724b2d59ded49512b374..41e48438033fc39b0c1fd8556fb704314ab7ec2c 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:is_valid_netmask, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "is_valid_netmask(): Wrong number of arguments "+
+        "given #{arguments.size} for 1")
+    end
+
   end
 end
 
index 9ec8c789494dd9f495c090189957ecbedd3417b0..7c3f1870833be8f94fb1297cd15307edd2647314 100644 (file)
@@ -6,6 +6,18 @@ module Puppet::Parser::Functions
   newfunction(:load_json, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "load_json(): Wrong number of arguments "+
+        "given #{arguments.size} for 1")
+    end
+
+    json = arguments[0]
+    
+    require 'json'
+
+    JSON.load(json)
+
   end
 end
 
index 684a721ceca053960315cbf08ebe372d5a1cd183..1bc2f36f1f3ffd7ef716fcc7d90bbf593698b530 100644 (file)
@@ -6,6 +6,16 @@ module Puppet::Parser::Functions
   newfunction(:load_yaml, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "load_yaml(): Wrong number of arguments "+
+        "given #{arguments.size} for 1")
+    end
+
+    require 'yaml'
+
+    YAML::load(arguments[0])
+
   end
 end
 
index 2cb9acbc100de665a4c0fabece2e0c00042fac01..6d870dc695338b989c167aa54db3ec71585e596e 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:rand, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 0) and (arguments.size != 1) then
+      raise(Puppet::ParseError, "rand(): Wrong number of arguments "+
+        "given #{arguments.size} for 0 or 1")
+    end
+
   end
 end
 
index 85e5ba01a73845df2c79d64fed116f426292a2df..974141cdeff13d46643efc549820a98db2bcfd9f 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:sort, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 0) then
+      raise(Puppet::ParseError, "sort(): Wrong number of arguments "+
+        "given #{arguments.size} for 0")
+    end
+
   end
 end
 
index a135bd390428206ea425f3ada9682f2a9b6b4ed1..02eb00ccc82013410a1c8f35851de4b42f624ff1 100644 (file)
@@ -6,6 +6,12 @@ module Puppet::Parser::Functions
   newfunction(:squeeze, :type => :rvalue, :doc => <<-EOS
     EOS
   ) do |arguments|
+
+    if (arguments.size != 2) then
+      raise(Puppet::ParseError, "squeeze(): Wrong number of arguments "+
+        "given #{arguments.size} for 2")
+    end
+
   end
 end
 
index f7c104135278b26a3e05484ceee8f06f97c621c1..e1f5b6f7b4ab9ba3c13630e0a32f4d16313af359 100644 (file)
@@ -10,6 +10,11 @@ module Puppet::Parser::Functions
     # The Time Zone argument is optional ...
     time_zone = arguments[0] if arguments[0]
 
+    if (arguments.size != 0) and (arguments.size != 1) then
+      raise(Puppet::ParseError, "time(): Wrong number of arguments "+
+        "given #{arguments.size} for 0 or 1")
+    end
+
     time = Time.new
 
     # There is probably a better way to handle Time Zone ...
diff --git a/spec/unit/parser/functions/abs_spec.rb b/spec/unit/parser/functions/abs_spec.rb
new file mode 100755 (executable)
index 0000000..cd2902a
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the abs function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("abs").should == "function_abs"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_abs([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/bool2num_spec.rb b/spec/unit/parser/functions/bool2num_spec.rb
new file mode 100755 (executable)
index 0000000..a2585e9
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the bool2num function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("bool2num").should == "function_bool2num"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_bool2num([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/capitalize_spec.rb b/spec/unit/parser/functions/capitalize_spec.rb
new file mode 100755 (executable)
index 0000000..bb1fe2a
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the capitalize function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("capitalize").should == "function_capitalize"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_capitalize([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/chomp_spec.rb b/spec/unit/parser/functions/chomp_spec.rb
new file mode 100755 (executable)
index 0000000..150a7c8
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the chomp function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("chomp").should == "function_chomp"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_chomp([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/chop_spec.rb b/spec/unit/parser/functions/chop_spec.rb
new file mode 100755 (executable)
index 0000000..ae636cb
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the chop function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("chop").should == "function_chop"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_chop([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/count_spec.rb b/spec/unit/parser/functions/count_spec.rb
new file mode 100755 (executable)
index 0000000..28617c9
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the count function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("count").should == "function_count"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_count([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/date_spec.rb b/spec/unit/parser/functions/date_spec.rb
new file mode 100755 (executable)
index 0000000..dcba4af
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the date function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("date").should == "function_date"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_date([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/delete_at_spec.rb b/spec/unit/parser/functions/delete_at_spec.rb
new file mode 100755 (executable)
index 0000000..a0b5b06
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the delete_at function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("delete_at").should == "function_delete_at"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_delete_at([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/delete_spec.rb b/spec/unit/parser/functions/delete_spec.rb
new file mode 100755 (executable)
index 0000000..b0729ab
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the delete function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("delete").should == "function_delete"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_delete([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/downcase_spec.rb b/spec/unit/parser/functions/downcase_spec.rb
new file mode 100755 (executable)
index 0000000..162291c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the downcase function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("downcase").should == "function_downcase"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_downcase([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/empty_spec.rb b/spec/unit/parser/functions/empty_spec.rb
new file mode 100755 (executable)
index 0000000..beaf45c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the empty function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("empty").should == "function_empty"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_empty([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/fact_spec.rb b/spec/unit/parser/functions/fact_spec.rb
new file mode 100755 (executable)
index 0000000..c013ae0
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the fact function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("fact").should == "function_fact"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_fact([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/flatten_spec.rb b/spec/unit/parser/functions/flatten_spec.rb
new file mode 100755 (executable)
index 0000000..7af23c1
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the flatten function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("flatten").should == "function_flatten"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_flatten([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/grep_spec.rb b/spec/unit/parser/functions/grep_spec.rb
new file mode 100755 (executable)
index 0000000..1c949da
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the grep function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("grep").should == "function_grep"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_grep([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/hash_spec.rb b/spec/unit/parser/functions/hash_spec.rb
new file mode 100644 (file)
index 0000000..09b0d50
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the hash function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("hash").should == "function_hash"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_hash([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/is_array_spec.rb b/spec/unit/parser/functions/is_array_spec.rb
new file mode 100644 (file)
index 0000000..b2843b0
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_array function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("is_array").should == "function_is_array"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_is_array([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/is_float_spec.rb b/spec/unit/parser/functions/is_float_spec.rb
new file mode 100644 (file)
index 0000000..e3dc8fc
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_float function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("is_float").should == "function_is_float"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_is_float([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/is_hash_spec.rb b/spec/unit/parser/functions/is_hash_spec.rb
new file mode 100644 (file)
index 0000000..66dfdeb
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_hash function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("is_hash").should == "function_is_hash"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_is_hash([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/is_integer_spec.rb b/spec/unit/parser/functions/is_integer_spec.rb
new file mode 100644 (file)
index 0000000..131251c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_integer function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("is_integer").should == "function_is_integer"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_is_integer([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/is_numeric_spec.rb b/spec/unit/parser/functions/is_numeric_spec.rb
new file mode 100644 (file)
index 0000000..3a49f5d
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_numeric function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("is_numeric").should == "function_is_numeric"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_is_numeric([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/is_string_spec.rb b/spec/unit/parser/functions/is_string_spec.rb
new file mode 100644 (file)
index 0000000..8c0061e
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_string function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("is_string").should == "function_is_string"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_is_string([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/is_valid_domain_name_spec.rb b/spec/unit/parser/functions/is_valid_domain_name_spec.rb
new file mode 100644 (file)
index 0000000..5cea285
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_valid_domain_name function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("is_valid_domain_name").should == "function_is_valid_domain_name"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_is_valid_domain_name([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/is_valid_ip_address_spec.rb b/spec/unit/parser/functions/is_valid_ip_address_spec.rb
new file mode 100644 (file)
index 0000000..fa803dd
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_valid_ip_address function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("is_valid_ip_address").should == "function_is_valid_ip_address"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_is_valid_ip_address([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/is_valid_mac_address_spec.rb b/spec/unit/parser/functions/is_valid_mac_address_spec.rb
new file mode 100644 (file)
index 0000000..f2a8389
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_valid_mac_address function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("is_valid_mac_address").should == "function_is_valid_mac_address"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_is_valid_mac_address([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/is_valid_netmask_spec.rb b/spec/unit/parser/functions/is_valid_netmask_spec.rb
new file mode 100644 (file)
index 0000000..97cbb7c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the is_valid_netmask function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("is_valid_netmask").should == "function_is_valid_netmask"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_is_valid_netmask([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/join_spec.rb b/spec/unit/parser/functions/join_spec.rb
new file mode 100644 (file)
index 0000000..a7dc0e5
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the join function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("join").should == "function_join"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_join([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/join_with_prefix_spec.rb b/spec/unit/parser/functions/join_with_prefix_spec.rb
new file mode 100644 (file)
index 0000000..0182d8c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the join_with_prefix function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("join_with_prefix").should == "function_join_with_prefix"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_join_with_prefix([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/keys_spec.rb b/spec/unit/parser/functions/keys_spec.rb
new file mode 100644 (file)
index 0000000..13dc260
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the keys function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("keys").should == "function_keys"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_keys([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
index b2afa128bd6ae6d8529177fd97e604f66cb1fe99..abdd529962ed032d49c0a7c07102af11004f7022 100755 (executable)
@@ -56,6 +56,7 @@ describe "the kwalify function" do
       'key1' => 'b',
       'key2' => 'c',
     }
+    @scope.function_kwalify([schema, document])
   end
 
 end
diff --git a/spec/unit/parser/functions/load_json_spec.rb b/spec/unit/parser/functions/load_json_spec.rb
new file mode 100644 (file)
index 0000000..73a4566
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the load_json function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("load_json").should == "function_load_json"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_load_json([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+  it "should convert JSON to a data structure" do
+    json = <<-EOS
+["aaa","bbb","ccc"]
+EOS
+    result = @scope.function_load_json([json])
+    result.should(eq(['aaa','bbb','ccc']))
+  end
+
+end
diff --git a/spec/unit/parser/functions/load_variables_spec.rb b/spec/unit/parser/functions/load_variables_spec.rb
new file mode 100644 (file)
index 0000000..dc29e61
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the load_variables function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("load_variables").should == "function_load_variables"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_load_variables([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/load_yaml_spec.rb b/spec/unit/parser/functions/load_yaml_spec.rb
new file mode 100644 (file)
index 0000000..2498d12
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the load_yaml function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("load_yaml").should == "function_load_yaml"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_load_yaml([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+  it "should convert YAML to a data structure" do
+    yaml = <<-EOS
+- aaa
+- bbb
+- ccc
+EOS
+    result = @scope.function_load_yaml([yaml])
+    result.should(eq(['aaa','bbb','ccc']))
+  end
+
+end
diff --git a/spec/unit/parser/functions/lstrip_spec.rb b/spec/unit/parser/functions/lstrip_spec.rb
new file mode 100644 (file)
index 0000000..9726675
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the lstrip function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("lstrip").should == "function_lstrip"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_lstrip([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/member_spec.rb b/spec/unit/parser/functions/member_spec.rb
new file mode 100644 (file)
index 0000000..39b684f
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the member function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("member").should == "function_member"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_member([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/num2bool_spec.rb b/spec/unit/parser/functions/num2bool_spec.rb
new file mode 100644 (file)
index 0000000..fbd25c8
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the num2bool function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("num2bool").should == "function_num2bool"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_num2bool([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/persistent_crontab_minutes_spec.rb b/spec/unit/parser/functions/persistent_crontab_minutes_spec.rb
new file mode 100644 (file)
index 0000000..1d8cbe7
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the persistent_crontab_minutes function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("persistent_crontab_minutes").should == "function_persistent_crontab_minutes"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_persistent_crontab_minutes([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/prefix_spec.rb b/spec/unit/parser/functions/prefix_spec.rb
new file mode 100644 (file)
index 0000000..9ede439
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the prefix function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("prefix").should == "function_prefix"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_prefix([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/rand_spec.rb b/spec/unit/parser/functions/rand_spec.rb
new file mode 100644 (file)
index 0000000..818d1c5
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the rand function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("rand").should == "function_rand"
+  end
+
+  it "should raise a ParseError if there is not 0 or 1 arguments" do
+    lambda { @scope.function_rand(['a','b']) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/random_crontab_minutes_spec.rb b/spec/unit/parser/functions/random_crontab_minutes_spec.rb
new file mode 100644 (file)
index 0000000..b47b3ae
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the random_crontab_minutes function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("random_crontab_minutes").should == "function_random_crontab_minutes"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_random_crontab_minutes([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/range_spec.rb b/spec/unit/parser/functions/range_spec.rb
new file mode 100644 (file)
index 0000000..23310bc
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the range function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("range").should == "function_range"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_range([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/reverse_spec.rb b/spec/unit/parser/functions/reverse_spec.rb
new file mode 100644 (file)
index 0000000..27aa2cf
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the reverse function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("reverse").should == "function_reverse"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_reverse([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/rstrip_spec.rb b/spec/unit/parser/functions/rstrip_spec.rb
new file mode 100644 (file)
index 0000000..a6e73ec
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the rstrip function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("rstrip").should == "function_rstrip"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_rstrip([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/shuffle_spec.rb b/spec/unit/parser/functions/shuffle_spec.rb
new file mode 100644 (file)
index 0000000..cf063c6
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the shuffle function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("shuffle").should == "function_shuffle"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_shuffle([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/size_spec.rb b/spec/unit/parser/functions/size_spec.rb
new file mode 100644 (file)
index 0000000..0d1f0c4
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the size function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("size").should == "function_size"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_size([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/sort_spec.rb b/spec/unit/parser/functions/sort_spec.rb
new file mode 100644 (file)
index 0000000..ae62d5f
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the sort function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("sort").should == "function_sort"
+  end
+
+  it "should raise a ParseError if there is not 0 arguments" do
+    lambda { @scope.function_sort(['']) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/squeeze_spec.rb b/spec/unit/parser/functions/squeeze_spec.rb
new file mode 100644 (file)
index 0000000..da8965c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the squeeze function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("squeeze").should == "function_squeeze"
+  end
+
+  it "should raise a ParseError if there is less than 2 arguments" do
+    lambda { @scope.function_squeeze([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/str2bool_spec.rb b/spec/unit/parser/functions/str2bool_spec.rb
new file mode 100644 (file)
index 0000000..6a1ac95
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the str2bool function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("str2bool").should == "function_str2bool"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_str2bool([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/strftime_spec.rb b/spec/unit/parser/functions/strftime_spec.rb
new file mode 100644 (file)
index 0000000..e377954
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the strftime function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("strftime").should == "function_strftime"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_strftime([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/strip_spec.rb b/spec/unit/parser/functions/strip_spec.rb
new file mode 100644 (file)
index 0000000..ca06845
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the strip function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("strip").should == "function_strip"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_strip([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/swapcase_spec.rb b/spec/unit/parser/functions/swapcase_spec.rb
new file mode 100644 (file)
index 0000000..7c5ff30
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the swapcase function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("swapcase").should == "function_swapcase"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_swapcase([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/time_spec.rb b/spec/unit/parser/functions/time_spec.rb
new file mode 100644 (file)
index 0000000..8bf5982
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the time function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("time").should == "function_time"
+  end
+
+  it "should raise a ParseError if there is more than 2 arguments" do
+    lambda { @scope.function_time(['','']) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/type_spec.rb b/spec/unit/parser/functions/type_spec.rb
new file mode 100644 (file)
index 0000000..4109da1
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the type function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("type").should == "function_type"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_type([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/unique_spec.rb b/spec/unit/parser/functions/unique_spec.rb
new file mode 100644 (file)
index 0000000..fe7b3ca
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the unique function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("unique").should == "function_unique"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_unique([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/upcase_spec.rb b/spec/unit/parser/functions/upcase_spec.rb
new file mode 100644 (file)
index 0000000..39884eb
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the upcase function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("upcase").should == "function_upcase"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_upcase([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/values_at_spec.rb b/spec/unit/parser/functions/values_at_spec.rb
new file mode 100644 (file)
index 0000000..af5dc25
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the values_at function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("values_at").should == "function_values_at"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_values_at([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/values_spec.rb b/spec/unit/parser/functions/values_spec.rb
new file mode 100644 (file)
index 0000000..2c313a0
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the values function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("values").should == "function_values"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_values([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end
diff --git a/spec/unit/parser/functions/zip_spec.rb b/spec/unit/parser/functions/zip_spec.rb
new file mode 100644 (file)
index 0000000..3d0392a
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe "the zip function" do
+  before :all do
+    Puppet::Parser::Functions.autoloader.loadall
+  end
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("zip").should == "function_zip"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_zip([]) }.should( raise_error(Puppet::ParseError))
+  end
+
+end