Skip to content

Commit 731c07e

Browse files
author
Jeff McCune
committed
Merge pull request #80 from jeffmccune/fix/2.3.x/go_green
Fix up 2.3.x for new scope
2 parents 730aee4 + c129775 commit 731c07e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+324
-837
lines changed

lib/puppet/parser/functions/get_module_path.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Puppet::Parser::Functions
77
$module_path = get_module_path('stdlib')
88
EOT
99
) do |args|
10-
raise(Puppet::ParseError, "get_module_name(): Wrong number of arguments, expects one") unless args.size == 1
10+
raise(Puppet::ParseError, "get_module_path(): Wrong number of arguments, expects one") unless args.size == 1
1111
if module_path = Puppet::Module.find(args[0], compiler.environment.to_s)
1212
module_path.path
1313
else

spec/spec_helper.rb

+1-23
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,5 @@
1010
gem 'rspec', '>=2.0.0'
1111
require 'rspec/expectations'
1212

13+
require 'puppetlabs_spec_helper/module_spec_helper'
1314

14-
# So everyone else doesn't have to include this base constant.
15-
module PuppetSpec
16-
FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR)
17-
end
18-
19-
# TODO: ultimately would like to move these requires into the puppet_spec_helper.rb file, but the namespaces
20-
# are not currently the same between the two, so tests would need to be modified. Not ready to undertake that
21-
# just yet.
22-
require 'puppet_spec/files'
23-
24-
require 'puppet_spec_helper'
25-
26-
27-
RSpec.configure do |config|
28-
29-
config.before :each do
30-
GC.disable
31-
end
32-
33-
config.after :each do
34-
GC.enable
35-
end
36-
end
+6-12
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
1-
#!/usr/bin/env rspec
1+
#! /usr/bin/env ruby -S rspec
2+
23
require 'spec_helper'
34

45
describe "the abs function" do
5-
before :all do
6-
Puppet::Parser::Functions.autoloader.loadall
7-
end
8-
9-
before :each do
10-
@scope = Puppet::Parser::Scope.new
11-
end
6+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
127

138
it "should exist" do
149
Puppet::Parser::Functions.function("abs").should == "function_abs"
1510
end
1611

1712
it "should raise a ParseError if there is less than 1 arguments" do
18-
lambda { @scope.function_abs([]) }.should( raise_error(Puppet::ParseError))
13+
lambda { scope.function_abs([]) }.should( raise_error(Puppet::ParseError))
1914
end
2015

2116
it "should convert a negative number into a positive" do
22-
result = @scope.function_abs(["-34"])
17+
result = scope.function_abs(["-34"])
2318
result.should(eq(34))
2419
end
2520

2621
it "should do nothing with a positive number" do
27-
result = @scope.function_abs(["5678"])
22+
result = scope.function_abs(["5678"])
2823
result.should(eq(5678))
2924
end
30-
3125
end
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
1-
#!/usr/bin/env rspec
1+
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper'
33

44
describe "the bool2num function" do
5-
before :all do
6-
Puppet::Parser::Functions.autoloader.loadall
7-
end
8-
9-
before :each do
10-
@scope = Puppet::Parser::Scope.new
11-
end
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
126

137
it "should exist" do
148
Puppet::Parser::Functions.function("bool2num").should == "function_bool2num"
159
end
1610

1711
it "should raise a ParseError if there is less than 1 arguments" do
18-
lambda { @scope.function_bool2num([]) }.should( raise_error(Puppet::ParseError))
12+
lambda { scope.function_bool2num([]) }.should( raise_error(Puppet::ParseError))
1913
end
2014

2115
it "should convert true to 1" do
22-
result = @scope.function_bool2num([true])
16+
result = scope.function_bool2num([true])
2317
result.should(eq(1))
2418
end
2519

2620
it "should convert false to 0" do
27-
result = @scope.function_bool2num([false])
21+
result = scope.function_bool2num([false])
2822
result.should(eq(0))
2923
end
30-
3124
end
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
#!/usr/bin/env rspec
1+
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper'
33

44
describe "the capitalize function" do
5-
before :all do
6-
Puppet::Parser::Functions.autoloader.loadall
7-
end
8-
9-
before :each do
10-
@scope = Puppet::Parser::Scope.new
11-
end
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
126

137
it "should exist" do
148
Puppet::Parser::Functions.function("capitalize").should == "function_capitalize"
159
end
1610

1711
it "should raise a ParseError if there is less than 1 arguments" do
18-
lambda { @scope.function_capitalize([]) }.should( raise_error(Puppet::ParseError))
12+
lambda { scope.function_capitalize([]) }.should( raise_error(Puppet::ParseError))
1913
end
2014

2115
it "should capitalize the beginning of a string" do
22-
result = @scope.function_capitalize(["abc"])
16+
result = scope.function_capitalize(["abc"])
2317
result.should(eq("Abc"))
2418
end
25-
2619
end
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
#!/usr/bin/env rspec
1+
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper'
33

44
describe "the chomp function" do
5-
before :all do
6-
Puppet::Parser::Functions.autoloader.loadall
7-
end
8-
9-
before :each do
10-
@scope = Puppet::Parser::Scope.new
11-
end
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
126

137
it "should exist" do
148
Puppet::Parser::Functions.function("chomp").should == "function_chomp"
159
end
1610

1711
it "should raise a ParseError if there is less than 1 arguments" do
18-
lambda { @scope.function_chomp([]) }.should( raise_error(Puppet::ParseError))
12+
lambda { scope.function_chomp([]) }.should( raise_error(Puppet::ParseError))
1913
end
2014

2115
it "should chomp the end of a string" do
22-
result = @scope.function_chomp(["abc\n"])
16+
result = scope.function_chomp(["abc\n"])
2317
result.should(eq("abc"))
2418
end
25-
2619
end
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
#!/usr/bin/env rspec
1+
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper'
33

44
describe "the chop function" do
5-
before :all do
6-
Puppet::Parser::Functions.autoloader.loadall
7-
end
8-
9-
before :each do
10-
@scope = Puppet::Parser::Scope.new
11-
end
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
126

137
it "should exist" do
148
Puppet::Parser::Functions.function("chop").should == "function_chop"
159
end
1610

1711
it "should raise a ParseError if there is less than 1 arguments" do
18-
lambda { @scope.function_chop([]) }.should( raise_error(Puppet::ParseError))
12+
lambda { scope.function_chop([]) }.should( raise_error(Puppet::ParseError))
1913
end
2014

2115
it "should chop the end of a string" do
22-
result = @scope.function_chop(["asdf\n"])
16+
result = scope.function_chop(["asdf\n"])
2317
result.should(eq("asdf"))
2418
end
25-
2619
end
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
#!/usr/bin/env rspec
1+
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper'
33

44
describe "the delete_at function" do
5-
before :all do
6-
Puppet::Parser::Functions.autoloader.loadall
7-
end
8-
9-
before :each do
10-
@scope = Puppet::Parser::Scope.new
11-
end
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
126

137
it "should exist" do
148
Puppet::Parser::Functions.function("delete_at").should == "function_delete_at"
159
end
1610

1711
it "should raise a ParseError if there is less than 1 arguments" do
18-
lambda { @scope.function_delete_at([]) }.should( raise_error(Puppet::ParseError))
12+
lambda { scope.function_delete_at([]) }.should( raise_error(Puppet::ParseError))
1913
end
2014

2115
it "should delete an item at specified location from an array" do
22-
result = @scope.function_delete_at([['a','b','c'],1])
16+
result = scope.function_delete_at([['a','b','c'],1])
2317
result.should(eq(['a','c']))
2418
end
25-
2619
end
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
#!/usr/bin/env rspec
1+
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper'
33

44
describe "the delete function" do
5-
before :all do
6-
Puppet::Parser::Functions.autoloader.loadall
7-
end
8-
9-
before :each do
10-
@scope = Puppet::Parser::Scope.new
11-
end
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
126

137
it "should exist" do
148
Puppet::Parser::Functions.function("delete").should == "function_delete"
159
end
1610

1711
it "should raise a ParseError if there is less than 1 arguments" do
18-
lambda { @scope.function_delete([]) }.should( raise_error(Puppet::ParseError))
12+
lambda { scope.function_delete([]) }.should( raise_error(Puppet::ParseError))
1913
end
2014

2115
it "should delete an item from an array" do
22-
result = @scope.function_delete([['a','b','c'],'b'])
16+
result = scope.function_delete([['a','b','c'],'b'])
2317
result.should(eq(['a','c']))
2418
end
25-
2619
end
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
1-
#!/usr/bin/env rspec
1+
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper'
33

44
describe "the downcase function" do
5-
before :all do
6-
Puppet::Parser::Functions.autoloader.loadall
7-
end
8-
9-
before :each do
10-
@scope = Puppet::Parser::Scope.new
11-
end
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
126

137
it "should exist" do
148
Puppet::Parser::Functions.function("downcase").should == "function_downcase"
159
end
1610

1711
it "should raise a ParseError if there is less than 1 arguments" do
18-
lambda { @scope.function_downcase([]) }.should( raise_error(Puppet::ParseError))
12+
lambda { scope.function_downcase([]) }.should( raise_error(Puppet::ParseError))
1913
end
2014

2115
it "should downcase a string" do
22-
result = @scope.function_downcase(["ASFD"])
16+
result = scope.function_downcase(["ASFD"])
2317
result.should(eq("asfd"))
2418
end
2519

2620
it "should do nothing to a string that is already downcase" do
27-
result = @scope.function_downcase(["asdf asdf"])
21+
result = scope.function_downcase(["asdf asdf"])
2822
result.should(eq("asdf asdf"))
2923
end
30-
3124
end
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
1-
#!/usr/bin/env rspec
1+
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper'
33

44
describe "the empty function" do
5-
before :all do
6-
Puppet::Parser::Functions.autoloader.loadall
7-
end
8-
9-
before :each do
10-
@scope = Puppet::Parser::Scope.new
11-
end
12-
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
136
it "should exist" do
147
Puppet::Parser::Functions.function("empty").should == "function_empty"
158
end
169

1710
it "should raise a ParseError if there is less than 1 arguments" do
18-
lambda { @scope.function_empty([]) }.should( raise_error(Puppet::ParseError))
11+
lambda { scope.function_empty([]) }.should( raise_error(Puppet::ParseError))
1912
end
2013

2114
it "should return a true for an empty string" do
22-
result = @scope.function_empty([''])
15+
result = scope.function_empty([''])
2316
result.should(eq(true))
2417
end
2518

2619
it "should return a false for a non-empty string" do
27-
result = @scope.function_empty(['asdf'])
20+
result = scope.function_empty(['asdf'])
2821
result.should(eq(false))
2922
end
30-
3123
end
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
1-
#!/usr/bin/env rspec
1+
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper'
33

44
describe "the flatten function" do
5-
before :all do
6-
Puppet::Parser::Functions.autoloader.loadall
7-
end
8-
9-
before :each do
10-
@scope = Puppet::Parser::Scope.new
11-
end
12-
5+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
136
it "should exist" do
147
Puppet::Parser::Functions.function("flatten").should == "function_flatten"
158
end
169

1710
it "should raise a ParseError if there is less than 1 arguments" do
18-
lambda { @scope.function_flatten([]) }.should( raise_error(Puppet::ParseError))
11+
lambda { scope.function_flatten([]) }.should( raise_error(Puppet::ParseError))
1912
end
2013

2114
it "should flatten a complex data structure" do
22-
result = @scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]])
15+
result = scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]])
2316
result.should(eq(["a","b","c","d","e","f","g"]))
2417
end
2518

2619
it "should do nothing to a structure that is already flat" do
27-
result = @scope.function_flatten([["a","b","c","d"]])
20+
result = scope.function_flatten([["a","b","c","d"]])
2821
result.should(eq(["a","b","c","d"]))
2922
end
30-
3123
end

0 commit comments

Comments
 (0)