Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from jeffmccune/fix/2.3.x/go_green
Fix up 2.3.x for new scope
- Loading branch information
Showing
61 changed files
with
324 additions
and
837 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
#!/usr/bin/env rspec | ||
#! /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::PuppetInternals.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,24 @@ | ||
#!/usr/bin/env rspec | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper' | ||
|
||
describe "the bool2num function" do | ||
before :all do | ||
Puppet::Parser::Functions.autoloader.loadall | ||
end | ||
|
||
before :each do | ||
@scope = Puppet::Parser::Scope.new | ||
end | ||
let(:scope) { PuppetlabsSpec::PuppetInternals.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
#!/usr/bin/env rspec | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper' | ||
|
||
describe "the capitalize function" do | ||
before :all do | ||
Puppet::Parser::Functions.autoloader.loadall | ||
end | ||
|
||
before :each do | ||
@scope = Puppet::Parser::Scope.new | ||
end | ||
let(:scope) { PuppetlabsSpec::PuppetInternals.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
#!/usr/bin/env rspec | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper' | ||
|
||
describe "the chomp function" do | ||
before :all do | ||
Puppet::Parser::Functions.autoloader.loadall | ||
end | ||
|
||
before :each do | ||
@scope = Puppet::Parser::Scope.new | ||
end | ||
let(:scope) { PuppetlabsSpec::PuppetInternals.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
#!/usr/bin/env rspec | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper' | ||
|
||
describe "the chop function" do | ||
before :all do | ||
Puppet::Parser::Functions.autoloader.loadall | ||
end | ||
|
||
before :each do | ||
@scope = Puppet::Parser::Scope.new | ||
end | ||
let(:scope) { PuppetlabsSpec::PuppetInternals.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
#!/usr/bin/env rspec | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper' | ||
|
||
describe "the delete_at function" do | ||
before :all do | ||
Puppet::Parser::Functions.autoloader.loadall | ||
end | ||
|
||
before :each do | ||
@scope = Puppet::Parser::Scope.new | ||
end | ||
let(:scope) { PuppetlabsSpec::PuppetInternals.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
#!/usr/bin/env rspec | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper' | ||
|
||
describe "the delete function" do | ||
before :all do | ||
Puppet::Parser::Functions.autoloader.loadall | ||
end | ||
|
||
before :each do | ||
@scope = Puppet::Parser::Scope.new | ||
end | ||
let(:scope) { PuppetlabsSpec::PuppetInternals.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,24 @@ | ||
#!/usr/bin/env rspec | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper' | ||
|
||
describe "the downcase function" do | ||
before :all do | ||
Puppet::Parser::Functions.autoloader.loadall | ||
end | ||
|
||
before :each do | ||
@scope = Puppet::Parser::Scope.new | ||
end | ||
let(:scope) { PuppetlabsSpec::PuppetInternals.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,23 @@ | ||
#!/usr/bin/env rspec | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper' | ||
|
||
describe "the empty function" do | ||
before :all do | ||
Puppet::Parser::Functions.autoloader.loadall | ||
end | ||
|
||
before :each do | ||
@scope = Puppet::Parser::Scope.new | ||
end | ||
|
||
let(:scope) { PuppetlabsSpec::PuppetInternals.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,23 @@ | ||
#!/usr/bin/env rspec | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper' | ||
|
||
describe "the flatten function" do | ||
before :all do | ||
Puppet::Parser::Functions.autoloader.loadall | ||
end | ||
|
||
before :each do | ||
@scope = Puppet::Parser::Scope.new | ||
end | ||
|
||
let(:scope) { PuppetlabsSpec::PuppetInternals.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 |
Oops, something went wrong.