puppetlabs/puppetlabs_spec_helper — pull request #17 by jeffmccune (2012-07-18 20:54:05+00:00)
Title: (maint) Add seam for Puppet::Parser::Scope.new

Without this patch there isn't an easy way for dependants to break their
direct dependency on the internal behavior of Puppet::Parser::Scope.new

This is a problem because third party puppet modules are tightly coupled
with the internal method signature of the scope initializer. Tests are
also breaking all over the place right now.

This patch helps fix the problem by providing a clear and consistent
method in the spec helper for all 3rd party modules to use to obtain
instances of parser scopes.

Modules should now do something like this in their tests:

require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_seams'
describe "split()" do
let(:scope) { PuppetlabsSpec::PuppetSeams.new.scope_for_test_harness }
it "should split 'one;two' on ';' into [ 'one', 'two' ]" do
scope.function_split(['one;two', ';']).should == [ 'one', 'two' ]
end
end