Created
March 29, 2013 19:44
-
-
Save bttf/5273122 to your computer and use it in GitHub Desktop.
Revisions
-
bttf created this gist
Mar 29, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ class File class << self alias_method :original_join, :join end def self.join(*args) new_args = args.collect { |questionableEncoding| join_encoding_fix(questionableEncoding) } self.send(:original_join, new_args) end def self.join_encoding_fix(value) if (value.instance_of?(String)) value = self.convert(value) elsif (value.instance_of?(Array)) value = value.collect { |subValue| join_encoding_fix(subValue) } end value end # # Ruby 1.8.7 requires the iconv library for string encoding # Ruby 1.9.3 uses the default encode method on string. # def self.convert(value) if value.respond_to? :encode value.encode("UTF-8") else require 'iconv' iconv = Iconv.new('ISO-8859-1', 'utf-8') iconv.iconv(value) end end end This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ F Failures: 1) puppetmaster when applied to any old node Failure/Error: }) Puppet::Error: Could not find class puppetmaster for 88nn7w1.mustard.com on node 88nn7w1.mustard.com # ./spec/classes/puppetmaster_spec.rb:9:in `block (3 levels) in <top (required)>' Finished in 0.083 seconds 1 example, 1 failure Failed examples: rspec ./spec/classes/puppetmaster_spec.rb:6 # puppetmaster when applied to any old node C:/ruby193/bin/ruby.exe -S rspec spec/classes/puppetmaster_spec.rb This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ require 'spec_helper' require 'file_join_patch.rb' describe 'puppetmaster', :type => :class do describe 'when applied to any old node' do it { should contain_package('puppetmaster').with({ 'ensure' => 'present', }) should contain_service('puppetmaster').with({ 'ensure' => 'running', }) should contain_file('site_pp').with({ 'ensure' => 'file', 'path' => '/etc/puppet/manifests/site.pp', 'owner' => 'puppet', 'group' => 'puppet', }) should contain_file('puppet_conf').with({ 'ensure' => 'file', 'path' => '/etc/puppet/puppet.conf', 'owner' => 'puppet', 'group' => 'puppet', }) should contain_file('autosign_conf').with({ 'ensure' => 'file', 'path' => '/etc/puppet/autosign.conf', 'owner' => 'puppet', 'group' => 'puppet', }) } end end