Skip to content

Commit

Permalink
Deprecate PuppetInternals.scope
Browse files Browse the repository at this point in the history
rspec-puppet provides the scope it is using to call the function within the run
matcher as a property. Using that is much preferred over building our own.
  • Loading branch information
DavidS committed Aug 23, 2016
1 parent d14555b commit d2c530f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
26 changes: 2 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,30 +278,8 @@ Pass additional flags to module installation:
Testing Parser Functions
========================

This library provides a consistent way to create a Puppet::Parser::Scope object
suitable for use in a testing harness with the intent of testing the expected
behavior of parser functions distributed in modules.

Previously, modules would do something like this:

describe "split()" do
let(:scope) { Puppet::Parser::Scope.new }
it "should split 'one;two' on ';' into [ 'one', 'two' ]" do
scope.function_split(['one;two', ';']).should == [ 'one', 'two' ]
end
end

This will not work beyond Puppet 2.7 as we have changed the behavior of the
scope initializer in Puppet 3.0. Modules should instead initialize scope
instances in a manner decoupled from the internal behavior of Puppet:

require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals'
describe "split()" do
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
it "should split 'one;two' on ';' into [ 'one', 'two' ]" do
scope.function_split(['one;two', ';']).should == [ 'one', 'two' ]
end
end
This whole section is superseded by improved support of accessing the scope in
rspec-puppet.

Generating code coverage reports
================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ module PuppetInternals
# instance suitable for placing in a test harness with the intent of
# testing parser functions from modules.
def scope(parts = {})
RSpec.deprecate('scope', :replacement => 'rspec-puppet 2.2.0 provides a scope property')

if Puppet.version =~ /^2\.[67]/
# loadall should only be necessary prior to 3.x
# Please note, loadall needs to happen first when creating a scope, otherwise
Expand Down

0 comments on commit d2c530f

Please sign in to comment.