From 596d005a988e65722f55932b98beecf7c9d3ca50 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Sat, 17 Aug 2013 20:55:00 -0400 Subject: [PATCH] Rework tests for mysql_password to extend coverage. --- spec/unit/mysql_password_spec.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/spec/unit/mysql_password_spec.rb b/spec/unit/mysql_password_spec.rb index e703d61..0736910 100644 --- a/spec/unit/mysql_password_spec.rb +++ b/spec/unit/mysql_password_spec.rb @@ -1,4 +1,3 @@ -#!/usr/bin/env rspec require 'spec_helper' describe 'the mysql_password function' do @@ -6,28 +5,22 @@ describe 'the mysql_password function' do Puppet::Parser::Functions.autoloader.loadall end - before :each do - @scope = if Puppet.version =~ /^3/ - Puppet::Parser::Scope.new_for_test_harness('localhost') - else - Puppet::Parser::Scope.new - end - end + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it 'should exist' do Puppet::Parser::Functions.function('mysql_password').should == 'function_mysql_password' end it 'should raise a ParseError if there is less than 1 arguments' do - lambda { @scope.function_mysql_password([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_mysql_password([]) }.should( raise_error(Puppet::ParseError)) end it 'should raise a ParseError if there is more than 1 arguments' do - lambda { @scope.function_mysql_password(%w(foo bar)) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_mysql_password(%w(foo bar)) }.should( raise_error(Puppet::ParseError)) end it 'should convert password into a hash' do - result = @scope.function_mysql_password(%w(password)) + result = scope.function_mysql_password(%w(password)) result.should(eq('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19')) end