From 20aacc5a29f767f09ecf5964068392cf3054bddc Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 10 May 2012 22:00:19 -0700 Subject: Memoize file_line spec instance variables This just changes the instance variables to a memoized let block and gets ride of the before :each block. The patch has no change in behavior. --- spec/unit/puppet/type/file_line_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'spec/unit/puppet') diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 7e07c06..a3e13ea 100644 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -1,19 +1,19 @@ require 'puppet' require 'tempfile' describe Puppet::Type.type(:file_line) do - before :each do - @file_line = Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => '/tmp/path') + let :file_line do + Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => '/tmp/path') end it 'should accept a line and path' do - @file_line[:line] = 'my_line' - @file_line[:line].should == 'my_line' + file_line[:line] = 'my_line' + file_line[:line].should == 'my_line' end it 'should accept posix filenames' do - @file_line[:path] = '/tmp/path' - @file_line[:path].should == '/tmp/path' + file_line[:path] = '/tmp/path' + file_line[:path].should == '/tmp/path' end it 'should not accept unqualified path' do - expect { @file_line[:path] = 'file' }.should raise_error(Puppet::Error, /File paths must be fully qualified/) + expect { file_line[:path] = 'file' }.should raise_error(Puppet::Error, /File paths must be fully qualified/) end it 'should require that a line is specified' do expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file') }.should raise_error(Puppet::Error, /Both line and path are required attributes/) -- cgit v1.2.3 From 1373e70639e0105ec314c006bd82545573a389e6 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 10 May 2012 21:36:46 -0700 Subject: Make file_line default to ensure => present The examples in the file_line resource documentation state the following resource should work: file_line { 'sudo_rule': path => '/etc/sudoers', line => '%sudo ALL=(ALL) ALL', } Without this patch the example does not work because ensure is not set to present. This patch fixes the problem by setting the default value of ensure to present. --- spec/unit/puppet/type/file_line_spec.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'spec/unit/puppet') diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index a3e13ea..c86dbd2 100644 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -21,4 +21,7 @@ describe Puppet::Type.type(:file_line) do it 'should require that a file is specified' do expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.should raise_error(Puppet::Error, /Both line and path are required attributes/) end + it 'should default to ensure => present' do + file_line[:ensure].should eq :present + end end -- cgit v1.2.3 From f604bae98cb377b6fc55185d4eeae05d1c7876d2 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 19 Jul 2012 15:27:52 -0700 Subject: (Maint) Fix interpreter lines This time around I actually know why I'm doing this thanks to the reminder from Nick Lewis. Ruby will replace itself in memory with the executable listed in the interpreter line if the string "ruby" is not in there. Since /usr/bin/env rspec doesn't contain the substring "ruby", you can't actually run ruby -W1 or whatever on the file. This patch fixes the problem by making sure "ruby" is present, preventing ruby from replacing itself in memory. --- spec/unit/puppet/parser/functions/abs_spec.rb | 2 +- spec/unit/puppet/parser/functions/bool2num_spec.rb | 2 +- spec/unit/puppet/parser/functions/capitalize_spec.rb | 2 +- spec/unit/puppet/parser/functions/chomp_spec.rb | 2 +- spec/unit/puppet/parser/functions/chop_spec.rb | 2 +- spec/unit/puppet/parser/functions/delete_at_spec.rb | 2 +- spec/unit/puppet/parser/functions/delete_spec.rb | 2 +- spec/unit/puppet/parser/functions/downcase_spec.rb | 2 +- spec/unit/puppet/parser/functions/empty_spec.rb | 2 +- spec/unit/puppet/parser/functions/flatten_spec.rb | 2 +- spec/unit/puppet/parser/functions/grep_spec.rb | 2 +- spec/unit/puppet/parser/functions/hash_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_array_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_domain_name_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_float_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_hash_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_integer_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_ip_address_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_mac_address_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_numeric_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_string_spec.rb | 2 +- spec/unit/puppet/parser/functions/join_spec.rb | 2 +- spec/unit/puppet/parser/functions/keys_spec.rb | 2 +- spec/unit/puppet/parser/functions/lstrip_spec.rb | 2 +- spec/unit/puppet/parser/functions/member_spec.rb | 2 +- spec/unit/puppet/parser/functions/num2bool_spec.rb | 2 +- spec/unit/puppet/parser/functions/parsejson_spec.rb | 2 +- spec/unit/puppet/parser/functions/parseyaml_spec.rb | 2 +- spec/unit/puppet/parser/functions/prefix_spec.rb | 2 +- spec/unit/puppet/parser/functions/range_spec.rb | 2 +- spec/unit/puppet/parser/functions/reverse_spec.rb | 2 +- spec/unit/puppet/parser/functions/rstrip_spec.rb | 2 +- spec/unit/puppet/parser/functions/shuffle_spec.rb | 2 +- spec/unit/puppet/parser/functions/size_spec.rb | 2 +- spec/unit/puppet/parser/functions/sort_spec.rb | 2 +- spec/unit/puppet/parser/functions/squeeze_spec.rb | 2 +- spec/unit/puppet/parser/functions/str2bool_spec.rb | 2 +- spec/unit/puppet/parser/functions/strftime_spec.rb | 2 +- spec/unit/puppet/parser/functions/strip_spec.rb | 2 +- spec/unit/puppet/parser/functions/swapcase_spec.rb | 2 +- spec/unit/puppet/parser/functions/time_spec.rb | 2 +- spec/unit/puppet/parser/functions/type_spec.rb | 2 +- spec/unit/puppet/parser/functions/unique_spec.rb | 2 +- spec/unit/puppet/parser/functions/upcase_spec.rb | 2 +- spec/unit/puppet/parser/functions/values_at_spec.rb | 2 +- spec/unit/puppet/parser/functions/values_spec.rb | 2 +- spec/unit/puppet/parser/functions/zip_spec.rb | 2 +- 47 files changed, 47 insertions(+), 47 deletions(-) (limited to 'spec/unit/puppet') diff --git a/spec/unit/puppet/parser/functions/abs_spec.rb b/spec/unit/puppet/parser/functions/abs_spec.rb index 65ba2e8..2361b93 100755 --- a/spec/unit/puppet/parser/functions/abs_spec.rb +++ b/spec/unit/puppet/parser/functions/abs_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the abs function" do diff --git a/spec/unit/puppet/parser/functions/bool2num_spec.rb b/spec/unit/puppet/parser/functions/bool2num_spec.rb index d5da18c..10fc21b 100755 --- a/spec/unit/puppet/parser/functions/bool2num_spec.rb +++ b/spec/unit/puppet/parser/functions/bool2num_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the bool2num function" do diff --git a/spec/unit/puppet/parser/functions/capitalize_spec.rb b/spec/unit/puppet/parser/functions/capitalize_spec.rb index 1c45821..a173f2f 100755 --- a/spec/unit/puppet/parser/functions/capitalize_spec.rb +++ b/spec/unit/puppet/parser/functions/capitalize_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the capitalize function" do diff --git a/spec/unit/puppet/parser/functions/chomp_spec.rb b/spec/unit/puppet/parser/functions/chomp_spec.rb index 0592115..3134e53 100755 --- a/spec/unit/puppet/parser/functions/chomp_spec.rb +++ b/spec/unit/puppet/parser/functions/chomp_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the chomp function" do diff --git a/spec/unit/puppet/parser/functions/chop_spec.rb b/spec/unit/puppet/parser/functions/chop_spec.rb index 0c456a8..c708867 100755 --- a/spec/unit/puppet/parser/functions/chop_spec.rb +++ b/spec/unit/puppet/parser/functions/chop_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the chop function" do diff --git a/spec/unit/puppet/parser/functions/delete_at_spec.rb b/spec/unit/puppet/parser/functions/delete_at_spec.rb index 27db0c8..cf10197 100755 --- a/spec/unit/puppet/parser/functions/delete_at_spec.rb +++ b/spec/unit/puppet/parser/functions/delete_at_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the delete_at function" do diff --git a/spec/unit/puppet/parser/functions/delete_spec.rb b/spec/unit/puppet/parser/functions/delete_spec.rb index fab3230..90b2eab 100755 --- a/spec/unit/puppet/parser/functions/delete_spec.rb +++ b/spec/unit/puppet/parser/functions/delete_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the delete function" do diff --git a/spec/unit/puppet/parser/functions/downcase_spec.rb b/spec/unit/puppet/parser/functions/downcase_spec.rb index 0bccd5f..bc4f797 100755 --- a/spec/unit/puppet/parser/functions/downcase_spec.rb +++ b/spec/unit/puppet/parser/functions/downcase_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the downcase function" do diff --git a/spec/unit/puppet/parser/functions/empty_spec.rb b/spec/unit/puppet/parser/functions/empty_spec.rb index cb0021f..8d69c83 100755 --- a/spec/unit/puppet/parser/functions/empty_spec.rb +++ b/spec/unit/puppet/parser/functions/empty_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the empty function" do diff --git a/spec/unit/puppet/parser/functions/flatten_spec.rb b/spec/unit/puppet/parser/functions/flatten_spec.rb index 7bedeb2..e186fad 100755 --- a/spec/unit/puppet/parser/functions/flatten_spec.rb +++ b/spec/unit/puppet/parser/functions/flatten_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the flatten function" do diff --git a/spec/unit/puppet/parser/functions/grep_spec.rb b/spec/unit/puppet/parser/functions/grep_spec.rb index b1f647c..97f31a0 100755 --- a/spec/unit/puppet/parser/functions/grep_spec.rb +++ b/spec/unit/puppet/parser/functions/grep_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the grep function" do diff --git a/spec/unit/puppet/parser/functions/hash_spec.rb b/spec/unit/puppet/parser/functions/hash_spec.rb index 6d3d48c..f76fbe3 100644 --- a/spec/unit/puppet/parser/functions/hash_spec.rb +++ b/spec/unit/puppet/parser/functions/hash_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the hash function" do diff --git a/spec/unit/puppet/parser/functions/is_array_spec.rb b/spec/unit/puppet/parser/functions/is_array_spec.rb index 537595c..6a46bfe 100644 --- a/spec/unit/puppet/parser/functions/is_array_spec.rb +++ b/spec/unit/puppet/parser/functions/is_array_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_array function" do diff --git a/spec/unit/puppet/parser/functions/is_domain_name_spec.rb b/spec/unit/puppet/parser/functions/is_domain_name_spec.rb index ccd3276..2e17dfb 100644 --- a/spec/unit/puppet/parser/functions/is_domain_name_spec.rb +++ b/spec/unit/puppet/parser/functions/is_domain_name_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_domain_name function" do diff --git a/spec/unit/puppet/parser/functions/is_float_spec.rb b/spec/unit/puppet/parser/functions/is_float_spec.rb index 55ba8cf..2cfc789 100644 --- a/spec/unit/puppet/parser/functions/is_float_spec.rb +++ b/spec/unit/puppet/parser/functions/is_float_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_float function" do diff --git a/spec/unit/puppet/parser/functions/is_hash_spec.rb b/spec/unit/puppet/parser/functions/is_hash_spec.rb index 94364f5..112c9ab 100644 --- a/spec/unit/puppet/parser/functions/is_hash_spec.rb +++ b/spec/unit/puppet/parser/functions/is_hash_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_hash function" do diff --git a/spec/unit/puppet/parser/functions/is_integer_spec.rb b/spec/unit/puppet/parser/functions/is_integer_spec.rb index faf6f2d..d4b8f6b 100644 --- a/spec/unit/puppet/parser/functions/is_integer_spec.rb +++ b/spec/unit/puppet/parser/functions/is_integer_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_integer function" do diff --git a/spec/unit/puppet/parser/functions/is_ip_address_spec.rb b/spec/unit/puppet/parser/functions/is_ip_address_spec.rb index 98ce828..7930634 100644 --- a/spec/unit/puppet/parser/functions/is_ip_address_spec.rb +++ b/spec/unit/puppet/parser/functions/is_ip_address_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_ip_address function" do diff --git a/spec/unit/puppet/parser/functions/is_mac_address_spec.rb b/spec/unit/puppet/parser/functions/is_mac_address_spec.rb index c9b9637..4ba896e 100644 --- a/spec/unit/puppet/parser/functions/is_mac_address_spec.rb +++ b/spec/unit/puppet/parser/functions/is_mac_address_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_mac_address function" do diff --git a/spec/unit/puppet/parser/functions/is_numeric_spec.rb b/spec/unit/puppet/parser/functions/is_numeric_spec.rb index 2191b7b..0b0a834 100644 --- a/spec/unit/puppet/parser/functions/is_numeric_spec.rb +++ b/spec/unit/puppet/parser/functions/is_numeric_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_numeric function" do diff --git a/spec/unit/puppet/parser/functions/is_string_spec.rb b/spec/unit/puppet/parser/functions/is_string_spec.rb index 4f3f5fd..e54562d 100644 --- a/spec/unit/puppet/parser/functions/is_string_spec.rb +++ b/spec/unit/puppet/parser/functions/is_string_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_string function" do diff --git a/spec/unit/puppet/parser/functions/join_spec.rb b/spec/unit/puppet/parser/functions/join_spec.rb index 1b3dec8..60c1c95 100644 --- a/spec/unit/puppet/parser/functions/join_spec.rb +++ b/spec/unit/puppet/parser/functions/join_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the join function" do diff --git a/spec/unit/puppet/parser/functions/keys_spec.rb b/spec/unit/puppet/parser/functions/keys_spec.rb index d928562..455acb8 100644 --- a/spec/unit/puppet/parser/functions/keys_spec.rb +++ b/spec/unit/puppet/parser/functions/keys_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the keys function" do diff --git a/spec/unit/puppet/parser/functions/lstrip_spec.rb b/spec/unit/puppet/parser/functions/lstrip_spec.rb index ac331fa..1bac793 100644 --- a/spec/unit/puppet/parser/functions/lstrip_spec.rb +++ b/spec/unit/puppet/parser/functions/lstrip_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the lstrip function" do diff --git a/spec/unit/puppet/parser/functions/member_spec.rb b/spec/unit/puppet/parser/functions/member_spec.rb index 2cebc0d..8462e04 100644 --- a/spec/unit/puppet/parser/functions/member_spec.rb +++ b/spec/unit/puppet/parser/functions/member_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the member function" do diff --git a/spec/unit/puppet/parser/functions/num2bool_spec.rb b/spec/unit/puppet/parser/functions/num2bool_spec.rb index 6585273..3c9f846 100644 --- a/spec/unit/puppet/parser/functions/num2bool_spec.rb +++ b/spec/unit/puppet/parser/functions/num2bool_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the num2bool function" do diff --git a/spec/unit/puppet/parser/functions/parsejson_spec.rb b/spec/unit/puppet/parser/functions/parsejson_spec.rb index 26eea36..22fe27e 100644 --- a/spec/unit/puppet/parser/functions/parsejson_spec.rb +++ b/spec/unit/puppet/parser/functions/parsejson_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the parsejson function" do diff --git a/spec/unit/puppet/parser/functions/parseyaml_spec.rb b/spec/unit/puppet/parser/functions/parseyaml_spec.rb index f9cb049..7c29f1a 100644 --- a/spec/unit/puppet/parser/functions/parseyaml_spec.rb +++ b/spec/unit/puppet/parser/functions/parseyaml_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the parseyaml function" do diff --git a/spec/unit/puppet/parser/functions/prefix_spec.rb b/spec/unit/puppet/parser/functions/prefix_spec.rb index a0cbcab..c093d9e 100644 --- a/spec/unit/puppet/parser/functions/prefix_spec.rb +++ b/spec/unit/puppet/parser/functions/prefix_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the prefix function" do diff --git a/spec/unit/puppet/parser/functions/range_spec.rb b/spec/unit/puppet/parser/functions/range_spec.rb index 060423a..210fec8 100644 --- a/spec/unit/puppet/parser/functions/range_spec.rb +++ b/spec/unit/puppet/parser/functions/range_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the range function" do diff --git a/spec/unit/puppet/parser/functions/reverse_spec.rb b/spec/unit/puppet/parser/functions/reverse_spec.rb index 4fa50e4..a07bdd6 100644 --- a/spec/unit/puppet/parser/functions/reverse_spec.rb +++ b/spec/unit/puppet/parser/functions/reverse_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the reverse function" do diff --git a/spec/unit/puppet/parser/functions/rstrip_spec.rb b/spec/unit/puppet/parser/functions/rstrip_spec.rb index af8cc12..b6a461a 100644 --- a/spec/unit/puppet/parser/functions/rstrip_spec.rb +++ b/spec/unit/puppet/parser/functions/rstrip_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the rstrip function" do diff --git a/spec/unit/puppet/parser/functions/shuffle_spec.rb b/spec/unit/puppet/parser/functions/shuffle_spec.rb index f04fda5..e66fdc5 100644 --- a/spec/unit/puppet/parser/functions/shuffle_spec.rb +++ b/spec/unit/puppet/parser/functions/shuffle_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the shuffle function" do diff --git a/spec/unit/puppet/parser/functions/size_spec.rb b/spec/unit/puppet/parser/functions/size_spec.rb index ccaa335..20c3580 100644 --- a/spec/unit/puppet/parser/functions/size_spec.rb +++ b/spec/unit/puppet/parser/functions/size_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the size function" do diff --git a/spec/unit/puppet/parser/functions/sort_spec.rb b/spec/unit/puppet/parser/functions/sort_spec.rb index fbe3073..0f2343a 100644 --- a/spec/unit/puppet/parser/functions/sort_spec.rb +++ b/spec/unit/puppet/parser/functions/sort_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the sort function" do diff --git a/spec/unit/puppet/parser/functions/squeeze_spec.rb b/spec/unit/puppet/parser/functions/squeeze_spec.rb index 9355ad2..4e84c12 100644 --- a/spec/unit/puppet/parser/functions/squeeze_spec.rb +++ b/spec/unit/puppet/parser/functions/squeeze_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the squeeze function" do diff --git a/spec/unit/puppet/parser/functions/str2bool_spec.rb b/spec/unit/puppet/parser/functions/str2bool_spec.rb index d7f0ac9..fff9f5d 100644 --- a/spec/unit/puppet/parser/functions/str2bool_spec.rb +++ b/spec/unit/puppet/parser/functions/str2bool_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the str2bool function" do diff --git a/spec/unit/puppet/parser/functions/strftime_spec.rb b/spec/unit/puppet/parser/functions/strftime_spec.rb index f7a2cd9..a0ca9d5 100644 --- a/spec/unit/puppet/parser/functions/strftime_spec.rb +++ b/spec/unit/puppet/parser/functions/strftime_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the strftime function" do diff --git a/spec/unit/puppet/parser/functions/strip_spec.rb b/spec/unit/puppet/parser/functions/strip_spec.rb index 48a52dd..c051038 100644 --- a/spec/unit/puppet/parser/functions/strip_spec.rb +++ b/spec/unit/puppet/parser/functions/strip_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the strip function" do diff --git a/spec/unit/puppet/parser/functions/swapcase_spec.rb b/spec/unit/puppet/parser/functions/swapcase_spec.rb index 2686054..b40e199 100644 --- a/spec/unit/puppet/parser/functions/swapcase_spec.rb +++ b/spec/unit/puppet/parser/functions/swapcase_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the swapcase function" do diff --git a/spec/unit/puppet/parser/functions/time_spec.rb b/spec/unit/puppet/parser/functions/time_spec.rb index 5d6cd97..4b1ab5e 100644 --- a/spec/unit/puppet/parser/functions/time_spec.rb +++ b/spec/unit/puppet/parser/functions/time_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the time function" do diff --git a/spec/unit/puppet/parser/functions/type_spec.rb b/spec/unit/puppet/parser/functions/type_spec.rb index e3c28ed..ad5efdc 100644 --- a/spec/unit/puppet/parser/functions/type_spec.rb +++ b/spec/unit/puppet/parser/functions/type_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the type function" do diff --git a/spec/unit/puppet/parser/functions/unique_spec.rb b/spec/unit/puppet/parser/functions/unique_spec.rb index 627dc33..82edb26 100644 --- a/spec/unit/puppet/parser/functions/unique_spec.rb +++ b/spec/unit/puppet/parser/functions/unique_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the unique function" do diff --git a/spec/unit/puppet/parser/functions/upcase_spec.rb b/spec/unit/puppet/parser/functions/upcase_spec.rb index 5d18846..d779b16 100644 --- a/spec/unit/puppet/parser/functions/upcase_spec.rb +++ b/spec/unit/puppet/parser/functions/upcase_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the upcase function" do diff --git a/spec/unit/puppet/parser/functions/values_at_spec.rb b/spec/unit/puppet/parser/functions/values_at_spec.rb index 6c45316..c1c9a6a 100644 --- a/spec/unit/puppet/parser/functions/values_at_spec.rb +++ b/spec/unit/puppet/parser/functions/values_at_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the values_at function" do diff --git a/spec/unit/puppet/parser/functions/values_spec.rb b/spec/unit/puppet/parser/functions/values_spec.rb index a5fbbd8..0c7f1f9 100644 --- a/spec/unit/puppet/parser/functions/values_spec.rb +++ b/spec/unit/puppet/parser/functions/values_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the values function" do diff --git a/spec/unit/puppet/parser/functions/zip_spec.rb b/spec/unit/puppet/parser/functions/zip_spec.rb index 074f4df..9badb06 100644 --- a/spec/unit/puppet/parser/functions/zip_spec.rb +++ b/spec/unit/puppet/parser/functions/zip_spec.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the zip function" do -- cgit v1.2.3 From 8a4e115ccb14d409878d46d456cc9b93fdc24867 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 19 Jul 2012 16:14:37 -0700 Subject: (Maint) use PuppetlabsSpec::PuppetSeams.parser_scope Without this patch all of the spec tests for parser functions in stdlib would instantiate their own scope instances. This is a problem because the standard library is tightly coupled with the internal behavior of Puppet. Tight coupling like this creates failures when we change the internal behavior of Puppet. This is exactly what happened recently when we changed the method signature for the initializer of Puppet::Parser::Scope instances. This patch fixes the problem by creating scope instances using the puppet labs spec helper. The specific method that provides scope instances in Puppet-version-independent way is something like this: let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } This patch simply implements this across the board. --- spec/unit/puppet/parser/functions/abs_spec.rb | 16 +++----- spec/unit/puppet/parser/functions/bool2num_spec.rb | 15 ++------ .../puppet/parser/functions/capitalize_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/chomp_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/chop_spec.rb | 13 ++----- .../unit/puppet/parser/functions/delete_at_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/delete_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/downcase_spec.rb | 15 ++------ spec/unit/puppet/parser/functions/empty_spec.rb | 16 ++------ spec/unit/puppet/parser/functions/flatten_spec.rb | 16 ++------ spec/unit/puppet/parser/functions/getvar_spec.rb | 35 +++--------------- spec/unit/puppet/parser/functions/grep_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/has_key_spec.rb | 31 ++++------------ spec/unit/puppet/parser/functions/hash_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/is_array_spec.rb | 17 +++------ .../puppet/parser/functions/is_domain_name_spec.rb | 6 +-- spec/unit/puppet/parser/functions/is_float_spec.rb | 17 +++------ spec/unit/puppet/parser/functions/is_hash_spec.rb | 17 +++------ .../puppet/parser/functions/is_integer_spec.rb | 17 +++------ .../puppet/parser/functions/is_ip_address_spec.rb | 20 ++++------ .../puppet/parser/functions/is_mac_address_spec.rb | 17 +++------ .../puppet/parser/functions/is_numeric_spec.rb | 17 +++------ .../unit/puppet/parser/functions/is_string_spec.rb | 19 +++------- spec/unit/puppet/parser/functions/join_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/keys_spec.rb | 6 +-- spec/unit/puppet/parser/functions/lstrip_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/member_spec.rb | 19 +++------- spec/unit/puppet/parser/functions/merge_spec.rb | 31 ++++------------ spec/unit/puppet/parser/functions/num2bool_spec.rb | 15 ++------ .../unit/puppet/parser/functions/parsejson_spec.rb | 13 ++----- .../unit/puppet/parser/functions/parseyaml_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/prefix_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/range_spec.rb | 8 +--- spec/unit/puppet/parser/functions/reverse_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/rstrip_spec.rb | 15 ++------ spec/unit/puppet/parser/functions/shuffle_spec.rb | 15 ++------ spec/unit/puppet/parser/functions/size_spec.rb | 15 ++------ spec/unit/puppet/parser/functions/sort_spec.rb | 15 ++------ spec/unit/puppet/parser/functions/squeeze_spec.rb | 15 ++------ spec/unit/puppet/parser/functions/str2bool_spec.rb | 15 ++------ spec/unit/puppet/parser/functions/strftime_spec.rb | 17 +++------ spec/unit/puppet/parser/functions/strip_spec.rb | 14 ++----- spec/unit/puppet/parser/functions/swapcase_spec.rb | 13 ++----- spec/unit/puppet/parser/functions/time_spec.rb | 17 +++------ spec/unit/puppet/parser/functions/type_spec.rb | 24 ++++-------- spec/unit/puppet/parser/functions/unique_spec.rb | 15 ++------ spec/unit/puppet/parser/functions/upcase_spec.rb | 15 ++------ .../puppet/parser/functions/validate_array_spec.rb | 39 ++++---------------- .../puppet/parser/functions/validate_bool_spec.rb | 43 +++++----------------- .../puppet/parser/functions/validate_hash_spec.rb | 33 ++++------------- .../parser/functions/validate_string_spec.rb | 42 +++++---------------- .../unit/puppet/parser/functions/values_at_spec.rb | 21 ++++------- spec/unit/puppet/parser/functions/values_spec.rb | 6 +-- spec/unit/puppet/parser/functions/zip_spec.rb | 17 ++------- 54 files changed, 236 insertions(+), 709 deletions(-) (limited to 'spec/unit/puppet') diff --git a/spec/unit/puppet/parser/functions/abs_spec.rb b/spec/unit/puppet/parser/functions/abs_spec.rb index 2361b93..68e1b3a 100755 --- a/spec/unit/puppet/parser/functions/abs_spec.rb +++ b/spec/unit/puppet/parser/functions/abs_spec.rb @@ -1,31 +1,25 @@ #! /usr/bin/env ruby -S 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_abs([]) }.should( raise_error(Puppet::ParseError)) end it "should convert a negative number into a positive" do - result = @scope.function_abs(["-34"]) + result = scope.function_abs(["-34"]) result.should(eq(34)) end it "should do nothing with a positive number" do - result = @scope.function_abs(["5678"]) + result = scope.function_abs(["5678"]) result.should(eq(5678)) end - end diff --git a/spec/unit/puppet/parser/functions/bool2num_spec.rb b/spec/unit/puppet/parser/functions/bool2num_spec.rb index 10fc21b..d54f089 100755 --- a/spec/unit/puppet/parser/functions/bool2num_spec.rb +++ b/spec/unit/puppet/parser/functions/bool2num_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_bool2num([]) }.should( raise_error(Puppet::ParseError)) end it "should convert true to 1" do - result = @scope.function_bool2num([true]) + result = scope.function_bool2num([true]) result.should(eq(1)) end it "should convert false to 0" do - result = @scope.function_bool2num([false]) + result = scope.function_bool2num([false]) result.should(eq(0)) end - end diff --git a/spec/unit/puppet/parser/functions/capitalize_spec.rb b/spec/unit/puppet/parser/functions/capitalize_spec.rb index a173f2f..9736d5f 100755 --- a/spec/unit/puppet/parser/functions/capitalize_spec.rb +++ b/spec/unit/puppet/parser/functions/capitalize_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_capitalize([]) }.should( raise_error(Puppet::ParseError)) end it "should capitalize the beginning of a string" do - result = @scope.function_capitalize(["abc"]) + result = scope.function_capitalize(["abc"]) result.should(eq("Abc")) end - end diff --git a/spec/unit/puppet/parser/functions/chomp_spec.rb b/spec/unit/puppet/parser/functions/chomp_spec.rb index 3134e53..1aacaa0 100755 --- a/spec/unit/puppet/parser/functions/chomp_spec.rb +++ b/spec/unit/puppet/parser/functions/chomp_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_chomp([]) }.should( raise_error(Puppet::ParseError)) end it "should chomp the end of a string" do - result = @scope.function_chomp(["abc\n"]) + result = scope.function_chomp(["abc\n"]) result.should(eq("abc")) end - end diff --git a/spec/unit/puppet/parser/functions/chop_spec.rb b/spec/unit/puppet/parser/functions/chop_spec.rb index c708867..b12a4d1 100755 --- a/spec/unit/puppet/parser/functions/chop_spec.rb +++ b/spec/unit/puppet/parser/functions/chop_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_chop([]) }.should( raise_error(Puppet::ParseError)) end it "should chop the end of a string" do - result = @scope.function_chop(["asdf\n"]) + result = scope.function_chop(["asdf\n"]) result.should(eq("asdf")) end - end diff --git a/spec/unit/puppet/parser/functions/delete_at_spec.rb b/spec/unit/puppet/parser/functions/delete_at_spec.rb index cf10197..d6a21da 100755 --- a/spec/unit/puppet/parser/functions/delete_at_spec.rb +++ b/spec/unit/puppet/parser/functions/delete_at_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_delete_at([]) }.should( raise_error(Puppet::ParseError)) end it "should delete an item at specified location from an array" do - result = @scope.function_delete_at([['a','b','c'],1]) + result = scope.function_delete_at([['a','b','c'],1]) result.should(eq(['a','c'])) end - end diff --git a/spec/unit/puppet/parser/functions/delete_spec.rb b/spec/unit/puppet/parser/functions/delete_spec.rb index 90b2eab..74d46fc 100755 --- a/spec/unit/puppet/parser/functions/delete_spec.rb +++ b/spec/unit/puppet/parser/functions/delete_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_delete([]) }.should( raise_error(Puppet::ParseError)) end it "should delete an item from an array" do - result = @scope.function_delete([['a','b','c'],'b']) + result = scope.function_delete([['a','b','c'],'b']) result.should(eq(['a','c'])) end - end diff --git a/spec/unit/puppet/parser/functions/downcase_spec.rb b/spec/unit/puppet/parser/functions/downcase_spec.rb index bc4f797..5c2ebe6 100755 --- a/spec/unit/puppet/parser/functions/downcase_spec.rb +++ b/spec/unit/puppet/parser/functions/downcase_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_downcase([]) }.should( raise_error(Puppet::ParseError)) end it "should downcase a string" do - result = @scope.function_downcase(["ASFD"]) + result = scope.function_downcase(["ASFD"]) result.should(eq("asfd")) end it "should do nothing to a string that is already downcase" do - result = @scope.function_downcase(["asdf asdf"]) + result = scope.function_downcase(["asdf asdf"]) result.should(eq("asdf asdf")) end - end diff --git a/spec/unit/puppet/parser/functions/empty_spec.rb b/spec/unit/puppet/parser/functions/empty_spec.rb index 8d69c83..75eec5a 100755 --- a/spec/unit/puppet/parser/functions/empty_spec.rb +++ b/spec/unit/puppet/parser/functions/empty_spec.rb @@ -2,30 +2,22 @@ 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 - + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_empty([]) }.should( raise_error(Puppet::ParseError)) end it "should return a true for an empty string" do - result = @scope.function_empty(['']) + result = scope.function_empty(['']) result.should(eq(true)) end it "should return a false for a non-empty string" do - result = @scope.function_empty(['asdf']) + result = scope.function_empty(['asdf']) result.should(eq(false)) end - end diff --git a/spec/unit/puppet/parser/functions/flatten_spec.rb b/spec/unit/puppet/parser/functions/flatten_spec.rb index e186fad..adb03f4 100755 --- a/spec/unit/puppet/parser/functions/flatten_spec.rb +++ b/spec/unit/puppet/parser/functions/flatten_spec.rb @@ -2,30 +2,22 @@ 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 - + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_flatten([]) }.should( raise_error(Puppet::ParseError)) end it "should flatten a complex data structure" do - result = @scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]]) + result = scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]]) result.should(eq(["a","b","c","d","e","f","g"])) end it "should do nothing to a structure that is already flat" do - result = @scope.function_flatten([["a","b","c","d"]]) + result = scope.function_flatten([["a","b","c","d"]]) result.should(eq(["a","b","c","d"])) end - end diff --git a/spec/unit/puppet/parser/functions/getvar_spec.rb b/spec/unit/puppet/parser/functions/getvar_spec.rb index 16edd98..0fb9c83 100644 --- a/spec/unit/puppet/parser/functions/getvar_spec.rb +++ b/spec/unit/puppet/parser/functions/getvar_spec.rb @@ -1,36 +1,17 @@ -require 'puppet' +#! /usr/bin/env ruby -S rspec +require 'spec_helper' -# We don't need this for the basic tests we're doing -# require 'spec_helper' - -# Dan mentioned that Nick recommended the function method call -# to return the string value for the test description. -# this will not even try the test if the function cannot be -# loaded. describe Puppet::Parser::Functions.function(:getvar) do - - # Pulled from Dan's create_resources function - def get_scope - @topscope = Puppet::Parser::Scope.new - # This is necessary so we don't try to use the compiler to discover our parent. - @topscope.parent = nil - @scope = Puppet::Parser::Scope.new - @scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - @scope.parent = @topscope - @compiler = @scope.compiler - end - + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } describe 'when calling getvar from puppet' do it "should not compile when no arguments are passed" do Puppet[:code] = 'getvar()' - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) end it "should not compile when too many arguments are passed" do Puppet[:code] = 'getvar("foo::bar", "baz")' - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) end it "should lookup variables in other namespaces" do @@ -43,11 +24,7 @@ describe Puppet::Parser::Functions.function(:getvar) do fail('getvar did not return what we expect') } ENDofPUPPETcode - get_scope - @scope.compiler.compile + scope.compiler.compile end - end - end - diff --git a/spec/unit/puppet/parser/functions/grep_spec.rb b/spec/unit/puppet/parser/functions/grep_spec.rb index 97f31a0..d84c401 100755 --- a/spec/unit/puppet/parser/functions/grep_spec.rb +++ b/spec/unit/puppet/parser/functions/grep_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_grep([]) }.should( raise_error(Puppet::ParseError)) end it "should grep contents from an array" do - result = @scope.function_grep([["aaabbb","bbbccc","dddeee"], "bbb"]) + result = scope.function_grep([["aaabbb","bbbccc","dddeee"], "bbb"]) result.should(eq(["aaabbb","bbbccc"])) end - end diff --git a/spec/unit/puppet/parser/functions/has_key_spec.rb b/spec/unit/puppet/parser/functions/has_key_spec.rb index d1dcd15..20ba57e 100644 --- a/spec/unit/puppet/parser/functions/has_key_spec.rb +++ b/spec/unit/puppet/parser/functions/has_key_spec.rb @@ -1,37 +1,21 @@ -require 'puppet' -require 'mocha' -describe Puppet::Parser::Functions.function(:has_key) do +#! /usr/bin/env ruby -S rspec +require 'spec_helper' - # Pulled from Dan's create_resources function - # TODO - this should be moved to spec_helper since the - # logic is likely to be applied to multiple rspec files. - let(:compiler) { - topscope = Puppet::Parser::Scope.new - # This is necessary so we don't try to use the compiler to discover our parent. - topscope.parent = nil - my_scope = Puppet::Parser::Scope.new - my_scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - my_scope.parent = topscope - compiler = my_scope.compiler - } - let(:scope) { - scope = Puppet::Parser::Scope.new - scope.stubs(:environment).returns(Puppet::Node::Environment.new('production')) - scope - } +describe Puppet::Parser::Functions.function(:has_key) do + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } describe 'when calling has_key from puppet' do it "should not compile when no arguments are passed" do Puppet[:code] = 'has_key()' - expect { compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) end it "should not compile when 1 argument is passed" do Puppet[:code] = "has_key('foo')" - expect { compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) end it "should require the first value to be a Hash" do Puppet[:code] = "has_key('foo', 'bar')" - expect { compiler.compile }.should raise_error(Puppet::ParseError, /expects the first argument to be a hash/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /expects the first argument to be a hash/) end end describe 'when calling the function has_key from a scope instance' do @@ -42,5 +26,4 @@ describe Puppet::Parser::Functions.function(:has_key) do scope.function_has_key([{'one' => 1}, 'two']).should be_false end end - end diff --git a/spec/unit/puppet/parser/functions/hash_spec.rb b/spec/unit/puppet/parser/functions/hash_spec.rb index f76fbe3..ee09ef7 100644 --- a/spec/unit/puppet/parser/functions/hash_spec.rb +++ b/spec/unit/puppet/parser/functions/hash_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_hash([]) }.should( raise_error(Puppet::ParseError)) end it "should convert an array to a hash" do - result = @scope.function_hash([['a',1,'b',2,'c',3]]) + result = scope.function_hash([['a',1,'b',2,'c',3]]) result.should(eq({'a'=>1,'b'=>2,'c'=>3})) end - end diff --git a/spec/unit/puppet/parser/functions/is_array_spec.rb b/spec/unit/puppet/parser/functions/is_array_spec.rb index 6a46bfe..ebd472b 100644 --- a/spec/unit/puppet/parser/functions/is_array_spec.rb +++ b/spec/unit/puppet/parser/functions/is_array_spec.rb @@ -2,35 +2,28 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_is_array([]) }.should( raise_error(Puppet::ParseError)) end it "should return true if passed an array" do - result = @scope.function_is_array([[1,2,3]]) + result = scope.function_is_array([[1,2,3]]) result.should(eq(true)) end it "should return false if passed a hash" do - result = @scope.function_is_array([{'a'=>1}]) + result = scope.function_is_array([{'a'=>1}]) result.should(eq(false)) end it "should return false if passed a string" do - result = @scope.function_is_array(["asdf"]) + result = scope.function_is_array(["asdf"]) result.should(eq(false)) end - end diff --git a/spec/unit/puppet/parser/functions/is_domain_name_spec.rb b/spec/unit/puppet/parser/functions/is_domain_name_spec.rb index 2e17dfb..d8467bf 100644 --- a/spec/unit/puppet/parser/functions/is_domain_name_spec.rb +++ b/spec/unit/puppet/parser/functions/is_domain_name_spec.rb @@ -2,11 +2,7 @@ require 'spec_helper' describe "the is_domain_name function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - let(:scope) { Puppet::Parser::Scope.new } + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } it "should exist" do Puppet::Parser::Functions.function("is_domain_name").should == "function_is_domain_name" diff --git a/spec/unit/puppet/parser/functions/is_float_spec.rb b/spec/unit/puppet/parser/functions/is_float_spec.rb index 2cfc789..a00f4bc 100644 --- a/spec/unit/puppet/parser/functions/is_float_spec.rb +++ b/spec/unit/puppet/parser/functions/is_float_spec.rb @@ -2,35 +2,28 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_is_float([]) }.should( raise_error(Puppet::ParseError)) end it "should return true if a float" do - result = @scope.function_is_float(["0.12"]) + result = scope.function_is_float(["0.12"]) result.should(eq(true)) end it "should return false if a string" do - result = @scope.function_is_float(["asdf"]) + result = scope.function_is_float(["asdf"]) result.should(eq(false)) end it "should return false if an integer" do - result = @scope.function_is_float(["3"]) + result = scope.function_is_float(["3"]) result.should(eq(false)) end - end diff --git a/spec/unit/puppet/parser/functions/is_hash_spec.rb b/spec/unit/puppet/parser/functions/is_hash_spec.rb index 112c9ab..3f765d4 100644 --- a/spec/unit/puppet/parser/functions/is_hash_spec.rb +++ b/spec/unit/puppet/parser/functions/is_hash_spec.rb @@ -2,35 +2,28 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_is_hash([]) }.should( raise_error(Puppet::ParseError)) end it "should return true if passed a hash" do - result = @scope.function_is_hash([{"a"=>1,"b"=>2}]) + result = scope.function_is_hash([{"a"=>1,"b"=>2}]) result.should(eq(true)) end it "should return false if passed an array" do - result = @scope.function_is_hash([["a","b"]]) + result = scope.function_is_hash([["a","b"]]) result.should(eq(false)) end it "should return false if passed a string" do - result = @scope.function_is_hash(["asdf"]) + result = scope.function_is_hash(["asdf"]) result.should(eq(false)) end - end diff --git a/spec/unit/puppet/parser/functions/is_integer_spec.rb b/spec/unit/puppet/parser/functions/is_integer_spec.rb index d4b8f6b..56735ff 100644 --- a/spec/unit/puppet/parser/functions/is_integer_spec.rb +++ b/spec/unit/puppet/parser/functions/is_integer_spec.rb @@ -2,35 +2,28 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_is_integer([]) }.should( raise_error(Puppet::ParseError)) end it "should return true if an integer" do - result = @scope.function_is_integer(["3"]) + result = scope.function_is_integer(["3"]) result.should(eq(true)) end it "should return false if a float" do - result = @scope.function_is_integer(["3.2"]) + result = scope.function_is_integer(["3.2"]) result.should(eq(false)) end it "should return false if a string" do - result = @scope.function_is_integer(["asdf"]) + result = scope.function_is_integer(["asdf"]) result.should(eq(false)) end - end diff --git a/spec/unit/puppet/parser/functions/is_ip_address_spec.rb b/spec/unit/puppet/parser/functions/is_ip_address_spec.rb index 7930634..d231440 100644 --- a/spec/unit/puppet/parser/functions/is_ip_address_spec.rb +++ b/spec/unit/puppet/parser/functions/is_ip_address_spec.rb @@ -2,44 +2,38 @@ require 'spec_helper' describe "the is_ip_address function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - before :each do - @scope = Puppet::Parser::Scope.new - end + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } it "should exist" do Puppet::Parser::Functions.function("is_ip_address").should == "function_is_ip_address" end it "should raise a ParseError if there is less than 1 arguments" do - lambda { @scope.function_is_ip_address([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_ip_address([]) }.should( raise_error(Puppet::ParseError)) end it "should return true if an IPv4 address" do - result = @scope.function_is_ip_address(["1.2.3.4"]) + result = scope.function_is_ip_address(["1.2.3.4"]) result.should(eq(true)) end it "should return true if a full IPv6 address" do - result = @scope.function_is_ip_address(["fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"]) + result = scope.function_is_ip_address(["fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"]) result.should(eq(true)) end it "should return true if a compressed IPv6 address" do - result = @scope.function_is_ip_address(["fe00::1"]) + result = scope.function_is_ip_address(["fe00::1"]) result.should(eq(true)) end it "should return false if not valid" do - result = @scope.function_is_ip_address(["asdf"]) + result = scope.function_is_ip_address(["asdf"]) result.should(eq(false)) end it "should return false if IP octets out of range" do - result = @scope.function_is_ip_address(["1.1.1.300"]) + result = scope.function_is_ip_address(["1.1.1.300"]) result.should(eq(false)) end end diff --git a/spec/unit/puppet/parser/functions/is_mac_address_spec.rb b/spec/unit/puppet/parser/functions/is_mac_address_spec.rb index 4ba896e..0dcacb1 100644 --- a/spec/unit/puppet/parser/functions/is_mac_address_spec.rb +++ b/spec/unit/puppet/parser/functions/is_mac_address_spec.rb @@ -2,35 +2,28 @@ require 'spec_helper' describe "the is_mac_address function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - before :each do - @scope = Puppet::Parser::Scope.new - end + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } it "should exist" do Puppet::Parser::Functions.function("is_mac_address").should == "function_is_mac_address" end it "should raise a ParseError if there is less than 1 arguments" do - lambda { @scope.function_is_mac_address([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_mac_address([]) }.should( raise_error(Puppet::ParseError)) end it "should return true if a valid mac address" do - result = @scope.function_is_mac_address(["00:a0:1f:12:7f:a0"]) + result = scope.function_is_mac_address(["00:a0:1f:12:7f:a0"]) result.should(eq(true)) end it "should return false if octets are out of range" do - result = @scope.function_is_mac_address(["00:a0:1f:12:7f:g0"]) + result = scope.function_is_mac_address(["00:a0:1f:12:7f:g0"]) result.should(eq(false)) end it "should return false if not valid" do - result = @scope.function_is_mac_address(["not valid"]) + result = scope.function_is_mac_address(["not valid"]) result.should(eq(false)) end - end diff --git a/spec/unit/puppet/parser/functions/is_numeric_spec.rb b/spec/unit/puppet/parser/functions/is_numeric_spec.rb index 0b0a834..9c1aa40 100644 --- a/spec/unit/puppet/parser/functions/is_numeric_spec.rb +++ b/spec/unit/puppet/parser/functions/is_numeric_spec.rb @@ -2,35 +2,28 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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 argument" do - lambda { @scope.function_is_numeric([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_numeric([]) }.should( raise_error(Puppet::ParseError)) end it "should return true if an integer" do - result = @scope.function_is_numeric(["3"]) + result = scope.function_is_numeric(["3"]) result.should(eq(true)) end it "should return true if a float" do - result = @scope.function_is_numeric(["3.2"]) + result = scope.function_is_numeric(["3.2"]) result.should(eq(true)) end it "should return false if a string" do - result = @scope.function_is_numeric(["asdf"]) + result = scope.function_is_numeric(["asdf"]) result.should(eq(false)) end - end diff --git a/spec/unit/puppet/parser/functions/is_string_spec.rb b/spec/unit/puppet/parser/functions/is_string_spec.rb index e54562d..36c612c 100644 --- a/spec/unit/puppet/parser/functions/is_string_spec.rb +++ b/spec/unit/puppet/parser/functions/is_string_spec.rb @@ -2,40 +2,33 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_is_string([]) }.should( raise_error(Puppet::ParseError)) end it "should return true if a string" do - result = @scope.function_is_string(["asdf"]) + result = scope.function_is_string(["asdf"]) result.should(eq(true)) end it "should return false if an integer" do - result = @scope.function_is_string(["3"]) + result = scope.function_is_string(["3"]) result.should(eq(false)) end it "should return false if a float" do - result = @scope.function_is_string(["3.23"]) + result = scope.function_is_string(["3.23"]) result.should(eq(false)) end it "should return false if an array" do - result = @scope.function_is_string([["a","b","c"]]) + result = scope.function_is_string([["a","b","c"]]) result.should(eq(false)) end - end diff --git a/spec/unit/puppet/parser/functions/join_spec.rb b/spec/unit/puppet/parser/functions/join_spec.rb index 60c1c95..694fdce 100644 --- a/spec/unit/puppet/parser/functions/join_spec.rb +++ b/spec/unit/puppet/parser/functions/join_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_join([]) }.should( raise_error(Puppet::ParseError)) end it "should join an array into a string" do - result = @scope.function_join([["a","b","c"], ":"]) + result = scope.function_join([["a","b","c"], ":"]) result.should(eq("a:b:c")) end - end diff --git a/spec/unit/puppet/parser/functions/keys_spec.rb b/spec/unit/puppet/parser/functions/keys_spec.rb index 455acb8..def4a28 100644 --- a/spec/unit/puppet/parser/functions/keys_spec.rb +++ b/spec/unit/puppet/parser/functions/keys_spec.rb @@ -2,11 +2,7 @@ require 'spec_helper' describe "the keys function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - let(:scope) { Puppet::Parser::Scope.new } + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } it "should exist" do Puppet::Parser::Functions.function("keys").should == "function_keys" diff --git a/spec/unit/puppet/parser/functions/lstrip_spec.rb b/spec/unit/puppet/parser/functions/lstrip_spec.rb index 1bac793..77c18c7 100644 --- a/spec/unit/puppet/parser/functions/lstrip_spec.rb +++ b/spec/unit/puppet/parser/functions/lstrip_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_lstrip([]) }.should( raise_error(Puppet::ParseError)) end it "should lstrip a string" do - result = @scope.function_lstrip([" asdf"]) + result = scope.function_lstrip([" asdf"]) result.should(eq('asdf')) end - end diff --git a/spec/unit/puppet/parser/functions/member_spec.rb b/spec/unit/puppet/parser/functions/member_spec.rb index 8462e04..e939d95 100644 --- a/spec/unit/puppet/parser/functions/member_spec.rb +++ b/spec/unit/puppet/parser/functions/member_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_member([]) }.should( raise_error(Puppet::ParseError)) end it "should return true if a member is in an array" do - result = @scope.function_member([["a","b","c"], "a"]) + result = scope.function_member([["a","b","c"], "a"]) result.should(eq(true)) - end + end it "should return false if a member is not in an array" do - result = @scope.function_member([["a","b","c"], "d"]) + result = scope.function_member([["a","b","c"], "d"]) result.should(eq(false)) - end - + end end diff --git a/spec/unit/puppet/parser/functions/merge_spec.rb b/spec/unit/puppet/parser/functions/merge_spec.rb index 71e1869..78810cf 100644 --- a/spec/unit/puppet/parser/functions/merge_spec.rb +++ b/spec/unit/puppet/parser/functions/merge_spec.rb @@ -1,33 +1,18 @@ -require 'puppet' -require 'mocha' -describe Puppet::Parser::Functions.function(:merge) do +#! /usr/bin/env ruby -S rspec + +require 'spec_helper' - # Pulled from Dan's create_resources function - # TODO - these let statements should be moved somewhere - # where they can be resued - let(:compiler) { - topscope = Puppet::Parser::Scope.new - # This is necessary so we don't try to use the compiler to discover our parent. - topscope.parent = nil - my_scope = Puppet::Parser::Scope.new - my_scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - my_scope.parent = topscope - compiler = my_scope.compiler - } - let(:scope) { - scope = Puppet::Parser::Scope.new - scope.stubs(:environment).returns(Puppet::Node::Environment.new('production')) - scope - } +describe Puppet::Parser::Functions.function(:merge) do + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } describe 'when calling merge from puppet' do it "should not compile when no arguments are passed" do Puppet[:code] = 'merge()' - expect { compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) end it "should not compile when 1 argument is passed" do Puppet[:code] = "$my_hash={'one' => 1}\nmerge($my_hash)" - expect { compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) end end describe 'when calling merge on the scope instance' do @@ -48,7 +33,5 @@ describe Puppet::Parser::Functions.function(:merge) do it 'should accept empty hashes' do scope.function_merge([{},{},{}]).should == {} end - end - end diff --git a/spec/unit/puppet/parser/functions/num2bool_spec.rb b/spec/unit/puppet/parser/functions/num2bool_spec.rb index 3c9f846..907b6a3 100644 --- a/spec/unit/puppet/parser/functions/num2bool_spec.rb +++ b/spec/unit/puppet/parser/functions/num2bool_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_num2bool([]) }.should( raise_error(Puppet::ParseError)) end it "should return true if 1" do - result = @scope.function_num2bool(["1"]) + result = scope.function_num2bool(["1"]) result.should(be_true) end it "should return false if 0" do - result = @scope.function_num2bool(["0"]) + result = scope.function_num2bool(["0"]) result.should(be_false) end - end diff --git a/spec/unit/puppet/parser/functions/parsejson_spec.rb b/spec/unit/puppet/parser/functions/parsejson_spec.rb index 22fe27e..4eb1743 100644 --- a/spec/unit/puppet/parser/functions/parsejson_spec.rb +++ b/spec/unit/puppet/parser/functions/parsejson_spec.rb @@ -2,28 +2,21 @@ require 'spec_helper' describe "the parsejson function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - before :each do - @scope = Puppet::Parser::Scope.new - end + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } it "should exist" do Puppet::Parser::Functions.function("parsejson").should == "function_parsejson" end it "should raise a ParseError if there is less than 1 arguments" do - lambda { @scope.function_parsejson([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_parsejson([]) }.should( raise_error(Puppet::ParseError)) end it "should convert JSON to a data structure" do json = <<-EOS ["aaa","bbb","ccc"] EOS - result = @scope.function_parsejson([json]) + result = scope.function_parsejson([json]) result.should(eq(['aaa','bbb','ccc'])) end - end diff --git a/spec/unit/puppet/parser/functions/parseyaml_spec.rb b/spec/unit/puppet/parser/functions/parseyaml_spec.rb index 7c29f1a..39ec184 100644 --- a/spec/unit/puppet/parser/functions/parseyaml_spec.rb +++ b/spec/unit/puppet/parser/functions/parseyaml_spec.rb @@ -2,20 +2,14 @@ require 'spec_helper' describe "the parseyaml function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - before :each do - @scope = Puppet::Parser::Scope.new - end + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } it "should exist" do Puppet::Parser::Functions.function("parseyaml").should == "function_parseyaml" end it "should raise a ParseError if there is less than 1 arguments" do - lambda { @scope.function_parseyaml([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_parseyaml([]) }.should( raise_error(Puppet::ParseError)) end it "should convert YAML to a data structure" do @@ -24,8 +18,7 @@ describe "the parseyaml function" do - bbb - ccc EOS - result = @scope.function_parseyaml([yaml]) + result = scope.function_parseyaml([yaml]) result.should(eq(['aaa','bbb','ccc'])) end - end diff --git a/spec/unit/puppet/parser/functions/prefix_spec.rb b/spec/unit/puppet/parser/functions/prefix_spec.rb index c093d9e..4a55cc4 100644 --- a/spec/unit/puppet/parser/functions/prefix_spec.rb +++ b/spec/unit/puppet/parser/functions/prefix_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_prefix([]) }.should( raise_error(Puppet::ParseError)) end it "should return a prefixed array" do - result = @scope.function_prefix([['a','b','c'], 'p']) + result = scope.function_prefix([['a','b','c'], 'p']) result.should(eq(['pa','pb','pc'])) end - end diff --git a/spec/unit/puppet/parser/functions/range_spec.rb b/spec/unit/puppet/parser/functions/range_spec.rb index 210fec8..e1bd898 100644 --- a/spec/unit/puppet/parser/functions/range_spec.rb +++ b/spec/unit/puppet/parser/functions/range_spec.rb @@ -2,13 +2,7 @@ require 'spec_helper' describe "the range function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - let :scope do - Puppet::Parser::Scope.new - end + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } it "should exist" do Puppet::Parser::Functions.function("range").should == "function_range" diff --git a/spec/unit/puppet/parser/functions/reverse_spec.rb b/spec/unit/puppet/parser/functions/reverse_spec.rb index a07bdd6..8024cb3 100644 --- a/spec/unit/puppet/parser/functions/reverse_spec.rb +++ b/spec/unit/puppet/parser/functions/reverse_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_reverse([]) }.should( raise_error(Puppet::ParseError)) end it "should reverse a string" do - result = @scope.function_reverse(["asdfghijkl"]) + result = scope.function_reverse(["asdfghijkl"]) result.should(eq('lkjihgfdsa')) end - end diff --git a/spec/unit/puppet/parser/functions/rstrip_spec.rb b/spec/unit/puppet/parser/functions/rstrip_spec.rb index b6a461a..99f4dde 100644 --- a/spec/unit/puppet/parser/functions/rstrip_spec.rb +++ b/spec/unit/puppet/parser/functions/rstrip_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_rstrip([]) }.should( raise_error(Puppet::ParseError)) end it "should rstrip a string" do - result = @scope.function_rstrip(["asdf "]) + result = scope.function_rstrip(["asdf "]) result.should(eq('asdf')) end it "should rstrip each element in an array" do - result = @scope.function_rstrip([["a ","b ", "c "]]) + result = scope.function_rstrip([["a ","b ", "c "]]) result.should(eq(['a','b','c'])) end - end diff --git a/spec/unit/puppet/parser/functions/shuffle_spec.rb b/spec/unit/puppet/parser/functions/shuffle_spec.rb index e66fdc5..4bb77f2 100644 --- a/spec/unit/puppet/parser/functions/shuffle_spec.rb +++ b/spec/unit/puppet/parser/functions/shuffle_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_shuffle([]) }.should( raise_error(Puppet::ParseError)) end it "should shuffle a string and the result should be the same size" do - result = @scope.function_shuffle(["asdf"]) + result = scope.function_shuffle(["asdf"]) result.size.should(eq(4)) end it "should shuffle a string but the sorted contents should still be the same" do - result = @scope.function_shuffle(["adfs"]) + result = scope.function_shuffle(["adfs"]) result.split("").sort.join("").should(eq("adfs")) end - end diff --git a/spec/unit/puppet/parser/functions/size_spec.rb b/spec/unit/puppet/parser/functions/size_spec.rb index 20c3580..42c0209 100644 --- a/spec/unit/puppet/parser/functions/size_spec.rb +++ b/spec/unit/puppet/parser/functions/size_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_size([]) }.should( raise_error(Puppet::ParseError)) end it "should return the size of a string" do - result = @scope.function_size(["asdf"]) + result = scope.function_size(["asdf"]) result.should(eq(4)) end it "should return the size of an array" do - result = @scope.function_size([["a","b","c"]]) + result = scope.function_size([["a","b","c"]]) result.should(eq(3)) end - end diff --git a/spec/unit/puppet/parser/functions/sort_spec.rb b/spec/unit/puppet/parser/functions/sort_spec.rb index 0f2343a..f0e9649 100644 --- a/spec/unit/puppet/parser/functions/sort_spec.rb +++ b/spec/unit/puppet/parser/functions/sort_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } it "should exist" do Puppet::Parser::Functions.function("sort").should == "function_sort" end it "should raise a ParseError if there is not 1 arguments" do - lambda { @scope.function_sort(['','']) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_sort(['','']) }.should( raise_error(Puppet::ParseError)) end it "should sort an array" do - result = @scope.function_sort([["a","c","b"]]) + result = scope.function_sort([["a","c","b"]]) result.should(eq(['a','b','c'])) end it "should sort a string" do - result = @scope.function_sort(["acb"]) + result = scope.function_sort(["acb"]) result.should(eq('abc')) end - end diff --git a/spec/unit/puppet/parser/functions/squeeze_spec.rb b/spec/unit/puppet/parser/functions/squeeze_spec.rb index 4e84c12..8acec64 100644 --- a/spec/unit/puppet/parser/functions/squeeze_spec.rb +++ b/spec/unit/puppet/parser/functions/squeeze_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_squeeze([]) }.should( raise_error(Puppet::ParseError)) end it "should squeeze a string" do - result = @scope.function_squeeze(["aaabbbbcccc"]) + result = scope.function_squeeze(["aaabbbbcccc"]) result.should(eq('abc')) end it "should squeeze all elements in an array" do - result = @scope.function_squeeze([["aaabbbbcccc","dddfff"]]) + result = scope.function_squeeze([["aaabbbbcccc","dddfff"]]) result.should(eq(['abc','df'])) end - end diff --git a/spec/unit/puppet/parser/functions/str2bool_spec.rb b/spec/unit/puppet/parser/functions/str2bool_spec.rb index fff9f5d..2f01338 100644 --- a/spec/unit/puppet/parser/functions/str2bool_spec.rb +++ b/spec/unit/puppet/parser/functions/str2bool_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_str2bool([]) }.should( raise_error(Puppet::ParseError)) end it "should convert string 'true' to true" do - result = @scope.function_str2bool(["true"]) + result = scope.function_str2bool(["true"]) result.should(eq(true)) end it "should convert string 'undef' to false" do - result = @scope.function_str2bool(["undef"]) + result = scope.function_str2bool(["undef"]) result.should(eq(false)) end - end diff --git a/spec/unit/puppet/parser/functions/strftime_spec.rb b/spec/unit/puppet/parser/functions/strftime_spec.rb index a0ca9d5..bb45371 100644 --- a/spec/unit/puppet/parser/functions/strftime_spec.rb +++ b/spec/unit/puppet/parser/functions/strftime_spec.rb @@ -2,35 +2,28 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_strftime([]) }.should( raise_error(Puppet::ParseError)) end it "using %s should be higher then when I wrote this test" do - result = @scope.function_strftime(["%s"]) + result = scope.function_strftime(["%s"]) result.to_i.should(be > 1311953157) end it "using %s should be lower then 1.5 trillion" do - result = @scope.function_strftime(["%s"]) + result = scope.function_strftime(["%s"]) result.to_i.should(be < 1500000000) end it "should return a date when given %Y-%m-%d" do - result = @scope.function_strftime(["%Y-%m-%d"]) + result = scope.function_strftime(["%Y-%m-%d"]) result.should =~ /^\d{4}-\d{2}-\d{2}$/ end - end diff --git a/spec/unit/puppet/parser/functions/strip_spec.rb b/spec/unit/puppet/parser/functions/strip_spec.rb index c051038..47a0e0d 100644 --- a/spec/unit/puppet/parser/functions/strip_spec.rb +++ b/spec/unit/puppet/parser/functions/strip_spec.rb @@ -2,25 +2,17 @@ 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 - + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_strip([]) }.should( raise_error(Puppet::ParseError)) end it "should strip a string" do - result = @scope.function_strip([" ab cd "]) + result = scope.function_strip([" ab cd "]) result.should(eq('ab cd')) end - end diff --git a/spec/unit/puppet/parser/functions/swapcase_spec.rb b/spec/unit/puppet/parser/functions/swapcase_spec.rb index b40e199..9806d38 100644 --- a/spec/unit/puppet/parser/functions/swapcase_spec.rb +++ b/spec/unit/puppet/parser/functions/swapcase_spec.rb @@ -2,25 +2,18 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_swapcase([]) }.should( raise_error(Puppet::ParseError)) end it "should swapcase a string" do - result = @scope.function_swapcase(["aaBBccDD"]) + result = scope.function_swapcase(["aaBBccDD"]) result.should(eq('AAbbCCdd')) end - end diff --git a/spec/unit/puppet/parser/functions/time_spec.rb b/spec/unit/puppet/parser/functions/time_spec.rb index 4b1ab5e..32c3ab4 100644 --- a/spec/unit/puppet/parser/functions/time_spec.rb +++ b/spec/unit/puppet/parser/functions/time_spec.rb @@ -2,35 +2,28 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_time(['','']) }.should( raise_error(Puppet::ParseError)) end it "should return a number" do - result = @scope.function_time([]) + result = scope.function_time([]) result.should be_an(Integer) end it "should be higher then when I wrote this test" do - result = @scope.function_time([]) + result = scope.function_time([]) result.should(be > 1311953157) end it "should be lower then 1.5 trillion" do - result = @scope.function_time([]) + result = scope.function_time([]) result.should(be < 1500000000) end - end diff --git a/spec/unit/puppet/parser/functions/type_spec.rb b/spec/unit/puppet/parser/functions/type_spec.rb index ad5efdc..c7babc6 100644 --- a/spec/unit/puppet/parser/functions/type_spec.rb +++ b/spec/unit/puppet/parser/functions/type_spec.rb @@ -2,50 +2,42 @@ 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 - + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_type([]) }.should( raise_error(Puppet::ParseError)) end it "should return string when given a string" do - result = @scope.function_type(["aaabbbbcccc"]) + result = scope.function_type(["aaabbbbcccc"]) result.should(eq('string')) end it "should return array when given an array" do - result = @scope.function_type([["aaabbbbcccc","asdf"]]) + result = scope.function_type([["aaabbbbcccc","asdf"]]) result.should(eq('array')) end it "should return hash when given a hash" do - result = @scope.function_type([{"a"=>1,"b"=>2}]) + result = scope.function_type([{"a"=>1,"b"=>2}]) result.should(eq('hash')) end it "should return integer when given an integer" do - result = @scope.function_type(["1"]) + result = scope.function_type(["1"]) result.should(eq('integer')) end it "should return float when given a float" do - result = @scope.function_type(["1.34"]) + result = scope.function_type(["1.34"]) result.should(eq('float')) end it "should return boolean when given a boolean" do - result = @scope.function_type([true]) + result = scope.function_type([true]) result.should(eq('boolean')) end - end diff --git a/spec/unit/puppet/parser/functions/unique_spec.rb b/spec/unit/puppet/parser/functions/unique_spec.rb index 82edb26..c0c5872 100644 --- a/spec/unit/puppet/parser/functions/unique_spec.rb +++ b/spec/unit/puppet/parser/functions/unique_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_unique([]) }.should( raise_error(Puppet::ParseError)) end it "should remove duplicate elements in a string" do - result = @scope.function_unique(["aabbc"]) + result = scope.function_unique(["aabbc"]) result.should(eq('abc')) end it "should remove duplicate elements in an array" do - result = @scope.function_unique([["a","a","b","b","c"]]) + result = scope.function_unique([["a","a","b","b","c"]]) result.should(eq(['a','b','c'])) end - end diff --git a/spec/unit/puppet/parser/functions/upcase_spec.rb b/spec/unit/puppet/parser/functions/upcase_spec.rb index d779b16..f507009 100644 --- a/spec/unit/puppet/parser/functions/upcase_spec.rb +++ b/spec/unit/puppet/parser/functions/upcase_spec.rb @@ -2,30 +2,23 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_upcase([]) }.should( raise_error(Puppet::ParseError)) end it "should upcase a string" do - result = @scope.function_upcase(["abc"]) + result = scope.function_upcase(["abc"]) result.should(eq('ABC')) end it "should do nothing if a string is already upcase" do - result = @scope.function_upcase(["ABC"]) + result = scope.function_upcase(["ABC"]) result.should(eq('ABC')) end - end diff --git a/spec/unit/puppet/parser/functions/validate_array_spec.rb b/spec/unit/puppet/parser/functions/validate_array_spec.rb index 37ae09d..f015e42 100644 --- a/spec/unit/puppet/parser/functions/validate_array_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_array_spec.rb @@ -1,41 +1,21 @@ -require 'puppet' +#! /usr/bin/env ruby -S rspec -# We don't need this for the basic tests we're doing -# require 'spec_helper' +require 'spec_helper' -# Dan mentioned that Nick recommended the function method call -# to return the string value for the test description. -# this will not even try the test if the function cannot be -# loaded. describe Puppet::Parser::Functions.function(:validate_array) do - - # Pulled from Dan's create_resources function - def get_scope - @topscope = Puppet::Parser::Scope.new - # This is necessary so we don't try to use the compiler to discover our parent. - @topscope.parent = nil - @scope = Puppet::Parser::Scope.new - @scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - @scope.parent = @topscope - @compiler = @scope.compiler - end - + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } describe 'when calling validate_array from puppet' do %w{ true false }.each do |the_string| - it "should not compile when #{the_string} is a string" do Puppet[:code] = "validate_array('#{the_string}')" - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not an Array/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not an Array/) end it "should not compile when #{the_string} is a bare word" do Puppet[:code] = "validate_array(#{the_string})" - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not an Array/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not an Array/) end - end it "should compile when multiple array arguments are passed" do @@ -44,8 +24,7 @@ describe Puppet::Parser::Functions.function(:validate_array) do $bar = [ 'one', 'two' ] validate_array($foo, $bar) ENDofPUPPETcode - get_scope - @scope.compiler.compile + scope.compiler.compile end it "should not compile when an undef variable is passed" do @@ -53,11 +32,7 @@ describe Puppet::Parser::Functions.function(:validate_array) do $foo = undef validate_array($foo) ENDofPUPPETcode - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not an Array/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not an Array/) end - end - end - diff --git a/spec/unit/puppet/parser/functions/validate_bool_spec.rb b/spec/unit/puppet/parser/functions/validate_bool_spec.rb index e95c396..798b129 100644 --- a/spec/unit/puppet/parser/functions/validate_bool_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_bool_spec.rb @@ -1,53 +1,33 @@ -require 'puppet' +#! /usr/bin/env/ruby -S rspec -# We don't need this for the basic tests we're doing -# require 'spec_helper' +require 'spec_helper' -# Dan mentioned that Nick recommended the function method call -# to return the string value for the test description. -# this will not even try the test if the function cannot be -# loaded. describe Puppet::Parser::Functions.function(:validate_bool) do - - # Pulled from Dan's create_resources function - def get_scope - @topscope = Puppet::Parser::Scope.new - # This is necessary so we don't try to use the compiler to discover our parent. - @topscope.parent = nil - @scope = Puppet::Parser::Scope.new - @scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - @scope.parent = @topscope - @compiler = @scope.compiler - end - + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } describe 'when calling validate_bool from puppet' do %w{ true false }.each do |the_string| it "should not compile when #{the_string} is a string" do Puppet[:code] = "validate_bool('#{the_string}')" - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/) end it "should compile when #{the_string} is a bare word" do Puppet[:code] = "validate_bool(#{the_string})" - get_scope - @scope.compiler.compile + scope.compiler.compile end end it "should not compile when an arbitrary string is passed" do Puppet[:code] = 'validate_bool("jeff and dan are awesome")' - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/) end it "should not compile when no arguments are passed" do Puppet[:code] = 'validate_bool()' - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) end it "should compile when multiple boolean arguments are passed" do @@ -56,8 +36,7 @@ describe Puppet::Parser::Functions.function(:validate_bool) do $bar = false validate_bool($foo, $bar, true, false) ENDofPUPPETcode - get_scope - @scope.compiler.compile + scope.compiler.compile end it "should compile when multiple boolean arguments are passed" do @@ -66,11 +45,7 @@ describe Puppet::Parser::Functions.function(:validate_bool) do $bar = false validate_bool($foo, $bar, true, false, 'jeff') ENDofPUPPETcode - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/) end - end - end - diff --git a/spec/unit/puppet/parser/functions/validate_hash_spec.rb b/spec/unit/puppet/parser/functions/validate_hash_spec.rb index 8cc0b3d..aad8271 100644 --- a/spec/unit/puppet/parser/functions/validate_hash_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_hash_spec.rb @@ -1,24 +1,9 @@ -require 'puppet' +#! /usr/bin/env ruby -S rspec -# We don't need this for the basic tests we're doing -# require 'spec_helper' +require 'spec_helper' -# Dan mentioned that Nick recommended the function method call -# to return the string value for the test description. -# this will not even try the test if the function cannot be -# loaded. describe Puppet::Parser::Functions.function(:validate_hash) do - - # Pulled from Dan's create_resources function - def get_scope - @topscope = Puppet::Parser::Scope.new - # This is necessary so we don't try to use the compiler to discover our parent. - @topscope.parent = nil - @scope = Puppet::Parser::Scope.new - @scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - @scope.parent = @topscope - @compiler = @scope.compiler - end + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } describe 'when calling validate_hash from puppet' do @@ -26,14 +11,12 @@ describe Puppet::Parser::Functions.function(:validate_hash) do it "should not compile when #{the_string} is a string" do Puppet[:code] = "validate_hash('#{the_string}')" - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a Hash/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a Hash/) end it "should not compile when #{the_string} is a bare word" do Puppet[:code] = "validate_hash(#{the_string})" - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a Hash/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a Hash/) end end @@ -44,8 +27,7 @@ describe Puppet::Parser::Functions.function(:validate_hash) do $bar = { 'one' => 'two' } validate_hash($foo, $bar) ENDofPUPPETcode - get_scope - @scope.compiler.compile + scope.compiler.compile end it "should not compile when an undef variable is passed" do @@ -53,8 +35,7 @@ describe Puppet::Parser::Functions.function(:validate_hash) do $foo = undef validate_hash($foo) ENDofPUPPETcode - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a Hash/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a Hash/) end end diff --git a/spec/unit/puppet/parser/functions/validate_string_spec.rb b/spec/unit/puppet/parser/functions/validate_string_spec.rb index 92392da..caeefa0 100644 --- a/spec/unit/puppet/parser/functions/validate_string_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_string_spec.rb @@ -1,24 +1,9 @@ -require 'puppet' +#! /usr/bin/env ruby -S rspec -# We don't need this for the basic tests we're doing -# require 'spec_helper' +require 'spec_helper' -# Dan mentioned that Nick recommended the function method call -# to return the string value for the test description. -# this will not even try the test if the function cannot be -# loaded. describe Puppet::Parser::Functions.function(:validate_string) do - - # Pulled from Dan's create_resources function - def get_scope - @topscope = Puppet::Parser::Scope.new - # This is necessary so we don't try to use the compiler to discover our parent. - @topscope.parent = nil - @scope = Puppet::Parser::Scope.new - @scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - @scope.parent = @topscope - @compiler = @scope.compiler - end + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } describe 'when calling validate_string from puppet' do @@ -26,14 +11,12 @@ describe Puppet::Parser::Functions.function(:validate_string) do it "should compile when #{the_string} is a string" do Puppet[:code] = "validate_string('#{the_string}')" - get_scope - @scope.compiler.compile + scope.compiler.compile end it "should compile when #{the_string} is a bare word" do Puppet[:code] = "validate_string(#{the_string})" - get_scope - @scope.compiler.compile + scope.compiler.compile end end @@ -41,14 +24,12 @@ describe Puppet::Parser::Functions.function(:validate_string) do %w{ true false }.each do |the_string| it "should compile when #{the_string} is a string" do Puppet[:code] = "validate_string('#{the_string}')" - get_scope - @scope.compiler.compile + scope.compiler.compile end it "should not compile when #{the_string} is a bare word" do Puppet[:code] = "validate_string(#{the_string})" - get_scope - expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a string/) + expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a string/) end end @@ -58,8 +39,7 @@ describe Puppet::Parser::Functions.function(:validate_string) do $bar = 'two' validate_string($foo, $bar) ENDofPUPPETcode - get_scope - @scope.compiler.compile + scope.compiler.compile end it "should compile when an explicitly undef variable is passed (NOTE THIS MAY NOT BE DESIRABLE)" do @@ -67,16 +47,14 @@ describe Puppet::Parser::Functions.function(:validate_string) do $foo = undef validate_string($foo) ENDofPUPPETcode - get_scope - @scope.compiler.compile + scope.compiler.compile end it "should compile when an undefined variable is passed (NOTE THIS MAY NOT BE DESIRABLE)" do Puppet[:code] = <<-'ENDofPUPPETcode' validate_string($foobarbazishouldnotexist) ENDofPUPPETcode - get_scope - @scope.compiler.compile + scope.compiler.compile end end end diff --git a/spec/unit/puppet/parser/functions/values_at_spec.rb b/spec/unit/puppet/parser/functions/values_at_spec.rb index c1c9a6a..8e7bfa2 100644 --- a/spec/unit/puppet/parser/functions/values_at_spec.rb +++ b/spec/unit/puppet/parser/functions/values_at_spec.rb @@ -2,44 +2,37 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } 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)) + lambda { scope.function_values_at([]) }.should( raise_error(Puppet::ParseError)) end it "should raise a ParseError if you try to use a range where stop is greater then start" do - lambda { @scope.function_values_at([['a','b'],["3-1"]]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_values_at([['a','b'],["3-1"]]) }.should( raise_error(Puppet::ParseError)) end it "should return a value at from an array" do - result = @scope.function_values_at([['a','b','c'],"1"]) + result = scope.function_values_at([['a','b','c'],"1"]) result.should(eq(['b'])) end it "should return a value at from an array when passed a range" do - result = @scope.function_values_at([['a','b','c'],"0-1"]) + result = scope.function_values_at([['a','b','c'],"0-1"]) result.should(eq(['a','b'])) end it "should return chosen values from an array when passed number of indexes" do - result = @scope.function_values_at([['a','b','c'],["0","2"]]) + result = scope.function_values_at([['a','b','c'],["0","2"]]) result.should(eq(['a','c'])) end it "should return chosen values from an array when passed ranges and multiple indexes" do - result = @scope.function_values_at([['a','b','c','d','e','f','g'],["0","2","4-5"]]) + result = scope.function_values_at([['a','b','c','d','e','f','g'],["0","2","4-5"]]) result.should(eq(['a','c','e','f'])) end - end diff --git a/spec/unit/puppet/parser/functions/values_spec.rb b/spec/unit/puppet/parser/functions/values_spec.rb index 0c7f1f9..cd2f107 100644 --- a/spec/unit/puppet/parser/functions/values_spec.rb +++ b/spec/unit/puppet/parser/functions/values_spec.rb @@ -2,11 +2,7 @@ require 'spec_helper' describe "the values function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - let(:scope) { Puppet::Parser::Scope.new } + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } it "should exist" do Puppet::Parser::Functions.function("values").should == "function_values" diff --git a/spec/unit/puppet/parser/functions/zip_spec.rb b/spec/unit/puppet/parser/functions/zip_spec.rb index 9badb06..b6d8713 100644 --- a/spec/unit/puppet/parser/functions/zip_spec.rb +++ b/spec/unit/puppet/parser/functions/zip_spec.rb @@ -2,25 +2,14 @@ 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 + let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } it "should raise a ParseError if there is less than 1 arguments" do - lambda { @scope.function_zip([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_zip([]) }.should( raise_error(Puppet::ParseError)) end it "should be able to zip an array" do - result = @scope.function_zip([['1','2','3'],['4','5','6']]) + result = scope.function_zip([['1','2','3'],['4','5','6']]) result.should(eq([["1", "4"], ["2", "5"], ["3", "6"]])) end - end -- cgit v1.2.3 From 99f084868b585c0b34a3f91cb19c655c77219381 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Mon, 23 Jul 2012 08:28:06 -0700 Subject: (Maint) Rename PuppetlabsSpec::Puppet{Seams,Internals} The module PuppetlabsSpec::PuppetSeams has been renamed in the puppetlabs_spec_helper gem to PuppetlabsSpec::PuppetInternals. The method to obtain a scope object has also changed slightly. Without this patch the spec tests will fail because the stdlib module is not aligned with the spec helper gem. This patch fixes the problem by matching up messages with their receivers in the spec helper library. Paired-with: Andrew Parker --- spec/unit/puppet/parser/functions/abs_spec.rb | 2 +- spec/unit/puppet/parser/functions/bool2num_spec.rb | 2 +- spec/unit/puppet/parser/functions/capitalize_spec.rb | 2 +- spec/unit/puppet/parser/functions/chomp_spec.rb | 2 +- spec/unit/puppet/parser/functions/chop_spec.rb | 2 +- spec/unit/puppet/parser/functions/delete_at_spec.rb | 2 +- spec/unit/puppet/parser/functions/delete_spec.rb | 2 +- spec/unit/puppet/parser/functions/downcase_spec.rb | 2 +- spec/unit/puppet/parser/functions/empty_spec.rb | 2 +- spec/unit/puppet/parser/functions/flatten_spec.rb | 2 +- spec/unit/puppet/parser/functions/getvar_spec.rb | 2 +- spec/unit/puppet/parser/functions/grep_spec.rb | 2 +- spec/unit/puppet/parser/functions/has_key_spec.rb | 2 +- spec/unit/puppet/parser/functions/hash_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_array_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_domain_name_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_float_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_hash_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_integer_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_ip_address_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_mac_address_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_numeric_spec.rb | 2 +- spec/unit/puppet/parser/functions/is_string_spec.rb | 2 +- spec/unit/puppet/parser/functions/join_spec.rb | 2 +- spec/unit/puppet/parser/functions/keys_spec.rb | 2 +- spec/unit/puppet/parser/functions/lstrip_spec.rb | 2 +- spec/unit/puppet/parser/functions/member_spec.rb | 2 +- spec/unit/puppet/parser/functions/merge_spec.rb | 2 +- spec/unit/puppet/parser/functions/num2bool_spec.rb | 2 +- spec/unit/puppet/parser/functions/parsejson_spec.rb | 2 +- spec/unit/puppet/parser/functions/parseyaml_spec.rb | 2 +- spec/unit/puppet/parser/functions/prefix_spec.rb | 2 +- spec/unit/puppet/parser/functions/range_spec.rb | 2 +- spec/unit/puppet/parser/functions/reverse_spec.rb | 2 +- spec/unit/puppet/parser/functions/rstrip_spec.rb | 2 +- spec/unit/puppet/parser/functions/shuffle_spec.rb | 2 +- spec/unit/puppet/parser/functions/size_spec.rb | 2 +- spec/unit/puppet/parser/functions/sort_spec.rb | 2 +- spec/unit/puppet/parser/functions/squeeze_spec.rb | 2 +- spec/unit/puppet/parser/functions/str2bool_spec.rb | 2 +- spec/unit/puppet/parser/functions/strftime_spec.rb | 2 +- spec/unit/puppet/parser/functions/strip_spec.rb | 2 +- spec/unit/puppet/parser/functions/swapcase_spec.rb | 2 +- spec/unit/puppet/parser/functions/time_spec.rb | 2 +- spec/unit/puppet/parser/functions/type_spec.rb | 2 +- spec/unit/puppet/parser/functions/unique_spec.rb | 2 +- spec/unit/puppet/parser/functions/upcase_spec.rb | 2 +- spec/unit/puppet/parser/functions/validate_array_spec.rb | 2 +- spec/unit/puppet/parser/functions/validate_bool_spec.rb | 2 +- spec/unit/puppet/parser/functions/validate_hash_spec.rb | 2 +- spec/unit/puppet/parser/functions/validate_string_spec.rb | 2 +- spec/unit/puppet/parser/functions/values_at_spec.rb | 2 +- spec/unit/puppet/parser/functions/values_spec.rb | 2 +- spec/unit/puppet/parser/functions/zip_spec.rb | 2 +- 54 files changed, 54 insertions(+), 54 deletions(-) (limited to 'spec/unit/puppet') diff --git a/spec/unit/puppet/parser/functions/abs_spec.rb b/spec/unit/puppet/parser/functions/abs_spec.rb index 68e1b3a..c0b4297 100755 --- a/spec/unit/puppet/parser/functions/abs_spec.rb +++ b/spec/unit/puppet/parser/functions/abs_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe "the abs function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("abs").should == "function_abs" diff --git a/spec/unit/puppet/parser/functions/bool2num_spec.rb b/spec/unit/puppet/parser/functions/bool2num_spec.rb index d54f089..518ac85 100755 --- a/spec/unit/puppet/parser/functions/bool2num_spec.rb +++ b/spec/unit/puppet/parser/functions/bool2num_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the bool2num function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("bool2num").should == "function_bool2num" diff --git a/spec/unit/puppet/parser/functions/capitalize_spec.rb b/spec/unit/puppet/parser/functions/capitalize_spec.rb index 9736d5f..69c9758 100755 --- a/spec/unit/puppet/parser/functions/capitalize_spec.rb +++ b/spec/unit/puppet/parser/functions/capitalize_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the capitalize function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("capitalize").should == "function_capitalize" diff --git a/spec/unit/puppet/parser/functions/chomp_spec.rb b/spec/unit/puppet/parser/functions/chomp_spec.rb index 1aacaa0..e425365 100755 --- a/spec/unit/puppet/parser/functions/chomp_spec.rb +++ b/spec/unit/puppet/parser/functions/chomp_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the chomp function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("chomp").should == "function_chomp" diff --git a/spec/unit/puppet/parser/functions/chop_spec.rb b/spec/unit/puppet/parser/functions/chop_spec.rb index b12a4d1..9e466de 100755 --- a/spec/unit/puppet/parser/functions/chop_spec.rb +++ b/spec/unit/puppet/parser/functions/chop_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the chop function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("chop").should == "function_chop" diff --git a/spec/unit/puppet/parser/functions/delete_at_spec.rb b/spec/unit/puppet/parser/functions/delete_at_spec.rb index d6a21da..d8d9618 100755 --- a/spec/unit/puppet/parser/functions/delete_at_spec.rb +++ b/spec/unit/puppet/parser/functions/delete_at_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the delete_at function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("delete_at").should == "function_delete_at" diff --git a/spec/unit/puppet/parser/functions/delete_spec.rb b/spec/unit/puppet/parser/functions/delete_spec.rb index 74d46fc..0549232 100755 --- a/spec/unit/puppet/parser/functions/delete_spec.rb +++ b/spec/unit/puppet/parser/functions/delete_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the delete function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("delete").should == "function_delete" diff --git a/spec/unit/puppet/parser/functions/downcase_spec.rb b/spec/unit/puppet/parser/functions/downcase_spec.rb index 5c2ebe6..acef1f0 100755 --- a/spec/unit/puppet/parser/functions/downcase_spec.rb +++ b/spec/unit/puppet/parser/functions/downcase_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the downcase function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("downcase").should == "function_downcase" diff --git a/spec/unit/puppet/parser/functions/empty_spec.rb b/spec/unit/puppet/parser/functions/empty_spec.rb index 75eec5a..7745875 100755 --- a/spec/unit/puppet/parser/functions/empty_spec.rb +++ b/spec/unit/puppet/parser/functions/empty_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the empty function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("empty").should == "function_empty" end diff --git a/spec/unit/puppet/parser/functions/flatten_spec.rb b/spec/unit/puppet/parser/functions/flatten_spec.rb index adb03f4..d4dfd20 100755 --- a/spec/unit/puppet/parser/functions/flatten_spec.rb +++ b/spec/unit/puppet/parser/functions/flatten_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the flatten function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("flatten").should == "function_flatten" end diff --git a/spec/unit/puppet/parser/functions/getvar_spec.rb b/spec/unit/puppet/parser/functions/getvar_spec.rb index 0fb9c83..62ad192 100644 --- a/spec/unit/puppet/parser/functions/getvar_spec.rb +++ b/spec/unit/puppet/parser/functions/getvar_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:getvar) do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling getvar from puppet' do it "should not compile when no arguments are passed" do diff --git a/spec/unit/puppet/parser/functions/grep_spec.rb b/spec/unit/puppet/parser/functions/grep_spec.rb index d84c401..a93b842 100755 --- a/spec/unit/puppet/parser/functions/grep_spec.rb +++ b/spec/unit/puppet/parser/functions/grep_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the grep function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("grep").should == "function_grep" diff --git a/spec/unit/puppet/parser/functions/has_key_spec.rb b/spec/unit/puppet/parser/functions/has_key_spec.rb index 20ba57e..ae5baf7 100644 --- a/spec/unit/puppet/parser/functions/has_key_spec.rb +++ b/spec/unit/puppet/parser/functions/has_key_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:has_key) do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling has_key from puppet' do it "should not compile when no arguments are passed" do diff --git a/spec/unit/puppet/parser/functions/hash_spec.rb b/spec/unit/puppet/parser/functions/hash_spec.rb index ee09ef7..7c91be9 100644 --- a/spec/unit/puppet/parser/functions/hash_spec.rb +++ b/spec/unit/puppet/parser/functions/hash_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the hash function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("hash").should == "function_hash" diff --git a/spec/unit/puppet/parser/functions/is_array_spec.rb b/spec/unit/puppet/parser/functions/is_array_spec.rb index ebd472b..e7f4bcd 100644 --- a/spec/unit/puppet/parser/functions/is_array_spec.rb +++ b/spec/unit/puppet/parser/functions/is_array_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the is_array function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_array").should == "function_is_array" diff --git a/spec/unit/puppet/parser/functions/is_domain_name_spec.rb b/spec/unit/puppet/parser/functions/is_domain_name_spec.rb index d8467bf..f2ea76d 100644 --- a/spec/unit/puppet/parser/functions/is_domain_name_spec.rb +++ b/spec/unit/puppet/parser/functions/is_domain_name_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the is_domain_name function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_domain_name").should == "function_is_domain_name" diff --git a/spec/unit/puppet/parser/functions/is_float_spec.rb b/spec/unit/puppet/parser/functions/is_float_spec.rb index a00f4bc..2f527d9 100644 --- a/spec/unit/puppet/parser/functions/is_float_spec.rb +++ b/spec/unit/puppet/parser/functions/is_float_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the is_float function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_float").should == "function_is_float" diff --git a/spec/unit/puppet/parser/functions/is_hash_spec.rb b/spec/unit/puppet/parser/functions/is_hash_spec.rb index 3f765d4..bbebf39 100644 --- a/spec/unit/puppet/parser/functions/is_hash_spec.rb +++ b/spec/unit/puppet/parser/functions/is_hash_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the is_hash function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_hash").should == "function_is_hash" diff --git a/spec/unit/puppet/parser/functions/is_integer_spec.rb b/spec/unit/puppet/parser/functions/is_integer_spec.rb index 56735ff..5afbba4 100644 --- a/spec/unit/puppet/parser/functions/is_integer_spec.rb +++ b/spec/unit/puppet/parser/functions/is_integer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the is_integer function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_integer").should == "function_is_integer" diff --git a/spec/unit/puppet/parser/functions/is_ip_address_spec.rb b/spec/unit/puppet/parser/functions/is_ip_address_spec.rb index d231440..c0debb3 100644 --- a/spec/unit/puppet/parser/functions/is_ip_address_spec.rb +++ b/spec/unit/puppet/parser/functions/is_ip_address_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the is_ip_address function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_ip_address").should == "function_is_ip_address" diff --git a/spec/unit/puppet/parser/functions/is_mac_address_spec.rb b/spec/unit/puppet/parser/functions/is_mac_address_spec.rb index 0dcacb1..ca9c590 100644 --- a/spec/unit/puppet/parser/functions/is_mac_address_spec.rb +++ b/spec/unit/puppet/parser/functions/is_mac_address_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the is_mac_address function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_mac_address").should == "function_is_mac_address" diff --git a/spec/unit/puppet/parser/functions/is_numeric_spec.rb b/spec/unit/puppet/parser/functions/is_numeric_spec.rb index 9c1aa40..4078b37 100644 --- a/spec/unit/puppet/parser/functions/is_numeric_spec.rb +++ b/spec/unit/puppet/parser/functions/is_numeric_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the is_numeric function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_numeric").should == "function_is_numeric" diff --git a/spec/unit/puppet/parser/functions/is_string_spec.rb b/spec/unit/puppet/parser/functions/is_string_spec.rb index 36c612c..3756bea 100644 --- a/spec/unit/puppet/parser/functions/is_string_spec.rb +++ b/spec/unit/puppet/parser/functions/is_string_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the is_string function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_string").should == "function_is_string" diff --git a/spec/unit/puppet/parser/functions/join_spec.rb b/spec/unit/puppet/parser/functions/join_spec.rb index 694fdce..aafa1a7 100644 --- a/spec/unit/puppet/parser/functions/join_spec.rb +++ b/spec/unit/puppet/parser/functions/join_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the join function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("join").should == "function_join" diff --git a/spec/unit/puppet/parser/functions/keys_spec.rb b/spec/unit/puppet/parser/functions/keys_spec.rb index def4a28..fdd7a70 100644 --- a/spec/unit/puppet/parser/functions/keys_spec.rb +++ b/spec/unit/puppet/parser/functions/keys_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the keys function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("keys").should == "function_keys" diff --git a/spec/unit/puppet/parser/functions/lstrip_spec.rb b/spec/unit/puppet/parser/functions/lstrip_spec.rb index 77c18c7..b280ae7 100644 --- a/spec/unit/puppet/parser/functions/lstrip_spec.rb +++ b/spec/unit/puppet/parser/functions/lstrip_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the lstrip function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("lstrip").should == "function_lstrip" diff --git a/spec/unit/puppet/parser/functions/member_spec.rb b/spec/unit/puppet/parser/functions/member_spec.rb index e939d95..6e9a023 100644 --- a/spec/unit/puppet/parser/functions/member_spec.rb +++ b/spec/unit/puppet/parser/functions/member_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the member function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("member").should == "function_member" diff --git a/spec/unit/puppet/parser/functions/merge_spec.rb b/spec/unit/puppet/parser/functions/merge_spec.rb index 78810cf..9e8a619 100644 --- a/spec/unit/puppet/parser/functions/merge_spec.rb +++ b/spec/unit/puppet/parser/functions/merge_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:merge) do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling merge from puppet' do it "should not compile when no arguments are passed" do diff --git a/spec/unit/puppet/parser/functions/num2bool_spec.rb b/spec/unit/puppet/parser/functions/num2bool_spec.rb index 907b6a3..640c689 100644 --- a/spec/unit/puppet/parser/functions/num2bool_spec.rb +++ b/spec/unit/puppet/parser/functions/num2bool_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the num2bool function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("num2bool").should == "function_num2bool" diff --git a/spec/unit/puppet/parser/functions/parsejson_spec.rb b/spec/unit/puppet/parser/functions/parsejson_spec.rb index 4eb1743..f179ac1 100644 --- a/spec/unit/puppet/parser/functions/parsejson_spec.rb +++ b/spec/unit/puppet/parser/functions/parsejson_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the parsejson function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("parsejson").should == "function_parsejson" diff --git a/spec/unit/puppet/parser/functions/parseyaml_spec.rb b/spec/unit/puppet/parser/functions/parseyaml_spec.rb index 39ec184..0c7aea8 100644 --- a/spec/unit/puppet/parser/functions/parseyaml_spec.rb +++ b/spec/unit/puppet/parser/functions/parseyaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the parseyaml function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("parseyaml").should == "function_parseyaml" diff --git a/spec/unit/puppet/parser/functions/prefix_spec.rb b/spec/unit/puppet/parser/functions/prefix_spec.rb index 4a55cc4..5cf592b 100644 --- a/spec/unit/puppet/parser/functions/prefix_spec.rb +++ b/spec/unit/puppet/parser/functions/prefix_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the prefix function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("prefix").should == "function_prefix" diff --git a/spec/unit/puppet/parser/functions/range_spec.rb b/spec/unit/puppet/parser/functions/range_spec.rb index e1bd898..42751f4 100644 --- a/spec/unit/puppet/parser/functions/range_spec.rb +++ b/spec/unit/puppet/parser/functions/range_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the range function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("range").should == "function_range" diff --git a/spec/unit/puppet/parser/functions/reverse_spec.rb b/spec/unit/puppet/parser/functions/reverse_spec.rb index 8024cb3..1b59206 100644 --- a/spec/unit/puppet/parser/functions/reverse_spec.rb +++ b/spec/unit/puppet/parser/functions/reverse_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the reverse function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("reverse").should == "function_reverse" diff --git a/spec/unit/puppet/parser/functions/rstrip_spec.rb b/spec/unit/puppet/parser/functions/rstrip_spec.rb index 99f4dde..d90de1d 100644 --- a/spec/unit/puppet/parser/functions/rstrip_spec.rb +++ b/spec/unit/puppet/parser/functions/rstrip_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the rstrip function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("rstrip").should == "function_rstrip" diff --git a/spec/unit/puppet/parser/functions/shuffle_spec.rb b/spec/unit/puppet/parser/functions/shuffle_spec.rb index 4bb77f2..93346d5 100644 --- a/spec/unit/puppet/parser/functions/shuffle_spec.rb +++ b/spec/unit/puppet/parser/functions/shuffle_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the shuffle function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("shuffle").should == "function_shuffle" diff --git a/spec/unit/puppet/parser/functions/size_spec.rb b/spec/unit/puppet/parser/functions/size_spec.rb index 42c0209..b1c435a 100644 --- a/spec/unit/puppet/parser/functions/size_spec.rb +++ b/spec/unit/puppet/parser/functions/size_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the size function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("size").should == "function_size" diff --git a/spec/unit/puppet/parser/functions/sort_spec.rb b/spec/unit/puppet/parser/functions/sort_spec.rb index f0e9649..3187a5a 100644 --- a/spec/unit/puppet/parser/functions/sort_spec.rb +++ b/spec/unit/puppet/parser/functions/sort_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the sort function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("sort").should == "function_sort" diff --git a/spec/unit/puppet/parser/functions/squeeze_spec.rb b/spec/unit/puppet/parser/functions/squeeze_spec.rb index 8acec64..60e5a30 100644 --- a/spec/unit/puppet/parser/functions/squeeze_spec.rb +++ b/spec/unit/puppet/parser/functions/squeeze_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the squeeze function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("squeeze").should == "function_squeeze" diff --git a/spec/unit/puppet/parser/functions/str2bool_spec.rb b/spec/unit/puppet/parser/functions/str2bool_spec.rb index 2f01338..2782bbe 100644 --- a/spec/unit/puppet/parser/functions/str2bool_spec.rb +++ b/spec/unit/puppet/parser/functions/str2bool_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the str2bool function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("str2bool").should == "function_str2bool" diff --git a/spec/unit/puppet/parser/functions/strftime_spec.rb b/spec/unit/puppet/parser/functions/strftime_spec.rb index bb45371..df42b6f 100644 --- a/spec/unit/puppet/parser/functions/strftime_spec.rb +++ b/spec/unit/puppet/parser/functions/strftime_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the strftime function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("strftime").should == "function_strftime" diff --git a/spec/unit/puppet/parser/functions/strip_spec.rb b/spec/unit/puppet/parser/functions/strip_spec.rb index 47a0e0d..fccdd26 100644 --- a/spec/unit/puppet/parser/functions/strip_spec.rb +++ b/spec/unit/puppet/parser/functions/strip_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the strip function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("strip").should == "function_strip" end diff --git a/spec/unit/puppet/parser/functions/swapcase_spec.rb b/spec/unit/puppet/parser/functions/swapcase_spec.rb index 9806d38..808b415 100644 --- a/spec/unit/puppet/parser/functions/swapcase_spec.rb +++ b/spec/unit/puppet/parser/functions/swapcase_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the swapcase function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("swapcase").should == "function_swapcase" diff --git a/spec/unit/puppet/parser/functions/time_spec.rb b/spec/unit/puppet/parser/functions/time_spec.rb index 32c3ab4..e9fb76e 100644 --- a/spec/unit/puppet/parser/functions/time_spec.rb +++ b/spec/unit/puppet/parser/functions/time_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the time function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("time").should == "function_time" diff --git a/spec/unit/puppet/parser/functions/type_spec.rb b/spec/unit/puppet/parser/functions/type_spec.rb index c7babc6..8fec88f 100644 --- a/spec/unit/puppet/parser/functions/type_spec.rb +++ b/spec/unit/puppet/parser/functions/type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the type function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("type").should == "function_type" end diff --git a/spec/unit/puppet/parser/functions/unique_spec.rb b/spec/unit/puppet/parser/functions/unique_spec.rb index c0c5872..5d48d49 100644 --- a/spec/unit/puppet/parser/functions/unique_spec.rb +++ b/spec/unit/puppet/parser/functions/unique_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the unique function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("unique").should == "function_unique" diff --git a/spec/unit/puppet/parser/functions/upcase_spec.rb b/spec/unit/puppet/parser/functions/upcase_spec.rb index f507009..5db5513 100644 --- a/spec/unit/puppet/parser/functions/upcase_spec.rb +++ b/spec/unit/puppet/parser/functions/upcase_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the upcase function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("upcase").should == "function_upcase" diff --git a/spec/unit/puppet/parser/functions/validate_array_spec.rb b/spec/unit/puppet/parser/functions/validate_array_spec.rb index f015e42..8eee72a 100644 --- a/spec/unit/puppet/parser/functions/validate_array_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_array_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_array) do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling validate_array from puppet' do %w{ true false }.each do |the_string| diff --git a/spec/unit/puppet/parser/functions/validate_bool_spec.rb b/spec/unit/puppet/parser/functions/validate_bool_spec.rb index 798b129..31ab8fb 100644 --- a/spec/unit/puppet/parser/functions/validate_bool_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_bool_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_bool) do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling validate_bool from puppet' do %w{ true false }.each do |the_string| diff --git a/spec/unit/puppet/parser/functions/validate_hash_spec.rb b/spec/unit/puppet/parser/functions/validate_hash_spec.rb index aad8271..f63db1d 100644 --- a/spec/unit/puppet/parser/functions/validate_hash_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_hash_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_hash) do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling validate_hash from puppet' do diff --git a/spec/unit/puppet/parser/functions/validate_string_spec.rb b/spec/unit/puppet/parser/functions/validate_string_spec.rb index caeefa0..f40bf2a 100644 --- a/spec/unit/puppet/parser/functions/validate_string_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_string_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_string) do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling validate_string from puppet' do diff --git a/spec/unit/puppet/parser/functions/values_at_spec.rb b/spec/unit/puppet/parser/functions/values_at_spec.rb index 8e7bfa2..08e95a5 100644 --- a/spec/unit/puppet/parser/functions/values_at_spec.rb +++ b/spec/unit/puppet/parser/functions/values_at_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the values_at function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("values_at").should == "function_values_at" diff --git a/spec/unit/puppet/parser/functions/values_spec.rb b/spec/unit/puppet/parser/functions/values_spec.rb index cd2f107..14ae417 100644 --- a/spec/unit/puppet/parser/functions/values_spec.rb +++ b/spec/unit/puppet/parser/functions/values_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the values function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("values").should == "function_values" diff --git a/spec/unit/puppet/parser/functions/zip_spec.rb b/spec/unit/puppet/parser/functions/zip_spec.rb index b6d8713..f45ab17 100644 --- a/spec/unit/puppet/parser/functions/zip_spec.rb +++ b/spec/unit/puppet/parser/functions/zip_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "the zip function" do - let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should raise a ParseError if there is less than 1 arguments" do lambda { scope.function_zip([]) }.should( raise_error(Puppet::ParseError)) -- cgit v1.2.3 From 98ff3abd09ed447da37f09dce1ed2d95d0d05397 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 19 Jul 2012 16:14:37 -0700 Subject: (Maint) use PuppetlabsSpec::PuppetSeams.parser_scope (2.3.x) This patch is the same approach as the one that want into 2.2.x. It covers the functions in 2.3.x that do not exist in 2.2.x. Without this patch all of the spec tests for parser functions in stdlib would instantiate their own scope instances. This is a problem because the standard library is tightly coupled with the internal behavior of Puppet. Tight coupling like this creates failures when we change the internal behavior of Puppet. This is exactly what happened recently when we changed the method signature for the initializer of Puppet::Parser::Scope instances. This patch fixes the problem by creating scope instances using the puppet labs spec helper. The specific method that provides scope instances in Puppet-version-independent way is something like this: let(:scope) { PuppetlabsSpec::PuppetInternals.scope } This patch simply implements this across the board. --- .../puppet/parser/functions/str2saltedsha512_spec.rb | 20 +++++++------------- .../parser/functions/validate_absolute_path_spec.rb | 8 ++------ .../unit/puppet/parser/functions/validate_re_spec.rb | 8 +------- .../puppet/parser/functions/validate_slength_spec.rb | 8 ++------ 4 files changed, 12 insertions(+), 32 deletions(-) (limited to 'spec/unit/puppet') diff --git a/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb b/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb index 11485aa..a692c31 100644 --- a/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb +++ b/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb @@ -1,39 +1,33 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the str2saltedsha512 function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - before :each do - @scope = Puppet::Parser::Scope.new - end + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("str2saltedsha512").should == "function_str2saltedsha512" end it "should raise a ParseError if there is less than 1 argument" do - expect { @scope.function_str2saltedsha512([]) }.should( raise_error(Puppet::ParseError) ) + expect { scope.function_str2saltedsha512([]) }.should( raise_error(Puppet::ParseError) ) end it "should raise a ParseError if there is more than 1 argument" do - expect { @scope.function_str2saltedsha512(['foo', 'bar', 'baz']) }.should( raise_error(Puppet::ParseError) ) + expect { scope.function_str2saltedsha512(['foo', 'bar', 'baz']) }.should( raise_error(Puppet::ParseError) ) end it "should return a salted-sha512 password hash 136 characters in length" do - result = @scope.function_str2saltedsha512(["password"]) + result = scope.function_str2saltedsha512(["password"]) result.length.should(eq(136)) end it "should raise an error if you pass a non-string password" do - expect { @scope.function_str2saltedsha512([1234]) }.should( raise_error(Puppet::ParseError) ) + expect { scope.function_str2saltedsha512([1234]) }.should( raise_error(Puppet::ParseError) ) end it "should generate a valid password" do # Allow the function to generate a password based on the string 'password' - password_hash = @scope.function_str2saltedsha512(["password"]) + password_hash = scope.function_str2saltedsha512(["password"]) # Separate the Salt and Password from the Password Hash salt = password_hash[0..7] diff --git a/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb b/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb index 1e0b5ac..9d66fcb 100644 --- a/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb @@ -1,14 +1,10 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_absolute_path) do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } # The subject of these examplres is the method itself. - subject do - Puppet::Parser::Scope.new.method :function_validate_absolute_path - end + subject() { scope.method(:function_validate_absolute_path) } describe "Valid Paths" do def self.valid_paths diff --git a/spec/unit/puppet/parser/functions/validate_re_spec.rb b/spec/unit/puppet/parser/functions/validate_re_spec.rb index c35ae14..a07ad47 100644 --- a/spec/unit/puppet/parser/functions/validate_re_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_re_spec.rb @@ -1,13 +1,7 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_re) do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - let(:scope) do - scope = Puppet::Parser::Scope.new - end + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } # The subject of these examplres is the method itself. subject do diff --git a/spec/unit/puppet/parser/functions/validate_slength_spec.rb b/spec/unit/puppet/parser/functions/validate_slength_spec.rb index d2d4ca0..eccf908 100755 --- a/spec/unit/puppet/parser/functions/validate_slength_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_slength_spec.rb @@ -1,13 +1,9 @@ -#!/usr/bin/env rspec +#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the validate_slength function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - end - - let(:scope) { Puppet::Parser::Scope.new } + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("validate_slength").should == "function_validate_slength" -- cgit v1.2.3 From c1297755d4af11eb918ad987983ebd8398e38f58 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 19 Jul 2012 17:37:39 -0700 Subject: (Maint) Fix up the get_module_path parser function This patch switches the spec tests for the get_module_path function to use mock objects. The underlying Puppet::Module.find method has reasonable test coverage inside of Puppet core so we might as well break the tight dependency while we're fixing up the specs to use the new parser scope. The behavior of the parser function itself should still have complete coverage even though the tests have switched to mock the implementation inside of Puppet. --- .../parser/functions/get_module_path_spec.rb | 52 +++++++++++----------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'spec/unit/puppet') diff --git a/spec/unit/puppet/parser/functions/get_module_path_spec.rb b/spec/unit/puppet/parser/functions/get_module_path_spec.rb index d8340f4..0a769eb 100644 --- a/spec/unit/puppet/parser/functions/get_module_path_spec.rb +++ b/spec/unit/puppet/parser/functions/get_module_path_spec.rb @@ -1,42 +1,44 @@ -#!/usr/bin/env rspec -require 'puppet' -require 'fileutils' +#! /usr/bin/env ruby -S rspec require 'spec_helper' + describe Puppet::Parser::Functions.function(:get_module_path) do - include PuppetSpec::Files + Internals = PuppetlabsSpec::PuppetInternals - def get_scope(environment = 'production') - scope = Puppet::Parser::Scope.new - scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => environment)) - scope + def scope(environment = "production") + Internals.scope(:compiler => Internals.compiler(:node => Internals.node(:environment => environment))) end + it 'should only allow one argument' do - expect { get_scope.function_get_module_path([]) }.should raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) - expect { get_scope.function_get_module_path(['1','2','3']) }.should raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) + expect { scope.function_get_module_path([]) }.should raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) + expect { scope.function_get_module_path(['1','2','3']) }.should raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) end it 'should raise an exception when the module cannot be found' do - expect { get_scope.function_get_module_path(['foo']) }.should raise_error(Puppet::ParseError, /Could not find module/) + expect { scope.function_get_module_path(['foo']) }.should raise_error(Puppet::ParseError, /Could not find module/) end describe 'when locating a module' do - let(:modulepath) { tmpdir('modulepath') } - let(:foo_path) { File.join(modulepath, 'foo') } - before(:each) { FileUtils.mkdir(foo_path) } + let(:modulepath) { "/tmp/does_not_exist" } + let(:path_of_module_foo) do + mod = mock("Puppet::Module") + mod.stubs(:path).returns("/tmp/does_not_exist/foo") + mod + end + + before(:each) { Puppet[:modulepath] = modulepath } + it 'should be able to find module paths from the modulepath setting' do - Puppet[:modulepath] = modulepath - get_scope.function_get_module_path(['foo']).should == foo_path + Puppet::Module.expects(:find).with('foo', 'production').returns(path_of_module_foo) + scope.function_get_module_path(['foo']).should == path_of_module_foo.path end it 'should be able to find module paths when the modulepath is a list' do Puppet[:modulepath] = modulepath + ":/tmp" - get_scope.function_get_module_path(['foo']).should == foo_path + Puppet::Module.expects(:find).with('foo', 'production').returns(path_of_module_foo) + scope.function_get_module_path(['foo']).should == path_of_module_foo.path end - it 'should be able to find module paths from the environment' do - conf_file = tmpfile('conffile') - File.open(conf_file, 'w') do |fh| - fh.write("[dansenvironment]\nmodulepath = #{modulepath}") - end - Puppet[:config] = conf_file - Puppet.parse_config - get_scope('dansenvironment').function_get_module_path(['foo']).should ==foo_path + it 'should respect the environment' do + pending("Disabled on Puppet 2.6.x") if Puppet.version =~ /^2\.6\b/ + Puppet.settings[:environment] = 'danstestenv' + Puppet::Module.expects(:find).with('foo', 'danstestenv').returns(path_of_module_foo) + scope('danstestenv').function_get_module_path(['foo']).should == path_of_module_foo.path end end end -- cgit v1.2.3 From fd2ce0d24797b22022ecb14c32ffe88ff70de319 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Mon, 23 Jul 2012 15:47:51 -0700 Subject: (Maint) Don't mock with mocha Without this patch applied the stdlib module has load-order issues with mocha and rspec-puppet. The root cause has yet to be determined, but we've narrowed it down to this description: "If any rspec-puppet example groups run before parser function example groups and the parser function example groups use mock() then you'll get this error:" You can exercise this explicitly with: rspec -fd spec/unit/puppet/{provider,type,parser} This will ensure rspec runs all of the provider and type spec tests, which are rspec-puppet ones, before the parser function specs are run. I should also note we empted out the test in the file_line provider to be nothing except an empty describe block and this was still sufficient to trigger the load order error described here. Failures: 1) function_get_module_path when locating a module should be able to find module paths from the modulepath setting Failure/Error: mod = mock("Puppet::Module") NoMethodError: undefined method `mock' for # # ./spec/unit/puppet/parser/functions/get_module_path_spec.rb:21 # ./spec/unit/puppet/parser/functions/get_module_path_spec.rb:29 2) function_get_module_path when locating a module should be able to find module paths when the modulepath is a list Failure/Error: mod = mock("Puppet::Module") NoMethodError: undefined method `mock' for # # ./spec/unit/puppet/parser/functions/get_module_path_spec.rb:21 # ./spec/unit/puppet/parser/functions/get_module_path_spec.rb:34 3) function_get_module_path when locating a module should respect the environment Failure/Error: mod = mock("Puppet::Module") NoMethodError: undefined method `mock' for # # ./spec/unit/puppet/parser/functions/get_module_path_spec.rb:21 # ./spec/unit/puppet/parser/functions/get_module_path_spec.rb:40 Finished in 1.53 seconds 326 examples, 3 failures, 1 pending Paired-with: Andrew Parker --- spec/unit/puppet/parser/functions/get_module_path_spec.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'spec/unit/puppet') diff --git a/spec/unit/puppet/parser/functions/get_module_path_spec.rb b/spec/unit/puppet/parser/functions/get_module_path_spec.rb index 0a769eb..e761706 100644 --- a/spec/unit/puppet/parser/functions/get_module_path_spec.rb +++ b/spec/unit/puppet/parser/functions/get_module_path_spec.rb @@ -3,6 +3,12 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:get_module_path) do Internals = PuppetlabsSpec::PuppetInternals + class StubModule + attr_reader :path + def initialize(path) + @path = path + end + end def scope(environment = "production") Internals.scope(:compiler => Internals.compiler(:node => Internals.node(:environment => environment))) @@ -17,11 +23,7 @@ describe Puppet::Parser::Functions.function(:get_module_path) do end describe 'when locating a module' do let(:modulepath) { "/tmp/does_not_exist" } - let(:path_of_module_foo) do - mod = mock("Puppet::Module") - mod.stubs(:path).returns("/tmp/does_not_exist/foo") - mod - end + let(:path_of_module_foo) { StubModule.new("/tmp/does_not_exist/foo") } before(:each) { Puppet[:modulepath] = modulepath } -- cgit v1.2.3 From 09322ad94398d69081aae44cc770830ac2144b75 Mon Sep 17 00:00:00 2001 From: Patrick Carlisle Date: Thu, 9 Aug 2012 14:18:30 -0700 Subject: Use rvalue functions correctly A bug fix in Puppet exposed that several tests were using rvalue functions incorrectly (this was not properly checked by puppet before). This fixes those tests. --- spec/unit/puppet/parser/functions/getvar_spec.rb | 14 +++++++++----- spec/unit/puppet/parser/functions/has_key_spec.rb | 22 ++++++++++++++++------ spec/unit/puppet/parser/functions/merge_spec.rb | 12 ++++++++---- 3 files changed, 33 insertions(+), 15 deletions(-) (limited to 'spec/unit/puppet') diff --git a/spec/unit/puppet/parser/functions/getvar_spec.rb b/spec/unit/puppet/parser/functions/getvar_spec.rb index 62ad192..a8aeec1 100644 --- a/spec/unit/puppet/parser/functions/getvar_spec.rb +++ b/spec/unit/puppet/parser/functions/getvar_spec.rb @@ -6,16 +6,20 @@ describe Puppet::Parser::Functions.function(:getvar) do describe 'when calling getvar from puppet' do it "should not compile when no arguments are passed" do - Puppet[:code] = 'getvar()' - expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + Puppet[:code] = '$foo = getvar()' + expect { + scope.compiler.compile + }.to raise_error(Puppet::ParseError, /wrong number of arguments/) end + it "should not compile when too many arguments are passed" do - Puppet[:code] = 'getvar("foo::bar", "baz")' - expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + Puppet[:code] = '$foo = getvar("foo::bar", "baz")' + expect { + scope.compiler.compile + }.to raise_error(Puppet::ParseError, /wrong number of arguments/) end it "should lookup variables in other namespaces" do - pending "Puppet doesn't appear to think getvar is an rvalue function... BUG?" Puppet[:code] = <<-'ENDofPUPPETcode' class site::data { $foo = 'baz' } include site::data diff --git a/spec/unit/puppet/parser/functions/has_key_spec.rb b/spec/unit/puppet/parser/functions/has_key_spec.rb index ae5baf7..b1eb0ff 100644 --- a/spec/unit/puppet/parser/functions/has_key_spec.rb +++ b/spec/unit/puppet/parser/functions/has_key_spec.rb @@ -6,22 +6,32 @@ describe Puppet::Parser::Functions.function(:has_key) do describe 'when calling has_key from puppet' do it "should not compile when no arguments are passed" do - Puppet[:code] = 'has_key()' - expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + Puppet[:code] = '$x = has_key()' + expect { + scope.compiler.compile + }.to raise_error(Puppet::ParseError, /wrong number of arguments/) end + it "should not compile when 1 argument is passed" do - Puppet[:code] = "has_key('foo')" - expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + Puppet[:code] = "$x = has_key('foo')" + expect { + scope.compiler.compile + }.to raise_error(Puppet::ParseError, /wrong number of arguments/) end + it "should require the first value to be a Hash" do - Puppet[:code] = "has_key('foo', 'bar')" - expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /expects the first argument to be a hash/) + Puppet[:code] = "$x = has_key('foo', 'bar')" + expect { + scope.compiler.compile + }.to raise_error(Puppet::ParseError, /expects the first argument to be a hash/) end end + describe 'when calling the function has_key from a scope instance' do it 'should detect existing keys' do scope.function_has_key([{'one' => 1}, 'one']).should be_true end + it 'should detect existing keys' do scope.function_has_key([{'one' => 1}, 'two']).should be_false end diff --git a/spec/unit/puppet/parser/functions/merge_spec.rb b/spec/unit/puppet/parser/functions/merge_spec.rb index 9e8a619..192da4c 100644 --- a/spec/unit/puppet/parser/functions/merge_spec.rb +++ b/spec/unit/puppet/parser/functions/merge_spec.rb @@ -7,12 +7,16 @@ describe Puppet::Parser::Functions.function(:merge) do describe 'when calling merge from puppet' do it "should not compile when no arguments are passed" do - Puppet[:code] = 'merge()' - expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + Puppet[:code] = '$x = merge()' + expect { + scope.compiler.compile + }.to raise_error(Puppet::ParseError, /wrong number of arguments/) end it "should not compile when 1 argument is passed" do - Puppet[:code] = "$my_hash={'one' => 1}\nmerge($my_hash)" - expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + Puppet[:code] = "$my_hash={'one' => 1}\n$x = merge($my_hash)" + expect { + scope.compiler.compile + }.to raise_error(Puppet::ParseError, /wrong number of arguments/) end end describe 'when calling merge on the scope instance' do -- cgit v1.2.3 From 424b56da616041e365cb471dafc05a3d7ade4e45 Mon Sep 17 00:00:00 2001 From: Patrick Carlisle Date: Thu, 9 Aug 2012 14:33:10 -0700 Subject: Make sure functions are loaded for each test The test_helper code in Puppet now resets function state between each test. This patch fixes two spec files where the function was not actually loaded in the tests, causing them to fail. --- spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb | 8 ++++++-- spec/unit/puppet/parser/functions/validate_re_spec.rb | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'spec/unit/puppet') diff --git a/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb b/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb index 9d66fcb..08aaf78 100644 --- a/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb @@ -3,8 +3,12 @@ require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_absolute_path) do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - # The subject of these examplres is the method itself. - subject() { scope.method(:function_validate_absolute_path) } + # The subject of these examples is the method itself. + subject do + # This makes sure the function is loaded within each test + function_name = Puppet::Parser::Functions.function(:validate_absolute_path) + scope.method(function_name) + end describe "Valid Paths" do def self.valid_paths diff --git a/spec/unit/puppet/parser/functions/validate_re_spec.rb b/spec/unit/puppet/parser/functions/validate_re_spec.rb index a07ad47..d189efb 100644 --- a/spec/unit/puppet/parser/functions/validate_re_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_re_spec.rb @@ -5,7 +5,9 @@ describe Puppet::Parser::Functions.function(:validate_re) do # The subject of these examplres is the method itself. subject do - scope.method :function_validate_re + # This makes sure the function is loaded within each test + function_name = Puppet::Parser::Functions.function(:validate_re) + scope.method(function_name) end context 'Using Puppet::Parser::Scope.new' do -- cgit v1.2.3