diff options
83 files changed, 694 insertions, 314 deletions
diff --git a/lib/puppet/face/certificate.rb b/lib/puppet/face/certificate.rb index ee2b2873f..859946623 100644 --- a/lib/puppet/face/certificate.rb +++ b/lib/puppet/face/certificate.rb @@ -8,7 +8,7 @@ Puppet::Indirector::Face.define(:certificate, '0.0.1') do summary "Provide access to the CA for certificate management" description <<-EOT This face interacts with a local or remote Puppet certificate - authority. Currently, its behavior is not a full superset of puppet + authority. Currently, its behavior is not a full superset of puppet cert; specifically, it is unable to mimic puppet cert's "clean" option, and its "generate" action submits a CSR rather than creating a signed certificate. diff --git a/lib/puppet/face/resource.rb b/lib/puppet/face/resource.rb index ed6360888..87e587624 100644 --- a/lib/puppet/face/resource.rb +++ b/lib/puppet/face/resource.rb @@ -7,7 +7,7 @@ Puppet::Indirector::Face.define(:resource, '0.0.1') do summary "Interact directly with resources via the RAL, like ralsh" description <<-EOT This face provides a Ruby API with functionality similar to the puppet - resource (née ralsh) command line application. It is not intended to be + resource (originally ralsh) command line application. It is not intended to be used from the command line. EOT notes <<-EOT diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb index 7267ac7f3..86ede5994 100644 --- a/lib/puppet/indirector.rb +++ b/lib/puppet/indirector.rb @@ -18,7 +18,7 @@ module Puppet::Indirector terminus_name = termini["terminus"] cache_name = termini["cache"] - Puppet::Indirector::Terminus.terminus_classes(indirection_name) + Puppet::Indirector::Terminus.terminus_class(indirection_name, terminus_name || cache_name) indirection = Puppet::Indirector::Indirection.instance(indirection_name) raise "Indirection #{indirection_name} does not exist" unless indirection diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 622371a4e..3c377a49f 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -192,7 +192,7 @@ class Puppet::Interface::Action # but will on 1.9.2, which treats it as "no arguments". Which bites, # because this just begs for us to wind up in the horrible situation # where a 1.8 vs 1.9 error bites our end users. --daniel 2011-04-19 - raise ArgumentError, "action when_invoked requires at least one argument (options)" + raise ArgumentError, "when_invoked requires at least one argument (options) for action #{@name}" elsif arity > 0 then range = Range.new(1, arity - 1) decl = range.map { |x| "arg#{x}" } << "options = {}" diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb index 62db8de06..4948f5fab 100644 --- a/lib/puppet/interface/action_builder.rb +++ b/lib/puppet/interface/action_builder.rb @@ -49,9 +49,9 @@ class Puppet::Interface::ActionBuilder # Metaprogram the simple DSL from the target class. Puppet::Interface::Action.instance_methods.grep(/=$/).each do |setter| next if setter =~ /^=/ - property = setter.sub(/=$/, '') + property = setter.to_s.chomp('=') - unless public_instance_methods.include? property + unless method_defined? property # Using eval because the argument handling semantics are less awful than # when we use the define_method/block version. The later warns on older # Ruby versions if you pass the wrong number of arguments, but carries diff --git a/lib/puppet/interface/option_builder.rb b/lib/puppet/interface/option_builder.rb index 8f358c222..5676ec977 100644 --- a/lib/puppet/interface/option_builder.rb +++ b/lib/puppet/interface/option_builder.rb @@ -18,9 +18,9 @@ class Puppet::Interface::OptionBuilder # Metaprogram the simple DSL from the option class. Puppet::Interface::Option.instance_methods.grep(/=$/).each do |setter| next if setter =~ /^=/ - dsl = setter.sub(/=$/, '') + dsl = setter.to_s.chomp('=') - unless private_instance_methods.include? dsl + unless private_method_defined? dsl define_method(dsl) do |value| @option.send(setter, value) end end end diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb index cd88b9d84..c56b21393 100644 --- a/lib/puppet/network/client.rb +++ b/lib/puppet/network/client.rb @@ -23,7 +23,7 @@ class Net::HTTP # JJM: This is a "backport" of sorts to older ruby versions which # do not have this accessor. See #896 for more information. - attr_accessor :enable_post_connection_check unless Net::HTTP.instance_methods.include? "enable_post_connection_check" + attr_accessor :enable_post_connection_check unless Net::HTTP.method_defined? "enable_post_connection_check" end # The base class for all of the clients. Many clients just directly diff --git a/lib/puppet/network/format.rb b/lib/puppet/network/format.rb index 9cd6cf0b5..69895c344 100644 --- a/lib/puppet/network/format.rb +++ b/lib/puppet/network/format.rb @@ -106,6 +106,6 @@ class Puppet::Network::Format method = send(name) - return(type == :class ? klass.respond_to?(method) : klass.instance_methods.include?(method)) + return(type == :class ? klass.respond_to?(method) : klass.method_defined?(method)) end end diff --git a/lib/puppet/provider/mount/parsed.rb b/lib/puppet/provider/mount/parsed.rb index 7c3f41bbd..8d48dad57 100755 --- a/lib/puppet/provider/mount/parsed.rb +++ b/lib/puppet/provider/mount/parsed.rb @@ -47,6 +47,24 @@ Puppet::Type.type(:mount).provide( end end + def self.instances + providers = super + mounts = mountinstances.dup + + # Update fstab entries that are mounted + providers.each do |prov| + if mounts.delete({:name => prov.get(:name), :mounted => :yes}) then + prov.set(:ensure => :mounted) + end + end + + # Add mounts that are not in fstab but mounted + mounts.each do |mount| + providers << new(:ensure => :ghost, :name => mount[:name]) + end + providers + end + def self.prefetch(resources = nil) # Get providers for all resources the user defined and that match # a record in /etc/fstab. diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb index 6a3855c0e..81b1fbcfa 100644 --- a/lib/puppet/provider/ssh_authorized_key/parsed.rb +++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb @@ -42,12 +42,6 @@ require 'puppet/provider/parsedfile' 0600 end - def target - @resource.should(:target) || File.expand_path("~#{@resource.should(:user)}/.ssh/authorized_keys") - rescue - raise Puppet::Error, "Target not defined and/or specified user does not exist yet" - end - def user uid = File.stat(target).uid Etc.getpwuid(uid).name diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb index 214516908..59e387d00 100644 --- a/lib/puppet/resource.rb +++ b/lib/puppet/resource.rb @@ -269,7 +269,7 @@ class Puppet::Resource else " %-#{attr_max}s => %s,\n" % [ k, "\'#{v}\'" ] end - } + }.join "%s { '%s':\n%s}" % [self.type.to_s.downcase, self.title, attributes] end diff --git a/lib/puppet/type/ssh_authorized_key.rb b/lib/puppet/type/ssh_authorized_key.rb index 8338e2d64..170dc8383 100644 --- a/lib/puppet/type/ssh_authorized_key.rb +++ b/lib/puppet/type/ssh_authorized_key.rb @@ -14,6 +14,10 @@ module Puppet system-wide primary key and therefore has to be unique." isnamevar + + validate do |value| + raise Puppet::Error, "Resourcename must not contain whitespace: #{value}" if value =~ /\s/ + end end newproperty(:type) do @@ -28,6 +32,10 @@ module Puppet newproperty(:key) do desc "The key itself; generally a long string of hex digits." + + validate do |value| + raise Puppet::Error, "Key must not contain whitespace: #{value}" if value =~ /\s/ + end end newproperty(:user) do @@ -82,6 +90,10 @@ module Puppet value.join(",") end end + + validate do |value| + raise Puppet::Error, "Options must be provided as an array, not a comma separated list" if value != :absent and value.include?(',') + end end autorequire(:user) do diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index d06f44808..ce9d4642b 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -1,5 +1,6 @@ # A module to collect utility functions. +require 'English' require 'puppet/util/monkey_patches' require 'sync' require 'puppet/external/lock' diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index cec8a57d9..255388d58 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -140,7 +140,7 @@ module Puppet::Util::SELinux def read_mounts mounts = "" begin - if File.instance_methods.include? "read_nonblock" + if File.method_defined? "read_nonblock" # If possible we use read_nonblock in a loop rather than read to work- # a linux kernel bug. See ticket #1963 for details. mountfh = File.open("/proc/mounts") diff --git a/spec/integration/application/doc_spec.rb b/spec/integration/application/doc_spec.rb index c1e463033..9412976f0 100755 --- a/spec/integration/application/doc_spec.rb +++ b/spec/integration/application/doc_spec.rb @@ -5,7 +5,7 @@ require 'puppet_spec/files' describe Puppet::Application::Doc do include PuppetSpec::Files - it "should not generate an error when module dir overlaps parent of site.pp (#4798)" do + it "should not generate an error when module dir overlaps parent of site.pp (#4798)", :'fails_on_ruby_1.9.2' => true do begin # Note: the directory structure below is more complex than it # needs to be, but it's representative of the directory structure diff --git a/spec/integration/network/formats_spec.rb b/spec/integration/network/formats_spec.rb index af505f267..214b2d78f 100755 --- a/spec/integration/network/formats_spec.rb +++ b/spec/integration/network/formats_spec.rb @@ -44,7 +44,7 @@ describe Puppet::Network::FormatHandler.format(:s) do end end -describe Puppet::Network::FormatHandler.format(:pson) do +describe Puppet::Network::FormatHandler.format(:pson), :'fails_on_ruby_1.9.2' => true do describe "when pson is absent", :if => (! Puppet.features.pson?) do before do diff --git a/spec/integration/network/server/mongrel_spec.rb b/spec/integration/network/server/mongrel_spec.rb index fd5903b9e..1ce59eb49 100755 --- a/spec/integration/network/server/mongrel_spec.rb +++ b/spec/integration/network/server/mongrel_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'puppet/network/server' require 'socket' -describe Puppet::Network::Server do +describe Puppet::Network::Server, :'fails_on_ruby_1.9.2' => true do describe "when using mongrel", :if => Puppet.features.mongrel? do before :each do diff --git a/spec/integration/node_spec.rb b/spec/integration/node_spec.rb index e15ddfc1e..4ea6142e2 100755 --- a/spec/integration/node_spec.rb +++ b/spec/integration/node_spec.rb @@ -43,7 +43,7 @@ describe Puppet::Node do Puppet::Node.indirection.terminus(:ldap).should_not be_nil end - it "should be able to use the plain terminus" do + it "should be able to use the plain terminus", :'fails_on_ruby_1.9.2' => true do Puppet::Node.indirection.stubs(:terminus_class).returns :plain # Load now, before we stub the exists? method. diff --git a/spec/integration/provider/package_spec.rb b/spec/integration/provider/package_spec.rb index 2d75826e8..5fecdf13c 100755 --- a/spec/integration/provider/package_spec.rb +++ b/spec/integration/provider/package_spec.rb @@ -1,7 +1,7 @@ #!/usr/bin/env rspec require 'spec_helper' -describe "Package Provider" do +describe "Package Provider", :'fails_on_ruby_1.9.2' => true do Puppet::Type.type(:package).providers.each do |name| provider = Puppet::Type.type(:package).provider(name) diff --git a/spec/integration/provider/service/init_spec.rb b/spec/integration/provider/service/init_spec.rb index ef7d98b4c..c209475bf 100755 --- a/spec/integration/provider/service/init_spec.rb +++ b/spec/integration/provider/service/init_spec.rb @@ -3,14 +3,14 @@ require 'spec_helper' provider = Puppet::Type.type(:service).provider(:init) -describe provider do +describe provider, :'fails_on_ruby_1.9.2' => true do describe "when running on FreeBSD", :if => (Facter.value(:operatingsystem) == "FreeBSD") do it "should set its default path to include /etc/init.d and /usr/local/etc/init.d" do provider.defpath.should == ["/etc/rc.d", "/usr/local/etc/rc.d"] end end - describe "when running on HP-UX", :if => (Facter.value(:operatingsystem) == "HP-UX")do + describe "when running on HP-UX", :if => (Facter.value(:operatingsystem) == "HP-UX") do it "should set its default path to include /sbin/init.d" do provider.defpath.should == "/sbin/init.d" end diff --git a/spec/integration/provider/ssh_authorized_key_spec.rb b/spec/integration/provider/ssh_authorized_key_spec.rb new file mode 100644 index 000000000..902f9ad22 --- /dev/null +++ b/spec/integration/provider/ssh_authorized_key_spec.rb @@ -0,0 +1,207 @@ +#!/usr/bin/env ruby + +require 'spec_helper' +require 'puppet/file_bucket/dipper' + +describe "ssh_authorized_key provider (integration)" do + include PuppetSpec::Files + + before :each do + @fake_userfile = tmpfile('authorized_keys.user') + @fake_rootfile = tmpfile('authorized_keys.root') + + # few testkeys generated with ssh-keygen + @sample_rsa_keys = [ + 'AAAAB3NzaC1yc2EAAAADAQABAAAAgQCi18JBZOq10X3w4f67nVhO0O3s5Y1vHH4UgMSM3ZnQwbC5hjGyYSi9UULOoQQoQynI/a0I9NL423/Xk/XJVIKCHcS8q6V2Wmjd+fLNelOjxxoW6mbIytEt9rDvwgq3Mof3/m21L3t2byvegR00a+ikKbmInPmKwjeWZpexCIsHzQ==', # 1024 bit + 'AAAAB3NzaC1yc2EAAAADAQABAAAAgQDLClyvi3CsJw5Id6khZs2/+s11qOH4Gdp6iDioDsrIp0m8kSiPr71VGyQYAfPzzvHemHS7Xg0NkG1Kc8u9tRqBQfTvz7ubq0AT/g01+4P2hQ/soFkuwlUG/HVnnaYb6N0Qp5SHWvD5vBE2nFFQVpP5GrSctPtHSjzJq/i+6LYhmQ==', # 1024 bit + 'AAAAB3NzaC1yc2EAAAADAQABAAABAQDLygAO6txXkh9FNV8xSsBkATeqLbHzS7sFjGI3gt0Dx6q3LjyKwbhQ1RLf28kd5G6VWiXmClU/RtiPdUz8nrGuun++2mrxzrXrvpR9dq1lygLQ2wn2cI35dN5bjRMtXy3decs6HUhFo9MoNwX250rUWfdCyNPhGIp6OOfmjdy+UeLGNxq9wDx6i4bT5tVVSqVRtsEfw9+ICXchzl85QudjneVVpP+thriPZXfXA5eaGwAo/dmoKOIhUwF96gpdLqzNtrGQuxPbV80PTbGv9ZtAtTictxaDz8muXO7he9pXmchUpxUKtMFjHkL0FAZ9tRPmv3RA30sEr2fZ8+LKvnE50w0' #2048 Bit + ] + @sample_dsa_keys = [ + 'AAAAB3NzaC1kc3MAAACBAOPck2O8MIDSqxPSnvENt6tzRrKJ5oOhB6Nc6oEcWm+VEH1gvuxdiRqwoMgRwyEf1yUd+UAcLw3a6Jn+EtFyEBN/5WF+4Tt4xTxZ0Pfik2Wc5uqHbQ2dkmOoXiAOYPiD3JUQ1Xwm/J0CgetjitoLfzAGdCNhMqguqAuHcVJ78ZZbAAAAFQCIBKFYZ+I18I+dtgteirXh+VVEEwAAAIEAs1yvQ/wnLLrRCM660pF4kBiw3D6dJfMdCXWQpn0hZmkBQSIzZv4Wuk3giei5luxscDxNc+y3CTXtnyG4Kt1Yi2sOdvhRI3rX8tD+ejn8GHazM05l5VIo9uu4AQPIE32iV63IqgApSBbJ6vDJW91oDH0J492WdLCar4BS/KE3cRwAAACBAN0uSDyJqYLRsfYcFn4HyVf6TJxQm1IcwEt6GcJVzgjri9VtW7FqY5iBqa9B9Zdh5XXAYJ0XLsWQCcrmMHM2XGHGpA4gL9VlCJ/0QvOcXxD2uK7IXwAVUA7g4V4bw8EVnFv2Flufozhsp+4soo1xiYc5jiFVHwVlk21sMhAtKAeF' # 1024 Bit + ] + + @sample_lines = [ + "ssh-rsa #{@sample_rsa_keys[1]} root@someotherhost", + "ssh-dss #{@sample_dsa_keys[0]} root@anywhere", + "ssh-rsa #{@sample_rsa_keys[2]} paul" + ] + + end + + after :each do + Puppet::Type::Ssh_authorized_key::ProviderParsed.clear # Work around bug #6628 + end + + def create_fake_key(username, content) + filename = (username == :root ? @fake_rootfile : @fake_userfile ) + File.open(filename, 'w') do |f| + content.each do |line| + f.puts line + end + end + end + + def check_fake_key(username, expected_content) + filename = (username == :root ? @fake_rootfile : @fake_userfile ) + content = File.readlines(filename).map(&:chomp).sort.reject{ |x| x =~ /^#|^$/ } + content.join("\n").should == expected_content.sort.join("\n") + end + + def run_in_catalog(*resources) + Puppet::FileBucket::Dipper.any_instance.stubs(:backup) # Don't backup to the filebucket + catalog = Puppet::Resource::Catalog.new + catalog.host_config = false + resources.each do |resource| + resource.expects(:err).never + catalog.add_resource(resource) + end + catalog.apply + end + + describe "when managing one resource" do + + before :each do + # We are not running as root so chown/chmod is not possible + File.stubs(:chown) + File.stubs(:chmod) + Puppet::Util::SUIDManager.stubs(:asuser).yields + end + + describe "with ensure set to absent" do + + before :each do + @example = Puppet::Type.type(:ssh_authorized_key).new( + :name => 'root@hostname', + :type => :rsa, + :key => @sample_rsa_keys[0], + :target => @fake_rootfile, + :user => 'root', + :ensure => :absent + ) + end + + it "should not modify root's keyfile if resource is currently not present" do + create_fake_key(:root, @sample_lines) + run_in_catalog(@example) + check_fake_key(:root, @sample_lines) + end + + it "remove the key from root's keyfile if resource is currently present" do + create_fake_key(:root, @sample_lines + ["ssh-rsa #{@sample_rsa_keys[0]} root@hostname"]) + run_in_catalog(@example) + check_fake_key(:root, @sample_lines) + end + + end + + describe "when ensure is present" do + + before :each do + @example = Puppet::Type.type(:ssh_authorized_key).new( + :name => 'root@hostname', + :type => :rsa, + :key => @sample_rsa_keys[0], + :target => @fake_rootfile, + :user => 'root', + :ensure => :present + ) + + # just a dummy so the parsedfile provider is aware + # of the user's authorized_keys file + @dummy = Puppet::Type.type(:ssh_authorized_key).new( + :name => 'dummy', + :target => @fake_userfile, + :user => 'nobody', + :ensure => :absent + ) + end + + it "should add the key if it is not present" do + create_fake_key(:root, @sample_lines) + run_in_catalog(@example) + check_fake_key(:root, @sample_lines + ["ssh-rsa #{@sample_rsa_keys[0]} root@hostname" ]) + end + + it "should modify the type if type is out of sync" do + create_fake_key(:root,@sample_lines + [ "ssh-dss #{@sample_rsa_keys[0]} root@hostname" ]) + run_in_catalog(@example) + check_fake_key(:root, @sample_lines + [ "ssh-rsa #{@sample_rsa_keys[0]} root@hostname" ]) + end + + it "should modify the key if key is out of sync" do + create_fake_key(:root,@sample_lines + [ "ssh-rsa #{@sample_rsa_keys[1]} root@hostname" ]) + run_in_catalog(@example) + check_fake_key(:root, @sample_lines + [ "ssh-rsa #{@sample_rsa_keys[0]} root@hostname" ]) + end + + it "should remove the key from old file if target is out of sync" do + create_fake_key(:user, [ @sample_lines[0], "ssh-rsa #{@sample_rsa_keys[0]} root@hostname" ]) + create_fake_key(:root, [ @sample_lines[1], @sample_lines[2] ]) + run_in_catalog(@example, @dummy) + check_fake_key(:user, [ @sample_lines[0] ]) + #check_fake_key(:root, [ @sample_lines[1], @sample_lines[2], "ssh-rsa #{@sample_rsa_keys[0]} root@hostname" ]) + end + + it "should add the key to new file if target is out of sync" do + create_fake_key(:user, [ @sample_lines[0], "ssh-rsa #{@sample_rsa_keys[0]} root@hostname" ]) + create_fake_key(:root, [ @sample_lines[1], @sample_lines[2] ]) + run_in_catalog(@example, @dummy) + #check_fake_key(:user, [ @sample_lines[0] ]) + check_fake_key(:root, [ @sample_lines[1], @sample_lines[2], "ssh-rsa #{@sample_rsa_keys[0]} root@hostname" ]) + end + + it "should modify options if options are out of sync" do + @example[:options]=[ 'from="correct.domain.com"', 'no-port-forwarding', 'no-pty' ] + create_fake_key(:root, @sample_lines + [ "from=\"incorrect.domain.com\",no-port-forwarding,no-pty ssh-rsa #{@sample_rsa_keys[0]} root@hostname"]) + run_in_catalog(@example) + check_fake_key(:root, @sample_lines + [ "from=\"correct.domain.com\",no-port-forwarding,no-pty ssh-rsa #{@sample_rsa_keys[0]} root@hostname"] ) + end + + end + + end + + describe "when managing two resource" do + + before :each do + # We are not running as root so chown/chmod is not possible + File.stubs(:chown) + File.stubs(:chmod) + Puppet::Util::SUIDManager.stubs(:asuser).yields + @example_one = Puppet::Type.type(:ssh_authorized_key).new( + :name => 'root@hostname', + :type => :rsa, + :key => @sample_rsa_keys[0], + :target => @fake_rootfile, + :user => 'root', + :ensure => :present + ) + + @example_two = Puppet::Type.type(:ssh_authorized_key).new( + :name => 'user@hostname', + :key => @sample_rsa_keys[1], + :type => :rsa, + :target => @fake_userfile, + :user => 'nobody', + :ensure => :present + ) + end + + describe "and both keys are absent" do + + before :each do + create_fake_key(:root, @sample_lines) + create_fake_key(:user, @sample_lines) + end + + it "should add both keys" do + run_in_catalog(@example_one, @example_two) + check_fake_key(:root, @sample_lines + [ "ssh-rsa #{@sample_rsa_keys[0]} root@hostname" ]) + check_fake_key(:user, @sample_lines + [ "ssh-rsa #{@sample_rsa_keys[1]} user@hostname" ]) + end + + end + + end + +end diff --git a/spec/integration/transaction_spec.rb b/spec/integration/transaction_spec.rb index 0ff50f47c..00e9dbb8e 100755 --- a/spec/integration/transaction_spec.rb +++ b/spec/integration/transaction_spec.rb @@ -220,7 +220,7 @@ describe Puppet::Transaction do FileTest.should be_exists(newfile) end - it "should still trigger skipped resources" do + it "should still trigger skipped resources", :'fails_on_ruby_1.9.2' => true do catalog = mk_catalog catalog.add_resource(*Puppet::Type.type(:schedule).mkdefaultschedules) diff --git a/spec/integration/util/file_locking_spec.rb b/spec/integration/util/file_locking_spec.rb index 9e829df0e..3b6964e8b 100755 --- a/spec/integration/util/file_locking_spec.rb +++ b/spec/integration/util/file_locking_spec.rb @@ -13,7 +13,7 @@ describe Puppet::Util::FileLocking do File.open(@file, "w") { |f| f.puts YAML.dump(@data) } end - it "should be able to keep file corruption from happening when there are multiple writers threads" do + it "should be able to keep file corruption from happening when there are multiple writers threads", :'fails_in_ruby_1.9.2' => true do threads = [] sync = Sync.new 9.times { |a| diff --git a/spec/integration/util/rdoc/parser_spec.rb b/spec/integration/util/rdoc/parser_spec.rb index ce316309b..bf1f0d268 100755 --- a/spec/integration/util/rdoc/parser_spec.rb +++ b/spec/integration/util/rdoc/parser_spec.rb @@ -8,7 +8,7 @@ require 'puppet/util/rdoc/code_objects' require 'rdoc/options' require 'rdoc/rdoc' -describe RDoc::Parser do +describe RDoc::Parser, :'fails_on_ruby_1.9.2' => true do require 'puppet_spec/files' include PuppetSpec::Files diff --git a/spec/lib/puppet/face/huzzah.rb b/spec/lib/puppet/face/huzzah.rb index 6593d358a..ab465d9e0 100755 --- a/spec/lib/puppet/face/huzzah.rb +++ b/spec/lib/puppet/face/huzzah.rb @@ -3,5 +3,5 @@ Puppet::Face.define(:huzzah, '2.0.1') do copyright "Puppet Labs", 2011 license "Apache 2 license; see COPYING" summary "life is a thing for celebration" - script :bar do "is where beer comes from" end + script :bar do |options| "is where beer comes from" end end diff --git a/spec/lib/puppet/face/version_matching.rb b/spec/lib/puppet/face/version_matching.rb index 52bc71dbd..bfdf5e36e 100644 --- a/spec/lib/puppet/face/version_matching.rb +++ b/spec/lib/puppet/face/version_matching.rb @@ -7,6 +7,6 @@ require 'puppet/face' copyright "Puppet Labs", 2011 license "Apache 2 license; see COPYING" summary "version matching face #{version}" - script :version do version end + script :version do |options| version end end end diff --git a/spec/unit/application/cert_spec.rb b/spec/unit/application/cert_spec.rb index 1b1c61ab4..7510f0783 100755 --- a/spec/unit/application/cert_spec.rb +++ b/spec/unit/application/cert_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'puppet/application/cert' -describe Puppet::Application::Cert do +describe Puppet::Application::Cert, :'fails_on_ruby_1.9.2' => true do before :each do @cert_app = Puppet::Application[:cert] Puppet::Util::Log.stubs(:newdestination) diff --git a/spec/unit/application/face_base_spec.rb b/spec/unit/application/face_base_spec.rb index 2a9a22356..3318e061e 100755 --- a/spec/unit/application/face_base_spec.rb +++ b/spec/unit/application/face_base_spec.rb @@ -148,7 +148,7 @@ describe Puppet::Application::FaceBase do end end - it "should handle application-level options" do + it "should handle application-level options", :'fails_on_ruby_1.9.2' => true do app.command_line.stubs(:args).returns %w{basetest --verbose return_true} app.preinit app.parse_options diff --git a/spec/unit/application/facts_spec.rb b/spec/unit/application/facts_spec.rb index 2981dc805..e11ea165c 100755 --- a/spec/unit/application/facts_spec.rb +++ b/spec/unit/application/facts_spec.rb @@ -15,7 +15,7 @@ describe Puppet::Application::Facts do @logs.first.to_s.should =~ /puppet facts find takes 1 argument, but you gave 0/ end - it "should return facts if a key is given to find" do + it "should return facts if a key is given to find", :'fails_on_ruby_1.9.2' => true do subject.command_line.stubs(:args).returns %w{find whatever --render-as yaml} expect { diff --git a/spec/unit/application/resource_spec.rb b/spec/unit/application/resource_spec.rb index 9ee6dd71b..a6564cae5 100755 --- a/spec/unit/application/resource_spec.rb +++ b/spec/unit/application/resource_spec.rb @@ -35,13 +35,13 @@ describe Puppet::Application::Resource do end describe "in preinit" do - it "should set hosts to nil" do + it "should set hosts to nil", :'fails_on_ruby_1.9.2' => true do @resource.preinit @resource.host.should be_nil end - it "should init extra_params to empty array" do + it "should init extra_params to empty array", :'fails_on_ruby_1.9.2' => true do @resource.preinit @resource.extra_params.should == [] diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index fc1bbceb6..aed80e3e6 100755 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -26,7 +26,7 @@ describe Puppet::Application do @klass.find("Agent").should == @klass::Agent end - it "should not find classes outside the namespace" do + it "should not find classes outside the namespace", :'fails_on_ruby_1.9.2' => true do expect { @klass.find("String") }.to exit_with 1 end @@ -222,7 +222,7 @@ describe Puppet::Application do end describe 'on POSIX systems', :if => Puppet.features.posix? do - it 'should signal process with HUP after block if restart requested during block execution' do + it 'should signal process with HUP after block if restart requested during block execution', :'fails_on_ruby_1.9.2' => true do Puppet::Application.run_status = nil target = mock 'target' target.expects(:some_method).once diff --git a/spec/unit/indirector/face_spec.rb b/spec/unit/indirector/face_spec.rb index 1530f7270..943ff7991 100755 --- a/spec/unit/indirector/face_spec.rb +++ b/spec/unit/indirector/face_spec.rb @@ -16,8 +16,17 @@ describe Puppet::Indirector::Face do Puppet::Indirector::Face.indirections.should be_include("catalog") end - it "should be able to return a list of terminuses for a given indirection" do - Puppet::Indirector::Face.terminus_classes(:catalog).should be_include("compiler") + it "should return the sorted to_s list of terminus classes" do + Puppet::Indirector::Terminus.expects(:terminus_classes).returns([ + :yaml, + :compiler, + :rest + ]) + Puppet::Indirector::Face.terminus_classes(:catalog).should == [ + 'compiler', + 'rest', + 'yaml' + ] end describe "as an instance" do diff --git a/spec/unit/indirector/facts/couch_spec.rb b/spec/unit/indirector/facts/couch_spec.rb index d0862486c..b6477bafe 100755 --- a/spec/unit/indirector/facts/couch_spec.rb +++ b/spec/unit/indirector/facts/couch_spec.rb @@ -6,12 +6,12 @@ require 'puppet/indirector/facts/couch' describe "Puppet::Node::Facts::Couch" do describe "when couchdb is not available", :unless => Puppet.features.couchdb? do - it "should fail to initialize" do + it "should fail to initialize", :'fails_in_ruby_1.9.2' => true do lambda { Puppet::Node::Facts::Couch.new }.should raise_error end end - describe "when couchdb is available", :if => Puppet.features.couchdb? do + describe "when couchdb is available", :if => Puppet.features.couchdb?, :'fails_on_ruby_1.9.2' => true do before do @mock_db = mock('couch db') mock_document = CouchRest::Document.new(:_id => fake_request.key, :facts => fake_request.values) diff --git a/spec/unit/indirector/ldap_spec.rb b/spec/unit/indirector/ldap_spec.rb index 2b40325de..d4c9ddcff 100755 --- a/spec/unit/indirector/ldap_spec.rb +++ b/spec/unit/indirector/ldap_spec.rb @@ -108,7 +108,7 @@ describe Puppet::Indirector::Ldap do end end - describe "when connecting to ldap", :if => Puppet.features.ldap? do + describe "when connecting to ldap", :if => Puppet.features.ldap?, :'fails_on_ruby_1.9.2' => true do it "should create and start a Util::Ldap::Connection instance" do conn = mock 'connection', :connection => "myconn", :start => nil Puppet::Util::Ldap::Connection.expects(:instance).returns conn diff --git a/spec/unit/indirector/report/yaml_spec.rb b/spec/unit/indirector/report/yaml_spec.rb index 7df4bb2e9..557795f21 100755 --- a/spec/unit/indirector/report/yaml_spec.rb +++ b/spec/unit/indirector/report/yaml_spec.rb @@ -22,7 +22,7 @@ describe Puppet::Transaction::Report::Yaml do Puppet::Transaction::Report::Yaml.name.should == :yaml end - it "should inconditionnally save/load from the --lastrunreport setting" do + it "should inconditionnally save/load from the --lastrunreport setting", :'fails_on_ruby_1.9.2' => true do indirection = stub 'indirection', :name => :my_yaml, :register_terminus_type => nil Puppet::Indirector::Indirection.stubs(:instance).with(:my_yaml).returns(indirection) store_class = Class.new(Puppet::Transaction::Report::Yaml) do diff --git a/spec/unit/indirector/resource/ral_spec.rb b/spec/unit/indirector/resource/ral_spec.rb index 61290f7a7..cf746cb0c 100755 --- a/spec/unit/indirector/resource/ral_spec.rb +++ b/spec/unit/indirector/resource/ral_spec.rb @@ -18,7 +18,7 @@ describe "Puppet::Resource::Ral" do Puppet::Resource::Ral.new.find(@request).should == my_resource end - it "if there is no instance, it should create one" do + it "if there is no instance, it should create one", :'fails_on_ruby_1.9.2' => true do wrong_instance = stub "wrong user", :name => "bob" require 'puppet/type/user' diff --git a/spec/unit/indirector/terminus_spec.rb b/spec/unit/indirector/terminus_spec.rb index 41770e1e3..33932cfca 100755 --- a/spec/unit/indirector/terminus_spec.rb +++ b/spec/unit/indirector/terminus_spec.rb @@ -4,7 +4,7 @@ require 'puppet/defaults' require 'puppet/indirector' require 'puppet/indirector/file' -describe Puppet::Indirector::Terminus do +describe Puppet::Indirector::Terminus, :'fails_on_ruby_1.9.2' => true do before :each do Puppet::Indirector::Terminus.stubs(:register_terminus_class) @indirection = stub 'indirection', :name => :my_stuff, :register_terminus_type => nil @@ -135,7 +135,7 @@ describe Puppet::Indirector::Terminus, " when managing terminus classes" do Puppet::Indirector::Terminus.terminus_class(:test1, :yay) end - it "should fail when no indirection can be found" do + it "should fail when no indirection can be found", :'fails_on_ruby_1.9.2' => true do Puppet::Indirector::Indirection.expects(:instance).with(:my_indirection).returns(nil) @abstract_terminus = Class.new(Puppet::Indirector::Terminus) do @@ -152,7 +152,7 @@ describe Puppet::Indirector::Terminus, " when managing terminus classes" do }.should raise_error(ArgumentError) end - it "should register the terminus class with the terminus base class" do + it "should register the terminus class with the terminus base class", :'fails_on_ruby_1.9.2' => true do Puppet::Indirector::Terminus.expects(:register_terminus_class).with do |type| type.indirection_name == :my_indirection and type.name == :test_terminus end @@ -219,7 +219,7 @@ describe Puppet::Indirector::Terminus, " when parsing class constants for indire end end -describe Puppet::Indirector::Terminus, " when creating terminus class types" do +describe Puppet::Indirector::Terminus, " when creating terminus class types", :'fails_on_ruby_1.9.2' => true do before do Puppet::Indirector::Terminus.stubs(:register_terminus_class) @subclass = Class.new(Puppet::Indirector::Terminus) do diff --git a/spec/unit/interface/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb index c39860591..602daaaca 100755 --- a/spec/unit/interface/action_builder_spec.rb +++ b/spec/unit/interface/action_builder_spec.rb @@ -8,7 +8,7 @@ describe Puppet::Interface::ActionBuilder do it "should build an action" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end end action.should be_a(Puppet::Interface::Action) action.name.should == :foo @@ -16,7 +16,7 @@ describe Puppet::Interface::ActionBuilder do it "should define a method on the face which invokes the action" do face = Puppet::Interface.new(:action_builder_test_interface, '0.0.1') do - action(:foo) { when_invoked { "invoked the method" } } + action(:foo) { when_invoked { |options| "invoked the method" } } end face.foo.should == "invoked the method" @@ -37,7 +37,7 @@ describe Puppet::Interface::ActionBuilder do it "should have a #option DSL function" do method = nil Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end method = self.method(:option) end method.should be_an_instance_of Method @@ -45,7 +45,7 @@ describe Puppet::Interface::ActionBuilder do it "should define an option without a block" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end option "--bar" end action.should be_option :bar @@ -53,7 +53,7 @@ describe Puppet::Interface::ActionBuilder do it "should accept an empty block" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end option "--bar" do # This space left deliberately blank. end @@ -65,7 +65,7 @@ describe Puppet::Interface::ActionBuilder do context "inline documentation" do it "should set the summary" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end summary "this is some text" end action.summary.should == "this is some text" @@ -75,7 +75,7 @@ describe Puppet::Interface::ActionBuilder do context "action defaulting" do it "should set the default to true" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end default end action.default.should be_true @@ -83,7 +83,7 @@ describe Puppet::Interface::ActionBuilder do it "should not be default by, er, default. *cough*" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end end action.default.should be_false end @@ -93,7 +93,7 @@ describe Puppet::Interface::ActionBuilder do it "should fail if no rendering format is given" do expect { Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end when_rendering do true end end }.to raise_error ArgumentError, /must give a rendering format to when_rendering/ @@ -102,7 +102,7 @@ describe Puppet::Interface::ActionBuilder do it "should fail if no block is given" do expect { Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end when_rendering :json end }.to raise_error ArgumentError, /must give a block to when_rendering/ @@ -111,7 +111,7 @@ describe Puppet::Interface::ActionBuilder do it "should fail if the block takes no arguments" do expect { Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end when_rendering :json do true end end }.to raise_error ArgumentError, /when_rendering methods take one argument, the result, not/ @@ -120,7 +120,7 @@ describe Puppet::Interface::ActionBuilder do it "should fail if the block takes more than one argument" do expect { Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end when_rendering :json do |a, b, c| true end end }.to raise_error ArgumentError, /when_rendering methods take one argument, the result, not/ @@ -129,7 +129,7 @@ describe Puppet::Interface::ActionBuilder do it "should fail if the block takes a variable number of arguments" do expect { Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end when_rendering :json do |*args| true end end }.to raise_error(ArgumentError, @@ -138,7 +138,7 @@ describe Puppet::Interface::ActionBuilder do it "should stash a rendering block" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end when_rendering :json do |a| true end end action.when_rendering(:json).should be_an_instance_of Method @@ -147,7 +147,7 @@ describe Puppet::Interface::ActionBuilder do it "should fail if you try to set the same rendering twice" do expect { Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end when_rendering :json do |a| true end when_rendering :json do |a| true end end @@ -156,7 +156,7 @@ describe Puppet::Interface::ActionBuilder do it "should work if you set two different renderings" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end when_rendering :json do |a| true end when_rendering :yaml do |a| true end end @@ -166,7 +166,7 @@ describe Puppet::Interface::ActionBuilder do it "should be bound to the face when called" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end when_rendering :json do |a| self end end action.when_rendering(:json).call(true).should == face @@ -176,7 +176,7 @@ describe Puppet::Interface::ActionBuilder do context "#render_as" do it "should default to nil (eg: based on context)" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end end action.render_as.should be_nil end @@ -184,7 +184,7 @@ describe Puppet::Interface::ActionBuilder do it "should fail if not rendering format is given" do expect { Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end render_as end }.to raise_error ArgumentError, /must give a rendering format to render_as/ @@ -193,7 +193,7 @@ describe Puppet::Interface::ActionBuilder do Puppet::Network::FormatHandler.formats.each do |name| it "should accept #{name.inspect} format" do action = Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end render_as name end action.render_as.should == name @@ -204,7 +204,7 @@ describe Puppet::Interface::ActionBuilder do it "should fail if given #{input.inspect}" do expect { Puppet::Interface::ActionBuilder.build(face, :foo) do - when_invoked do true end + when_invoked do |options| true end render_as input end }.to raise_error ArgumentError, /#{input.inspect} is not a valid rendering format/ diff --git a/spec/unit/interface/action_manager_spec.rb b/spec/unit/interface/action_manager_spec.rb index 5a479ad5c..e357a5fa1 100755 --- a/spec/unit/interface/action_manager_spec.rb +++ b/spec/unit/interface/action_manager_spec.rb @@ -15,57 +15,57 @@ describe Puppet::Interface::ActionManager do describe "when included in a class" do it "should be able to define an action" do subject.action(:foo) do - when_invoked { "something "} + when_invoked { |options| "something "} end end it "should be able to define a 'script' style action" do - subject.script :bar do + subject.script :bar do |options| "a bar is where beer is found" end end it "should be able to list defined actions" do subject.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end subject.action(:bar) do - when_invoked { "something" } + when_invoked { |options| "something" } end subject.actions.should =~ [:foo, :bar] end it "should list 'script' actions" do - subject.script :foo do "foo" end + subject.script :foo do |options| "foo" end subject.actions.should =~ [:foo] end it "should list both script and normal actions" do subject.action :foo do - when_invoked do "foo" end + when_invoked do |options| "foo" end end - subject.script :bar do "a bar is where beer is found" end + subject.script :bar do |options| "a bar is where beer is found" end subject.actions.should =~ [:foo, :bar] end it "should be able to indicate when an action is defined" do subject.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end subject.should be_action(:foo) end it "should indicate an action is defined for script actions" do - subject.script :foo do "foo" end + subject.script :foo do |options| "foo" end subject.should be_action :foo end it "should correctly treat action names specified as strings" do subject.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end subject.should be_action("foo") @@ -77,16 +77,16 @@ describe Puppet::Interface::ActionManager do it "should be able to define an action" do subject.action(:foo) do - when_invoked { "something "} + when_invoked { |options| "something "} end end it "should be able to list defined actions" do subject.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end subject.action(:bar) do - when_invoked { "something" } + when_invoked { |options| "something" } end subject.actions.should include(:bar) @@ -94,7 +94,7 @@ describe Puppet::Interface::ActionManager do end it "should be able to indicate when an action is defined" do - subject.action(:foo) { when_invoked do true end } + subject.action(:foo) { when_invoked do |options| true end } subject.should be_action(:foo) end end @@ -112,36 +112,36 @@ describe Puppet::Interface::ActionManager do it "should be able to define an action at the class level" do @klass.action(:foo) do - when_invoked { "something "} + when_invoked { |options| "something "} end end it "should create an instance method when an action is defined at the class level" do @klass.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end @instance.foo.should == "something" end it "should be able to define an action at the instance level" do @instance.action(:foo) do - when_invoked { "something "} + when_invoked { |options| "something "} end end it "should create an instance method when an action is defined at the instance level" do @instance.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end @instance.foo.should == "something" end it "should be able to list actions defined at the class level" do @klass.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end @klass.action(:bar) do - when_invoked { "something" } + when_invoked { |options| "something" } end @klass.actions.should include(:bar) @@ -150,10 +150,10 @@ describe Puppet::Interface::ActionManager do it "should be able to list actions defined at the instance level" do @instance.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end @instance.action(:bar) do - when_invoked { "something" } + when_invoked { |options| "something" } end @instance.actions.should include(:bar) @@ -162,10 +162,10 @@ describe Puppet::Interface::ActionManager do it "should be able to list actions defined at both instance and class level" do @klass.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end @instance.action(:bar) do - when_invoked { "something" } + when_invoked { |options| "something" } end @instance.actions.should include(:bar) @@ -174,14 +174,14 @@ describe Puppet::Interface::ActionManager do it "should be able to indicate when an action is defined at the class level" do @klass.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end @instance.should be_action(:foo) end it "should be able to indicate when an action is defined at the instance level" do @klass.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end @instance.should be_action(:foo) end @@ -191,13 +191,13 @@ describe Puppet::Interface::ActionManager do @instance = @subclass.new @klass.action(:parent) do - when_invoked { "a" } + when_invoked { |options| "a" } end @subclass.action(:sub) do - when_invoked { "a" } + when_invoked { |options| "a" } end @instance.action(:instance) do - when_invoked { "a" } + when_invoked { |options| "a" } end @instance.should be_action(:parent) @@ -210,7 +210,7 @@ describe Puppet::Interface::ActionManager do @instance = @subclass.new @klass.action(:foo) do - when_invoked { "something" } + when_invoked { |options| "something" } end @instance.foo.should == "something" end @@ -218,19 +218,19 @@ describe Puppet::Interface::ActionManager do describe "#action" do it 'should add an action' do - subject.action(:foo) { when_invoked do true end } + subject.action(:foo) { when_invoked do |options| true end } subject.get_action(:foo).should be_a Puppet::Interface::Action end it 'should support default actions' do - subject.action(:foo) { when_invoked do true end; default } + subject.action(:foo) { when_invoked do |options| true end; default } subject.get_default_action.should == subject.get_action(:foo) end it 'should not support more than one default action' do - subject.action(:foo) { when_invoked do true end; default } + subject.action(:foo) { when_invoked do |options| true end; default } expect { subject.action(:bar) { - when_invoked do true end + when_invoked do |options| true end default } }.should raise_error /cannot both be default/ @@ -240,7 +240,7 @@ describe Puppet::Interface::ActionManager do describe "#get_action" do let :parent_class do parent_class = Class.new(Puppet::Interface) - parent_class.action(:foo) { when_invoked do true end } + parent_class.action(:foo) { when_invoked do |options| true end } parent_class end diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb index 9e539c68e..cf8d61d51 100755 --- a/spec/unit/interface/action_spec.rb +++ b/spec/unit/interface/action_spec.rb @@ -20,11 +20,10 @@ describe Puppet::Interface::Action do expect { Puppet::Interface.new(:action_when_invoked, '1.0.0') do action :foo do - when_invoked do - end + when_invoked { } end end - }.to raise_error ArgumentError, /foobra/ + }.to raise_error ArgumentError, /foo/ end it "should work with arity 1 blocks" do @@ -72,11 +71,11 @@ describe Puppet::Interface::Action do it "should be able to call other actions on the same object" do face = Puppet::Interface.new(:my_face, '0.0.1') do action(:foo) do - when_invoked { 25 } + when_invoked { |options| 25 } end action(:bar) do - when_invoked { "the value of foo is '#{foo}'" } + when_invoked { |options| "the value of foo is '#{foo}'" } end end face.foo.should == 25 @@ -90,25 +89,25 @@ describe Puppet::Interface::Action do it "should be able to call other actions on the same object when defined on a class" do class Puppet::Interface::MyInterfaceBaseClass < Puppet::Interface action(:foo) do - when_invoked { 25 } + when_invoked { |options| 25 } end action(:bar) do - when_invoked { "the value of foo is '#{foo}'" } + when_invoked { |options| "the value of foo is '#{foo}'" } end action(:quux) do - when_invoked { "qux told me #{qux}" } + when_invoked { |options| "qux told me #{qux}" } end end face = Puppet::Interface::MyInterfaceBaseClass.new(:my_inherited_face, '0.0.1') do action(:baz) do - when_invoked { "the value of foo in baz is '#{foo}'" } + when_invoked { |options| "the value of foo in baz is '#{foo}'" } end action(:qux) do - when_invoked { baz } + when_invoked { |options| baz } end end face.foo.should == 25 @@ -150,7 +149,7 @@ describe Puppet::Interface::Action do it "should support options with an empty block" do face = Puppet::Interface.new(:action_level_options, '0.0.1') do action :foo do - when_invoked do true end + when_invoked do |options| true end option "--bar" do # this line left deliberately blank end @@ -164,7 +163,7 @@ describe Puppet::Interface::Action do it "should return only action level options when there are no face options" do face = Puppet::Interface.new(:action_level_options, '0.0.1') do action :foo do - when_invoked do true end + when_invoked do |options| true end option "--bar" end end @@ -175,8 +174,8 @@ describe Puppet::Interface::Action do describe "with both face and action options" do let :face do Puppet::Interface.new(:action_level_options, '0.0.1') do - action :foo do when_invoked do true end ; option "--bar" end - action :baz do when_invoked do true end ; option "--bim" end + action :foo do when_invoked do |options| true end ; option "--bar" end + action :baz do when_invoked do |options| true end ; option "--bim" end option "--quux" end end @@ -191,7 +190,7 @@ describe Puppet::Interface::Action do child = parent.new(:inherited_options, '0.0.1') do option "--bar" action :action do - when_invoked do true end + when_invoked do |options| true end option "--baz" end end @@ -223,7 +222,7 @@ describe Puppet::Interface::Action do def add_options_to(&block) face = Puppet::Interface.new(:with_options, '0.0.1') do action(:foo) do - when_invoked do true end + when_invoked do |options| true end self.instance_eval &block end end @@ -244,7 +243,7 @@ describe Puppet::Interface::Action do face = Puppet::Interface.new(:required_action_option, '0.0.1') do action(:bar) do option('--foo') { required } - when_invoked { } + when_invoked {|options| } end end expect { face.bar }.to raise_error ArgumentError, /The following options are required: foo/ @@ -253,7 +252,7 @@ describe Puppet::Interface::Action do it "should fail when a required face option is not provided" do face = Puppet::Interface.new(:required_face_option, '0.0.1') do option('--foo') { required } - action(:bar) { when_invoked { } } + action(:bar) { when_invoked {|options| } } end expect { face.bar }.to raise_error ArgumentError, /The following options are required: foo/ end @@ -263,7 +262,7 @@ describe Puppet::Interface::Action do context "declared locally" do let :face do Puppet::Interface.new(:action_decorators, '0.0.1') do - action :bar do when_invoked do true end end + action :bar do when_invoked do |options| true end end def reported; @reported; end def report(arg) (@reported ||= []) << arg @@ -278,7 +277,7 @@ describe Puppet::Interface::Action do option("-q", "--quux") { before_action { |_,_,_| report :quux } } option("-f") { before_action { |_,_,_| report :f } } option("--baz") { before_action { |_,_,_| report :baz } } - when_invoked { } + when_invoked {|options| } end face.boo :foo => 1, :bar => 1, :quux => 1, :f => 1, :baz => 1 @@ -292,7 +291,7 @@ describe Puppet::Interface::Action do option("-q", "--quux") { after_action { |_,_,_| report :quux } } option("-f") { after_action { |_,_,_| report :f } } option("--baz") { after_action { |_,_,_| report :baz } } - when_invoked { } + when_invoked {|options| } end face.boo :foo => 1, :bar => 1, :quux => 1, :f => 1, :baz => 1 @@ -307,7 +306,7 @@ describe Puppet::Interface::Action do option("-f") { before_action { |_,_,_| report :f } } option("--baz") { before_action { |_,_,_| report :baz } } end - face.script(:boo) { } + face.script(:boo) {|options| } face.boo :foo => 1, :bar => 1, :quux => 1, :f => 1, :baz => 1 face.reported.should == [ :foo, :bar, :quux, :f, :baz ] @@ -321,7 +320,7 @@ describe Puppet::Interface::Action do option("-f") { after_action { |_,_,_| report :f } } option("--baz") { after_action { |_,_,_| report :baz } } end - face.script(:boo) { } + face.script(:boo) {|options| } face.boo :foo => 1, :bar => 1, :quux => 1, :f => 1, :baz => 1 face.reported.should == [ :foo, :bar, :quux, :f, :baz ].reverse @@ -337,7 +336,7 @@ describe Puppet::Interface::Action do option("-q", "--action-quux") { before_action { |_,_,_| report :action_quux } } option("-a") { before_action { |_,_,_| report :a } } option("--action-baz") { before_action { |_,_,_| report :action_baz } } - when_invoked { } + when_invoked {|options| } end option("-u", "--face-quux") { before_action { |_,_,_| report :face_quux } } option("-f") { before_action { |_,_,_| report :f } } @@ -360,7 +359,7 @@ describe Puppet::Interface::Action do option("-q", "--action-quux") { after_action { |_,_,_| report :action_quux } } option("-a") { after_action { |_,_,_| report :a } } option("--action-baz") { after_action { |_,_,_| report :action_baz } } - when_invoked { } + when_invoked {|options| } end option("-u", "--face-quux") { after_action { |_,_,_| report :face_quux } } option("-f") { after_action { |_,_,_| report :f } } @@ -405,7 +404,7 @@ describe Puppet::Interface::Action do context "and inheritance" do let :parent do Class.new(Puppet::Interface) do - script(:on_parent) { :on_parent } + script(:on_parent) {|options| :on_parent } def reported; @reported; end def report(arg) @@ -416,7 +415,7 @@ describe Puppet::Interface::Action do let :child do parent.new(:inherited_decorators, '0.0.1') do - script(:on_child) { :on_child } + script(:on_child) {|options| :on_child } end end @@ -479,7 +478,7 @@ describe Puppet::Interface::Action do after_action { |action, args, options| report :b_after } end - child.script(:decorations) { report :invoked } + child.script(:decorations) { |options| report :invoked } child end @@ -509,7 +508,7 @@ describe Puppet::Interface::Action do subject do face = Puppet::Interface.new(:action_documentation, '0.0.1') do action :documentation do - when_invoked do true end + when_invoked do |options| true end end end face.get_action(:documentation) @@ -528,7 +527,7 @@ describe Puppet::Interface::Action do context "#validate_args" do subject do Puppet::Interface.new(:validate_args, '1.0.0') do - script :test do true end + script :test do |options| true end end end diff --git a/spec/unit/interface_spec.rb b/spec/unit/interface_spec.rb index e28e55aac..8bbbcc857 100755 --- a/spec/unit/interface_spec.rb +++ b/spec/unit/interface_spec.rb @@ -101,7 +101,7 @@ describe Puppet::Interface do should raise_error ArgumentError end - it "should instance-eval any provided block" do + it "should instance-eval any provided block", :'fails_on_ruby_1.9.2' => true do face = subject.new(:face_test_block, '0.0.1') do action(:something) do when_invoked { "foo" } @@ -140,7 +140,7 @@ describe Puppet::Interface do end end - describe "with face-level options" do + describe "with face-level options", :'fails_on_ruby_1.9.2' => true do it "should not return any action-level options" do face = subject.new(:with_options, '0.0.1') do option "--foo" @@ -191,7 +191,7 @@ describe Puppet::Interface do face end - describe "#options" do + describe "#options", :'fails_on_ruby_1.9.2' => true do it "should list inherited options" do face.options.should =~ [:inherited, :local] end @@ -213,7 +213,7 @@ describe Puppet::Interface do end end - describe "#get_option" do + describe "#get_option", :'fails_on_ruby_1.9.2' => true do it "should return an inherited option object" do face.get_option(:inherited).should be_an_instance_of subject::Option end diff --git a/spec/unit/network/handler/fileserver_spec.rb b/spec/unit/network/handler/fileserver_spec.rb index 52c4a71f5..08852634d 100755 --- a/spec/unit/network/handler/fileserver_spec.rb +++ b/spec/unit/network/handler/fileserver_spec.rb @@ -123,7 +123,7 @@ describe Puppet::Network::Handler::FileServer do list.sort.should == [ ["/aFile", "file"], ["/", "directory"] ].sort end - describe Puppet::Network::Handler::FileServer::PluginMount do + describe Puppet::Network::Handler::FileServer::PluginMount, :'fails_on_ruby_1.9.2' => true do PLUGINS = Puppet::Network::Handler::FileServer::PLUGINS # create a module plugin hierarchy diff --git a/spec/unit/network/http/mongrel/rest_spec.rb b/spec/unit/network/http/mongrel/rest_spec.rb index 3e454cf8f..85b9f7496 100755 --- a/spec/unit/network/http/mongrel/rest_spec.rb +++ b/spec/unit/network/http/mongrel/rest_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'puppet/network/http' -describe "Puppet::Network::HTTP::MongrelREST", :if => Puppet.features.mongrel? do +describe "Puppet::Network::HTTP::MongrelREST", :if => Puppet.features.mongrel?, :'fails_on_ruby_1.9.2' => true do before do require 'puppet/network/http/mongrel/rest' end diff --git a/spec/unit/network/http/mongrel_spec.rb b/spec/unit/network/http/mongrel_spec.rb index 56d0afbed..6776fad61 100755 --- a/spec/unit/network/http/mongrel_spec.rb +++ b/spec/unit/network/http/mongrel_spec.rb @@ -6,15 +6,15 @@ require 'spec_helper' require 'puppet/network/http' -describe "Puppet::Network::HTTP::Mongrel", "after initializing", :if => Puppet.features.mongrel? do - it "should not be listening" do +describe "Puppet::Network::HTTP::Mongrel", "after initializing", :if => Puppet.features.mongrel?, :'fails_on_ruby_1.9.2' => true do + it "should not be listening", :'fails_on_ruby_1.9.2' => true do require 'puppet/network/http/mongrel' Puppet::Network::HTTP::Mongrel.new.should_not be_listening end end -describe "Puppet::Network::HTTP::Mongrel", "when turning on listening", :if => Puppet.features.mongrel? do +describe "Puppet::Network::HTTP::Mongrel", "when turning on listening", :if => Puppet.features.mongrel?, :'fails_on_ruby_1.9.2' => true do before do require 'puppet/network/http/mongrel' @@ -96,7 +96,7 @@ describe "Puppet::Network::HTTP::Mongrel", "when turning on listening", :if => P end end -describe "Puppet::Network::HTTP::Mongrel", "when turning off listening", :if => Puppet.features.mongrel? do +describe "Puppet::Network::HTTP::Mongrel", "when turning off listening", :if => Puppet.features.mongrel?, :'fails_on_ruby_1.9.2' => true do before do @mock_mongrel = mock('mongrel httpserver') @mock_mongrel.stubs(:run) diff --git a/spec/unit/network/http/webrick/rest_spec.rb b/spec/unit/network/http/webrick/rest_spec.rb index 267ddcc72..84a2b7791 100755 --- a/spec/unit/network/http/webrick/rest_spec.rb +++ b/spec/unit/network/http/webrick/rest_spec.rb @@ -9,7 +9,7 @@ describe Puppet::Network::HTTP::WEBrickREST do Puppet::Network::HTTP::WEBrickREST.ancestors.should be_include(Puppet::Network::HTTP::Handler) end - describe "when initializing" do + describe "when initializing", :'fails_on_ruby_1.9.2' => true do it "should call the Handler's initialization hook with its provided arguments as the server and handler" do Puppet::Network::HTTP::WEBrickREST.any_instance.expects(:initialize_for_puppet).with(:server => "my", :handler => "arguments") Puppet::Network::HTTP::WEBrickREST.new("my", "arguments") diff --git a/spec/unit/parser/ast/function_spec.rb b/spec/unit/parser/ast/function_spec.rb index c52e806e9..d683b122b 100755 --- a/spec/unit/parser/ast/function_spec.rb +++ b/spec/unit/parser/ast/function_spec.rb @@ -48,7 +48,7 @@ describe Puppet::Parser::AST::Function do lambda{ func.evaluate(@scope) }.should raise_error(Puppet::ParseError,"Function 'exist' must be the value of a statement") end - it "should evaluate its arguments" do + it "should evaluate its arguments", :'fails_on_ruby_1.9.2' => true do argument = stub 'arg' Puppet::Parser::Functions.stubs(:function).with("exist").returns(true) func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement, :arguments => argument diff --git a/spec/unit/parser/ast/selector_spec.rb b/spec/unit/parser/ast/selector_spec.rb index 1bf5f6757..76afec271 100755 --- a/spec/unit/parser/ast/selector_spec.rb +++ b/spec/unit/parser/ast/selector_spec.rb @@ -6,7 +6,7 @@ describe Puppet::Parser::AST::Selector do @scope = Puppet::Parser::Scope.new end - describe "when evaluating" do + describe "when evaluating", :'fails_on_ruby_1.9.2' => true do before :each do @param = stub 'param' diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb index 88f7167f3..fcce9f6f4 100755 --- a/spec/unit/parser/compiler_spec.rb +++ b/spec/unit/parser/compiler_spec.rb @@ -571,7 +571,7 @@ describe Puppet::Parser::Compiler do @compiler.evaluate_classes(%w{myclass}, @scope) end - it "should ensure each node class hash is in catalog and have appropriate parameters" do + it "should ensure each node class hash is in catalog and have appropriate parameters", :'fails_on_ruby_1.9.2' => true do klasses = {'foo'=>{'1'=>'one'}, 'bar::foo'=>{'2'=>'two'}, 'bar'=>{'1'=> [1,2,3], '2'=>{'foo'=>'bar'}}} @node.classes = klasses ast_obj = Puppet::Parser::AST::String.new(:value => 'foo') @@ -595,7 +595,7 @@ describe Puppet::Parser::Compiler do r2.tags.should =~ ['class', 'bar'] end - it "should ensure each node class is in catalog and has appropriate tags" do + it "should ensure each node class is in catalog and has appropriate tags", :'fails_on_ruby_1.9.2' => true do klasses = ['bar::foo'] @node.classes = klasses ast_obj = Puppet::Parser::AST::String.new(:value => 'foo') diff --git a/spec/unit/parser/functions/create_resources_spec.rb b/spec/unit/parser/functions/create_resources_spec.rb index 88a67e369..da76e75d0 100755 --- a/spec/unit/parser/functions/create_resources_spec.rb +++ b/spec/unit/parser/functions/create_resources_spec.rb @@ -114,7 +114,7 @@ notify{tester:} @scope.resource=Puppet::Parser::Resource.new('class', 't', :scope => @scope) Puppet::Parser::Functions.function(:create_resources) end - it 'should be able to create classes' do + it 'should be able to create classes', :'fails_on_ruby_1.9.2' => true do @scope.function_create_resources(['class', {'bar'=>{'one'=>'two'}}]) @scope.compiler.compile @compiler.catalog.resource(:notify, "test")['message'].should == 'two' @@ -123,7 +123,7 @@ notify{tester:} it 'should fail to create non-existing classes' do lambda { @scope.function_create_resources(['class', {'blah'=>{'one'=>'two'}}]) }.should raise_error(ArgumentError ,'could not find hostclass blah') end - it 'should be able to add edges' do + it 'should be able to add edges', :'fails_on_ruby_1.9.2' => true do @scope.function_create_resources(['class', {'bar'=>{'one'=>'two', 'require' => 'Notify[tester]'}}]) @scope.compiler.compile rg = @scope.compiler.catalog.to_ral.relationship_graph diff --git a/spec/unit/parser/functions/inline_template_spec.rb b/spec/unit/parser/functions/inline_template_spec.rb index a9ac0c2d0..47dcae15e 100755 --- a/spec/unit/parser/functions/inline_template_spec.rb +++ b/spec/unit/parser/functions/inline_template_spec.rb @@ -1,7 +1,7 @@ #!/usr/bin/env rspec require 'spec_helper' -describe "the inline_template function" do +describe "the inline_template function", :'fails_on_ruby_1.9.2' => true do before :all do Puppet::Parser::Functions.autoloader.loadall end diff --git a/spec/unit/parser/functions/shellquote_spec.rb b/spec/unit/parser/functions/shellquote_spec.rb index b100b4913..bfa2969ea 100755 --- a/spec/unit/parser/functions/shellquote_spec.rb +++ b/spec/unit/parser/functions/shellquote_spec.rb @@ -53,7 +53,7 @@ describe "the shellquote function" do result.should(eql( "'$PATH' 'foo$bar' '\"x$\"'")) end - it "should deal with apostrophes (single quotes)" do + it "should deal with apostrophes (single quotes)", :'fails_on_ruby_1.9.2' => true do result = @scope.function_shellquote( ["'foo'bar'", "`$'EDITOR'`"]) result.should(eql( @@ -65,12 +65,12 @@ describe "the shellquote function" do result.should(eql( "'`echo *`' '`ls \"$MAILPATH\"`'")) end - it "should deal with both single and double quotes" do + it "should deal with both single and double quotes", :'fails_on_ruby_1.9.2' => true do result = @scope.function_shellquote( ['\'foo"bar"xyzzy\'', '"foo\'bar\'xyzzy"']) result.should(eql( '"\'foo\\"bar\\"xyzzy\'" "\\"foo\'bar\'xyzzy\\""')) end - it "should handle multiple quotes *and* dollars and backquotes" do + it "should handle multiple quotes *and* dollars and backquotes", :'fails_on_ruby_1.9.2' => true do result = @scope.function_shellquote( ['\'foo"$x`bar`"xyzzy\'']) result.should(eql( '"\'foo\\"\\$x\\`bar\\`\\"xyzzy\'"')) end diff --git a/spec/unit/parser/functions/template_spec.rb b/spec/unit/parser/functions/template_spec.rb index e7ee974d3..6bce69534 100755 --- a/spec/unit/parser/functions/template_spec.rb +++ b/spec/unit/parser/functions/template_spec.rb @@ -1,7 +1,7 @@ #!/usr/bin/env rspec require 'spec_helper' -describe "the template function" do +describe "the template function", :'fails_on_ruby_1.9.2' => true do before :all do Puppet::Parser::Functions.autoloader.loadall end diff --git a/spec/unit/parser/resource_spec.rb b/spec/unit/parser/resource_spec.rb index 0d9cba60b..365c4e9c5 100755 --- a/spec/unit/parser/resource_spec.rb +++ b/spec/unit/parser/resource_spec.rb @@ -113,7 +113,7 @@ describe Puppet::Parser::Resource do @arguments = {:scope => @scope} end - it "should fail unless #{name.to_s} is specified" do + it "should fail unless #{name.to_s} is specified", :'fails_on_ruby_1.9.2' => true do lambda { Puppet::Parser::Resource.new('file', '/my/file') }.should raise_error(ArgumentError) end diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb index 0293e0758..7831dae3a 100755 --- a/spec/unit/provider/mount/parsed_spec.rb +++ b/spec/unit/provider/mount/parsed_spec.rb @@ -39,7 +39,7 @@ FSTAB # it_should_behave_like "all parsedfile providers", # provider_class, my_fixtures('*.fstab') - describe "on Solaris", :if => Facter.value(:operatingsystem) == 'Solaris' do + describe "on Solaris", :if => Facter.value(:operatingsystem) == 'Solaris', :'fails_on_ruby_1.9.2' => true do before :each do @example_line = "/dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 \t\t / \t ufs 1 no\t-" @@ -193,6 +193,47 @@ FSTAB my_fixtures('*.fstab').each do |fstab| platform = File.basename(fstab, '.fstab') + + describe "when calling instances on #{platform}" do + before :each do + if Facter[:operatingsystem] == "Solaris" then + platform == 'solaris' or + pending "We need to stub the operatingsystem fact at load time, but can't" + else + platform != 'solaris' or + pending "We need to stub the operatingsystem fact at load time, but can't" + end + + # Stub the mount output to our fixture. + begin + mount = my_fixture(platform + '.mount') + @provider.stubs(:mountcmd).returns File.read(mount) + rescue + pending "is #{platform}.mount missing at this point?" + end + + # Note: we have to stub default_target before creating resources + # because it is used by Puppet::Type::Mount.new to populate the + # :target property. + @provider.stubs(:default_target).returns fstab + @retrieve = @provider.instances.collect { |prov| {:name => prov.get(:name), :ensure => prov.get(:ensure)}} + end + + # Following mountpoint are present in all fstabs/mountoutputs + it "should include unmounted resources" do + @retrieve.should include(:name => '/', :ensure => :mounted) + end + + it "should include mounted resources" do + @retrieve.should include(:name => '/boot', :ensure => :unmounted) + end + + it "should include ghost resources" do + @retrieve.should include(:name => '/ghost', :ensure => :ghost) + end + + end + describe "when prefetching on #{platform}" do before :each do if Facter[:operatingsystem] == "Solaris" then diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb index 7d1acd537..8e08242d8 100755 --- a/spec/unit/provider/package/macports_spec.rb +++ b/spec/unit/provider/package/macports_spec.rb @@ -30,7 +30,7 @@ describe provider_class do it { should be_versionable } end - describe "when listing all instances" do + describe "when listing all instances", :'fails_on_ruby_1.9.2' => true do it "should call port -q installed" do provider_class.expects(:port).with("-q", :installed).returns("") provider_class.instances @@ -111,7 +111,7 @@ describe provider_class do provider.update end - it "should execute port install if the port is not installed" do + it "should execute port install if the port is not installed", :'fails_on_ruby_1.9.2' => true do resource[:name] = resource_name resource[:ensure] = :present provider.expects(:query).returns("") diff --git a/spec/unit/provider/service/init_spec.rb b/spec/unit/provider/service/init_spec.rb index d64e0fc5d..8374594e7 100755 --- a/spec/unit/provider/service/init_spec.rb +++ b/spec/unit/provider/service/init_spec.rb @@ -46,7 +46,7 @@ describe provider_class do results = (@services-exclude).collect {|x| "#{x}_instance"} @class.get_services(@class.defpath, exclude).should == results end - it "should omit a single service from the exclude list" do + it "should omit a single service from the exclude list", :'fails_on_ruby_1.9.2' => true do exclude = 'two' (@services-exclude.to_a).each do |inst| @class.expects(:new).with{|hash| hash[:name] == inst}.returns("#{inst}_instance") diff --git a/spec/unit/provider/service/src_spec.rb b/spec/unit/provider/service/src_spec.rb index 17f49994e..b45ca0c7c 100755 --- a/spec/unit/provider/service/src_spec.rb +++ b/spec/unit/provider/service/src_spec.rb @@ -44,7 +44,7 @@ describe provider_class do @provider.stop end - it "should execute status and return running if the subsystem is active" do + it "should execute status and return running if the subsystem is active", :'fails_on_ruby_1.9.2' => true do sample_output = <<_EOF_ Subsystem Group PID Status myservice tcpip 1234 active @@ -54,7 +54,7 @@ _EOF_ @provider.status.should == :running end - it "should execute status and return stopped if the subsystem is inoperative" do + it "should execute status and return stopped if the subsystem is inoperative", :'fails_on_ruby_1.9.2' => true do sample_output = <<_EOF_ Subsystem Group PID Status myservice tcpip inoperative @@ -64,7 +64,7 @@ _EOF_ @provider.status.should == :stopped end - it "should execute status and return nil if the status is not known" do + it "should execute status and return nil if the status is not known", :'fails_on_ruby_1.9.2' => true do sample_output = <<_EOF_ Subsystem Group PID Status myservice tcpip randomdata @@ -74,7 +74,7 @@ _EOF_ @provider.status.should == nil end - it "should execute restart which runs refresh" do + it "should execute restart which runs refresh", :'fails_on_ruby_1.9.2' => true do sample_output = <<_EOF_ #subsysname:synonym:cmdargs:path:uid:auditid:standin:standout:standerr:action:multi:contact:svrkey:svrmtype:priority:signorm:sigforce:display:waittime:grpname: myservice:::/usr/sbin/inetd:0:0:/dev/console:/dev/console:/dev/console:-O:-Q:-K:0:0:20:0:0:-d:20:tcpip: @@ -84,7 +84,7 @@ _EOF_ @provider.restart end - it "should execute restart which runs stopsrc then startsrc" do + it "should execute restart which runs stopsrc then startsrc", :'fails_on_ruby_1.9.2' => true do sample_output = <<_EOF_ #subsysname:synonym:cmdargs:path:uid:auditid:standin:standout:standerr:action:multi:contact:svrkey:svrmtype:priority:signorm:sigforce:display:waittime:grpname: myservice::--no-daemonize:/usr/sbin/puppetd:0:0:/dev/null:/var/log/puppet.log:/var/log/puppet.log:-O:-Q:-S:0:0:20:15:9:-d:20::" diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb index 69d29c674..bd5e55a9e 100755 --- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb @@ -9,23 +9,19 @@ describe provider_class do include PuppetSpec::Files before :each do - @sshauthkey_class = Puppet::Type.type(:ssh_authorized_key) - @provider = @sshauthkey_class.provider(:parsed) @keyfile = tmpfile('authorized_keys') - @provider.any_instance.stubs(:target).returns @keyfile + @provider_class = provider_class + @provider_class.initvars + @provider_class.any_instance.stubs(:target).returns @keyfile @user = 'random_bob' Puppet::Util.stubs(:uid).with(@user).returns 12345 end - after :each do - @provider.initvars - end - def mkkey(args) args[:target] = @keyfile args[:user] = @user resource = Puppet::Type.type(:ssh_authorized_key).new(args) - key = @provider.new(resource) + key = @provider_class.new(resource) args.each do |p,v| key.send(p.to_s + "=", v) end @@ -33,26 +29,26 @@ describe provider_class do end def genkey(key) - @provider.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam) + @provider_class.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam) File.stubs(:chown) File.stubs(:chmod) Puppet::Util::SUIDManager.stubs(:asuser).yields key.flush - @provider.target_object(@keyfile).read + @provider_class.target_object(@keyfile).read end it_should_behave_like "all parsedfile providers", provider_class it "should be able to generate a basic authorized_keys file" do - key = mkkey(:name => "Just Testing", + key = mkkey(:name => "Just_Testing", :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", :type => "ssh-dss", :ensure => :present, :options => [:absent] ) - genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj Just Testing\n" + genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj Just_Testing\n" end it "should be able to generate a authorized_keys file with options" do @@ -71,25 +67,25 @@ describe provider_class do options = %w{from="host1.reductlivelabs.com,host.reductivelabs.com" command="/usr/local/bin/run" ssh-pty} optionstr = options.join(", ") - @provider.parse_options(optionstr).should == options + @provider_class.parse_options(optionstr).should == options end it "should use '' as name for entries that lack a comment" do line = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAut8aOSxenjOqF527dlsdHWV4MNoAsX14l9M297+SQXaQ5Z3BedIxZaoQthkDALlV/25A1COELrg9J2MqJNQc8Xe9XQOIkBQWWinUlD/BXwoOTWEy8C8zSZPHZ3getMMNhGTBO+q/O+qiJx3y5cA4MTbw2zSxukfWC87qWwcZ64UUlegIM056vPsdZWFclS9hsROVEa57YUMrehQ1EGxT4Z5j6zIopufGFiAPjZigq/vqgcAqhAKP6yu4/gwO6S9tatBeEjZ8fafvj1pmvvIplZeMr96gHE7xS3pEEQqnB3nd4RY7AF6j9kFixnsytAUO7STPh/M3pLiVQBN89TvWPQ==" - @provider.parse(line)[0][:name].should == "" + @provider_class.parse(line)[0][:name].should == "" end end describe provider_class do before :each do - @resource = stub("resource", :name => "foo") - @resource.stubs(:[]).returns "foo" - @resource.class.stubs(:key_attributes).returns( [:name] ) + @resource = Puppet::Type.type(:ssh_authorized_key).new(:name => "foo", :user => "random_bob") @provider = provider_class.new(@resource) provider_class.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam) Puppet::Util::SUIDManager.stubs(:asuser).yields + + provider_class.initvars end describe "when flushing" do @@ -103,9 +99,9 @@ describe provider_class do describe "and both a user and a target have been specified" do before :each do Puppet::Util.stubs(:uid).with("random_bob").returns 12345 - @resource.stubs(:should).with(:user).returns "random_bob" + @resource[:user] = "random_bob" target = "/tmp/.ssh_dir/place_to_put_authorized_keys" - @resource.stubs(:should).with(:target).returns target + @resource[:target] = target end it "should create the directory" do @@ -134,8 +130,7 @@ describe provider_class do describe "and a user has been specified with no target" do before :each do - @resource.stubs(:should).with(:user).returns "nobody" - @resource.stubs(:should).with(:target).returns nil + @resource[:user] = "nobody" # # I'd like to use random_bob here and something like # @@ -186,26 +181,20 @@ describe provider_class do end describe "and a target has been specified with no user" do - before :each do - @resource.stubs(:should).with(:user).returns nil - @resource.stubs(:should).with(:target).returns("/tmp/.ssh_dir/place_to_put_authorized_keys") - end - it "should raise an error" do + @resource = Puppet::Type.type(:ssh_authorized_key).new(:name => "foo", :target => "/tmp/.ssh_dir/place_to_put_authorized_keys") + @provider = provider_class.new(@resource) + proc { @provider.flush }.should raise_error end end describe "and a invalid user has been specified with no target" do - before :each do - @resource.stubs(:should).with(:user).returns "thisusershouldnotexist" - @resource.stubs(:should).with(:target).returns nil - end - it "should catch an exception and raise a Puppet error" do + @resource[:user] = "thisusershouldnotexist" + lambda { @provider.flush }.should raise_error(Puppet::Error) end end - end end diff --git a/spec/unit/provider/user/user_role_add_spec.rb b/spec/unit/provider/user/user_role_add_spec.rb index b17ba68c8..5f2fc306e 100755 --- a/spec/unit/provider/user/user_role_add_spec.rb +++ b/spec/unit/provider/user/user_role_add_spec.rb @@ -40,7 +40,7 @@ describe provider_class do end end - describe "when calling transition" do + describe "when calling transition", :'fails_on_ruby_1.9.2' => true do it "should return the type set to whatever is passed in" do @provider.expects(:command).with(:modify).returns("foomod") @provider.transition("bar").include?("type=bar") @@ -120,7 +120,7 @@ describe provider_class do @provider.expects(:execute).with { |args| args.include?("-o") } end - it "should add -o when the user is being created" do + it "should add -o when the user is being created", :'fails_on_ruby_1.9.2' => true do @provider.stubs(:password=) @provider.create end diff --git a/spec/unit/provider/zpool/solaris_spec.rb b/spec/unit/provider/zpool/solaris_spec.rb index 7e3048a7a..39ee9c9ba 100755 --- a/spec/unit/provider/zpool/solaris_spec.rb +++ b/spec/unit/provider/zpool/solaris_spec.rb @@ -150,7 +150,7 @@ describe provider_class do end end - describe "when calling create" do + describe "when calling create", :'fails_on_ruby_1.9.2' => true do before do @resource.stubs(:[]).with(:pool).returns("mypool") @provider.stubs(:zpool) diff --git a/spec/unit/resource/status_spec.rb b/spec/unit/resource/status_spec.rb index bb88518c0..e5a9291db 100755 --- a/spec/unit/resource/status_spec.rb +++ b/spec/unit/resource/status_spec.rb @@ -140,7 +140,7 @@ describe Puppet::Resource::Status do end end - describe "When converting to YAML" do + describe "When converting to YAML", :'fails_on_ruby_1.9.2' => true do it "should include only documented attributes" do @status.file = "/foo.rb" @status.line = 27 diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 79ea69e9c..5c8e8dcf9 100755 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -516,7 +516,7 @@ type: File ) end - it "should align, sort and add trailing commas to attributes with ensure first" do + it "should align, sort and add trailing commas to attributes with ensure first", :'fails_on_ruby_1.9.2' => true do @resource.to_manifest.should == <<-HEREDOC.gsub(/^\s{8}/, '').gsub(/\n$/, '') one::two { '/my/file': ensure => 'present', diff --git a/spec/unit/simple_graph_spec.rb b/spec/unit/simple_graph_spec.rb index 472ebbd36..17e382fcc 100755 --- a/spec/unit/simple_graph_spec.rb +++ b/spec/unit/simple_graph_spec.rb @@ -441,7 +441,7 @@ describe Puppet::SimpleGraph do end end - describe "when matching edges" do + describe "when matching edges", :'fails_on_ruby_1.9.2' => true do before do @graph = Puppet::SimpleGraph.new @event = Puppet::Transaction::Event.new(:name => :yay, :resource => "a") diff --git a/spec/unit/ssl/certificate_authority/interface_spec.rb b/spec/unit/ssl/certificate_authority/interface_spec.rb index 9e858dd54..46273ccee 100755 --- a/spec/unit/ssl/certificate_authority/interface_spec.rb +++ b/spec/unit/ssl/certificate_authority/interface_spec.rb @@ -68,7 +68,7 @@ describe Puppet::SSL::CertificateAuthority::Interface do @class.new(:generate, :to => :all).subjects.should == :all end - it "should fail if the subjects setting isn't :all or an array" do + it "should fail if the subjects setting isn't :all or an array", :'fails_on_ruby_1.9.2' => true do lambda { @class.new(:generate, "other") }.should raise_error(ArgumentError) end end diff --git a/spec/unit/ssl/host_spec.rb b/spec/unit/ssl/host_spec.rb index d14da538e..c2d9690e6 100755 --- a/spec/unit/ssl/host_spec.rb +++ b/spec/unit/ssl/host_spec.rb @@ -517,7 +517,7 @@ describe Puppet::SSL::Host do Puppet::SSL::Host.search :for => Puppet::SSL::CertificateRequest end - it "should return a Host instance created with the name of each found instance" do + it "should return a Host instance created with the name of each found instance", :'fails_on_ruby_1.9.2' => true do key = stub 'key', :name => "key" cert = stub 'cert', :name => "cert" csr = stub 'csr', :name => "csr" diff --git a/spec/unit/transaction/event_spec.rb b/spec/unit/transaction/event_spec.rb index 1227802a7..0093baeb9 100755 --- a/spec/unit/transaction/event_spec.rb +++ b/spec/unit/transaction/event_spec.rb @@ -5,7 +5,7 @@ require 'puppet/transaction/event' describe Puppet::Transaction::Event do [:previous_value, :desired_value, :property, :resource, :name, :message, :file, :line, :tags, :audited].each do |attr| - it "should support #{attr}" do + it "should support #{attr}", :'fails_on_ruby_1.9.2' => true do event = Puppet::Transaction::Event.new event.send(attr.to_s + "=", "foo") event.send(attr).should == "foo" @@ -16,7 +16,7 @@ describe Puppet::Transaction::Event do Puppet::Transaction::Event.new(:property => :foo).property.should == "foo" end - it "should always convert the resource to a string" do + it "should always convert the resource to a string", :'fails_on_ruby_1.9.2' => true do Puppet::Transaction::Event.new(:resource => :foo).resource.should == "foo" end @@ -95,17 +95,17 @@ describe Puppet::Transaction::Event do end end - it "should use the source description as the source if one is set" do + it "should use the source description as the source if one is set", :'fails_on_ruby_1.9.2' => true do Puppet::Util::Log.expects(:new).with { |args| args[:source] == "/my/param" } Puppet::Transaction::Event.new(:source_description => "/my/param", :resource => "Foo[bar]", :property => "foo").send_log end - it "should use the property as the source if one is available and no source description is set" do + it "should use the property as the source if one is available and no source description is set", :'fails_on_ruby_1.9.2' => true do Puppet::Util::Log.expects(:new).with { |args| args[:source] == "foo" } Puppet::Transaction::Event.new(:resource => "Foo[bar]", :property => "foo").send_log end - it "should use the property as the source if one is available and no property or source description is set" do + it "should use the property as the source if one is available and no property or source description is set", :'fails_on_ruby_1.9.2' => true do Puppet::Util::Log.expects(:new).with { |args| args[:source] == "Foo[bar]" } Puppet::Transaction::Event.new(:resource => "Foo[bar]").send_log end diff --git a/spec/unit/type/augeas_spec.rb b/spec/unit/type/augeas_spec.rb index c8dc207f9..e80da9559 100755 --- a/spec/unit/type/augeas_spec.rb +++ b/spec/unit/type/augeas_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' augeas = Puppet::Type.type(:augeas) describe augeas do - describe "when augeas is present", :if => Puppet.features.augeas? do + describe "when augeas is present", :if => Puppet.features.augeas?, :'fails_on_ruby_1.9.2' => true do it "should have a default provider inheriting from Puppet::Provider" do augeas.defaultprovider.ancestors.should be_include(Puppet::Provider) end diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb index 6cd3ab701..3a01d09c1 100755 --- a/spec/unit/type/file_spec.rb +++ b/spec/unit/type/file_spec.rb @@ -300,12 +300,12 @@ describe Puppet::Type.type(:file) do file[:path].should == "X:/foo/bar/baz" end - it "should leave a drive letter with a slash alone" do + it "should leave a drive letter with a slash alone", :'fails_on_ruby_1.9.2' => true do file = Puppet::Type::File.new(:path => "X:/") file[:path].should == "X:/" end - it "should add a slash to a drive letter" do + it "should add a slash to a drive letter", :'fails_on_ruby_1.9.2' => true do file = Puppet::Type::File.new(:path => "X:") file[:path].should == "X:/" end @@ -324,7 +324,7 @@ describe Puppet::Type.type(:file) do end describe "when using UNC filenames" do - describe "on Microsoft Windows systems", :if => Puppet.features.microsoft_windows? do + describe "on Microsoft Windows systems", :if => Puppet.features.microsoft_windows?, :'fails_on_ruby_1.9.2' => true do before do Puppet.features.stubs(:posix?).returns(false) Puppet.features.stubs(:microsoft_windows?).returns(true) diff --git a/spec/unit/type/group_spec.rb b/spec/unit/type/group_spec.rb index 42fd3fb7b..afe28247a 100755 --- a/spec/unit/type/group_spec.rb +++ b/spec/unit/type/group_spec.rb @@ -41,11 +41,11 @@ describe Puppet::Type.type(:group) do end end - it "should have a boolean method for determining if duplicates are allowed" do + it "should have a boolean method for determining if duplicates are allowed", :'fails_on_ruby_1.9.2' => true do @class.new(:name => "foo").methods.should be_include("allowdupe?") end - it "should have a boolean method for determining if system groups are allowed" do + it "should have a boolean method for determining if system groups are allowed", :'fails_on_ruby_1.9.2' => true do @class.new(:name => "foo").methods.should be_include("system?") end diff --git a/spec/unit/type/resources_spec.rb b/spec/unit/type/resources_spec.rb index aedc58c7c..48c068cfa 100755 --- a/spec/unit/type/resources_spec.rb +++ b/spec/unit/type/resources_spec.rb @@ -51,7 +51,7 @@ describe resources do @resources.generate.collect { |r| r.ref }.should_not include(@host1.ref) end - it "should not include the skipped users" do + it "should not include the skipped users", :'fails_on_ruby_1.9.2' => true do res = Puppet::Type.type(:resources).new :name => :user, :purge => true res.catalog = Puppet::Resource::Catalog.new diff --git a/spec/unit/type/schedule_spec.rb b/spec/unit/type/schedule_spec.rb index 33064ca6f..08ec70cd7 100755 --- a/spec/unit/type/schedule_spec.rb +++ b/spec/unit/type/schedule_spec.rb @@ -96,7 +96,7 @@ describe Puppet::Type.type(:schedule) do end end - describe Puppet::Type.type(:schedule), "when matching hourly by distance" do + describe Puppet::Type.type(:schedule), "when matching hourly by distance", :'fails_on_ruby_1.9.2' => true do include ScheduleTesting before do @@ -117,7 +117,7 @@ describe Puppet::Type.type(:schedule) do end end - describe Puppet::Type.type(:schedule), "when matching daily by distance" do + describe Puppet::Type.type(:schedule), "when matching daily by distance", :'fails_on_ruby_1.9.2' => true do include ScheduleTesting before do @@ -138,7 +138,7 @@ describe Puppet::Type.type(:schedule) do end end - describe Puppet::Type.type(:schedule), "when matching weekly by distance" do + describe Puppet::Type.type(:schedule), "when matching weekly by distance", :'fails_on_ruby_1.9.2' => true do include ScheduleTesting before do @@ -159,7 +159,7 @@ describe Puppet::Type.type(:schedule) do end end - describe Puppet::Type.type(:schedule), "when matching monthly by distance" do + describe Puppet::Type.type(:schedule), "when matching monthly by distance", :'fails_on_ruby_1.9.2' => true do include ScheduleTesting before do @@ -180,7 +180,7 @@ describe Puppet::Type.type(:schedule) do end end - describe Puppet::Type.type(:schedule), "when matching hourly by number" do + describe Puppet::Type.type(:schedule), "when matching hourly by number", :'fails_on_ruby_1.9.2' => true do include ScheduleTesting before do @@ -205,7 +205,7 @@ describe Puppet::Type.type(:schedule) do end end - describe Puppet::Type.type(:schedule), "when matching daily by number" do + describe Puppet::Type.type(:schedule), "when matching daily by number", :'fails_on_ruby_1.9.2' => true do include ScheduleTesting before do @@ -236,7 +236,7 @@ describe Puppet::Type.type(:schedule) do end end - describe Puppet::Type.type(:schedule), "when matching weekly by number" do + describe Puppet::Type.type(:schedule), "when matching weekly by number", :'fails_on_ruby_1.9.2' => true do include ScheduleTesting before do @@ -261,7 +261,7 @@ describe Puppet::Type.type(:schedule) do end end - describe Puppet::Type.type(:schedule), "when matching monthly by number" do + describe Puppet::Type.type(:schedule), "when matching monthly by number", :'fails_on_ruby_1.9.2' => true do include ScheduleTesting before do @@ -286,7 +286,7 @@ describe Puppet::Type.type(:schedule) do end end - describe Puppet::Type.type(:schedule), "when matching with a repeat greater than one" do + describe Puppet::Type.type(:schedule), "when matching with a repeat greater than one", :'fails_on_ruby_1.9.2' => true do include ScheduleTesting before do diff --git a/spec/unit/type/ssh_authorized_key_spec.rb b/spec/unit/type/ssh_authorized_key_spec.rb index a5f167165..71b8a9ab0 100755 --- a/spec/unit/type/ssh_authorized_key_spec.rb +++ b/spec/unit/type/ssh_authorized_key_spec.rb @@ -16,115 +16,223 @@ describe ssh_authorized_key do @catalog = Puppet::Resource::Catalog.new end - it "should have a name parameter" do - @class.attrtype(:name).should == :param - end - it "should have :name be its namevar" do @class.key_attributes.should == [:name] end - it "should have a :provider parameter" do - @class.attrtype(:provider).should == :param - end + describe "when validating attributes" do - it "should have an ensure property" do - @class.attrtype(:ensure).should == :property - end + [:name, :provider].each do |param| + it "should have a #{param} parameter" do + @class.attrtype(param).should == :param + end + end - it "should support :present as a value for :ensure" do - proc { @class.new(:name => "whev", :ensure => :present, :user => "nobody") }.should_not raise_error - end + [:type, :key, :user, :target, :options, :ensure].each do |property| + it "should have a #{property} property" do + @class.attrtype(property).should == :property + end + end - it "should support :absent as a value for :ensure" do - proc { @class.new(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error end - it "should have an type property" do - @class.attrtype(:type).should == :property - end - it "should support ssh-dss as an type value" do - proc { @class.new(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error - end - it "should support ssh-rsa as an type value" do - proc { @class.new(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error - end - it "should support :dsa as an type value" do - proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error - end - it "should support :rsa as an type value" do - proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error - end + describe "when validating values" do - it "should not support values other than ssh-dss, ssh-rsa, dsa, rsa in the ssh_authorized_key_type" do - proc { @class.new(:name => "whev", :type => :something) }.should raise_error(Puppet::Error) - end + describe "for name" do - it "should have an key property" do - @class.attrtype(:key).should == :property - end + it "should support valid names" do + proc { @class.new(:name => "username", :ensure => :present, :user => "nobody") }.should_not raise_error + proc { @class.new(:name => "username@hostname", :ensure => :present, :user => "nobody") }.should_not raise_error + end - it "should have an user property" do - @class.attrtype(:user).should == :property - end + it "should not support whitespaces" do + proc { @class.new(:name => "my test", :ensure => :present, :user => "nobody") }.should raise_error(Puppet::Error,/Resourcename must not contain whitespace/) + proc { @class.new(:name => "my\ttest", :ensure => :present, :user => "nobody") }.should raise_error(Puppet::Error,/Resourcename must not contain whitespace/) + end - it "should have an options property" do - @class.attrtype(:options).should == :property - end + end - it "'s options property should return well formed string of arrays from is_to_s" do - resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"]) + describe "for ensure" do - resource.property(:options).is_to_s(["a","b","c"]).should == "a,b,c" - end + it "should support :present" do + proc { @class.new(:name => "whev", :ensure => :present, :user => "nobody") }.should_not raise_error + end - it "'s options property should return well formed string of arrays from is_to_s" do - resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"]) + it "should support :absent" do + proc { @class.new(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error + end - resource.property(:options).should_to_s(["a","b","c"]).should == "a,b,c" - end + it "should not support other values" do + proc { @class.new(:name => "whev", :ensure => :foo, :user => "nobody") }.should raise_error(Puppet::Error, /Invalid value/) + end + + end + + describe "for type" do + + + it "should support ssh-dss" do + proc { @class.new(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error + end + + it "should support ssh-rsa" do + proc { @class.new(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error + end + + it "should support :dsa" do + proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error + end + + it "should support :rsa" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error + end + + it "should alias :rsa to :ssh-rsa" do + key = @class.new(:name => "whev", :type => :rsa, :user => "nobody") + key.should(:type).should == :'ssh-rsa' + end + + it "should alias :dsa to :ssh-dss" do + key = @class.new(:name => "whev", :type => :dsa, :user => "nobody") + key.should(:type).should == :'ssh-dss' + end + + it "should not support values other than ssh-dss, ssh-rsa, dsa, rsa" do + proc { @class.new(:name => "whev", :type => :something) }.should raise_error(Puppet::Error,/Invalid value/) + end + + end + + describe "for key" do + + it "should support a valid key like a 1024 bit rsa key" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :key => 'AAAAB3NzaC1yc2EAAAADAQABAAAAgQDCPfzW2ry7XvMc6E5Kj2e5fF/YofhKEvsNMUogR3PGL/HCIcBlsEjKisrY0aYgD8Ikp7ZidpXLbz5dBsmPy8hJiBWs5px9ZQrB/EOQAwXljvj69EyhEoGawmxQMtYw+OAIKHLJYRuk1QiHAMHLp5piqem8ZCV2mLb9AsJ6f7zUVw==')}.should_not raise_error + end + + it "should support a valid key like a 4096 bit rsa key" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :key => 'AAAAB3NzaC1yc2EAAAADAQABAAACAQDEY4pZFyzSfRc9wVWI3DfkgT/EL033UZm/7x1M+d+lBD00qcpkZ6CPT7lD3Z+vylQlJ5S8Wcw6C5Smt6okZWY2WXA9RCjNJMIHQbJAzwuQwgnwU/1VMy9YPp0tNVslg0sUUgpXb13WW4mYhwxyGmIVLJnUrjrQmIFhtfHsJAH8ZVqCWaxKgzUoC/YIu1u1ScH93lEdoBPLlwm6J0aiM7KWXRb7Oq1nEDZtug1zpX5lhgkQWrs0BwceqpUbY+n9sqeHU5e7DCyX/yEIzoPRW2fe2Gx1Iq6JKM/5NNlFfaW8rGxh3Z3S1NpzPHTRjw8js3IeGiV+OPFoaTtM1LsWgPDSBlzIdyTbSQR7gKh0qWYCNV/7qILEfa0yIFB5wIo4667iSPZw2pNgESVtenm8uXyoJdk8iWQ4mecdoposV/znknNb2GPgH+n/2vme4btZ0Sl1A6rev22GQjVgbWOn8zaDglJ2vgCN1UAwmq41RXprPxENGeLnWQppTnibhsngu0VFllZR5kvSIMlekLRSOFLFt92vfd+tk9hZIiKm9exxcbVCGGQPsf6dZ27rTOmg0xM2Sm4J6RRKuz79HQgA4Eg18+bqRP7j/itb89DmtXEtoZFAsEJw8IgIfeGGDtHTkfAlAC92mtK8byeaxGq57XCTKbO/r5gcOMElZHy1AcB8kw==')}.should_not raise_error + end + + it "should support a valid key like a 1024 bit dsa key" do + proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody", :key => 'AAAAB3NzaC1kc3MAAACBAI80iR78QCgpO4WabVqHHdEDigOjUEHwIjYHIubR/7u7DYrXY+e+TUmZ0CVGkiwB/0yLHK5dix3Y/bpj8ZiWCIhFeunnXccOdE4rq5sT2V3l1p6WP33RpyVYbLmeuHHl5VQ1CecMlca24nHhKpfh6TO/FIwkMjghHBfJIhXK+0w/AAAAFQDYzLupuMY5uz+GVrcP+Kgd8YqMmwAAAIB3SVN71whLWjFPNTqGyyIlMy50624UfNOaH4REwO+Of3wm/cE6eP8n75vzTwQGBpJX3BPaBGW1S1Zp/DpTOxhCSAwZzAwyf4WgW7YyAOdxN3EwTDJZeyiyjWMAOjW9/AOWt9gtKg0kqaylbMHD4kfiIhBzo31ZY81twUzAfN7angAAAIBfva8sTSDUGKsWWIXkdbVdvM4X14K4gFdy0ZJVzaVOtZ6alysW6UQypnsl6jfnbKvsZ0tFgvcX/CPyqNY/gMR9lyh/TCZ4XQcbqeqYPuceGehz+jL5vArfqsW2fJYFzgCcklmr/VxtP5h6J/T0c9YcDgc/xIfWdZAlznOnphI/FA==')}.should_not raise_error + end + + it "should not support whitespaces" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :key => 'AAA FA==')}.should raise_error(Puppet::Error,/Key must not contain whitespace/) + end + + end + + describe "for options" do + + it "should support flags as options" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'cert-authority')}.should_not raise_error + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'no-port-forwarding')}.should_not raise_error + end + + it "should support key-value pairs as options" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'command="command"')}.should_not raise_error + end + + it "should support environments as options" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'environment="NAME=value"')}.should_not raise_error + end + + it "should support multiple options as an array" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ['cert-authority','environment="NAME=value"'])}.should_not raise_error + end + + it "should not support a comma separated lists" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'cert-authority,no-port-forwarding')}.should raise_error(Puppet::Error, /must be provided as an array/) + end + + it "should use :absent as a default value" do + @class.new(:name => "whev", :type => :rsa, :user => "nobody").should(:options).should == [:absent] + end + + it "property should return well formed string of arrays from is_to_s" do + resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"]) + resource.property(:options).is_to_s(["a","b","c"]).should == "a,b,c" + end + + it "property should return well formed string of arrays from is_to_s" do + resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"]) + resource.property(:options).should_to_s(["a","b","c"]).should == "a,b,c" + end + + end + + describe "for user" do + + it "should support present users" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "root") }.should_not raise_error + end + + it "should support absent users" do + proc { @class.new(:name => "whev", :type => :rsa, :user => "ihopeimabsent") }.should_not raise_error + end + + end + + describe "for target" do + + it "should support absolute paths" do + proc { @class.new(:name => "whev", :type => :rsa, :target => "/tmp/here") }.should_not raise_error + end + + it "should use the user's path if not explicitly specified" do + @class.new(:name => "whev", :user => 'root').should(:target).should == File.expand_path("~root/.ssh/authorized_keys") + end + + it "should not consider the user's path if explicitly specified" do + @class.new(:name => "whev", :user => 'root', :target => '/tmp/here').should(:target).should == '/tmp/here' + end + + it "should inform about an absent user" do + Puppet::Log.level = :debug + @class.new(:name => "whev", :user => 'idontexist').should(:target) + @logs.map(&:message).should include("The required user is not yet present on the system") + end + + end - it "should have a target property" do - @class.attrtype(:target).should == :property end describe "when neither user nor target is specified" do + it "should raise an error" do proc do - - @class.create( - + @class.new( :name => "Test", :key => "AAA", :type => "ssh-rsa", - :ensure => :present) - end.should raise_error(Puppet::Error) + end.should raise_error(Puppet::Error,/user.*or.*target.*mandatory/) end + end describe "when both target and user are specified" do - it "should use target" do - - resource = @class.create( + it "should use target" do + resource = @class.new( :name => "Test", :user => "root", - - :target => "/tmp/blah") + :target => "/tmp/blah" + ) resource.should(:target).should == "/tmp/blah" end + end describe "when user is specified" do - it "should determine target" do + it "should determine target" do resource = @class.create( - :name => "Test", - - :user => "root") + :user => "root" + ) target = File.expand_path("~root/.ssh/authorized_keys") resource.should(:target).should == target end @@ -135,17 +243,19 @@ describe ssh_authorized_key do target = File.expand_path("~root/.ssh/authorized_keys") resource.property(:target).safe_insync?(target).should == true end + end describe "when calling validate" do - it "should not crash on a non-existant user" do + it "should not crash on a non-existant user" do resource = @class.create( - :name => "Test", - - :user => "ihopesuchuserdoesnotexist") + :user => "ihopesuchuserdoesnotexist" + ) proc { resource.validate }.should_not raise_error end + end + end diff --git a/spec/unit/util/autoload_spec.rb b/spec/unit/util/autoload_spec.rb index 6d49b57dc..512f06c75 100755 --- a/spec/unit/util/autoload_spec.rb +++ b/spec/unit/util/autoload_spec.rb @@ -103,14 +103,14 @@ describe Puppet::Util::Autoload do end [RuntimeError, LoadError, SyntaxError].each do |error| - it "should die an if a #{error.to_s} exception is thrown" do + it "should die an if a #{error.to_s} exception is thrown", :'fails_on_ruby_1.9.2' => true do Kernel.expects(:require).raises error lambda { @autoload.loadall }.should raise_error(Puppet::Error) end end - it "should require the full path to the file" do + it "should require the full path to the file", :'fails_on_ruby_1.9.2' => true do Kernel.expects(:require).with("/path/to/file.rb") @autoload.loadall diff --git a/spec/unit/util/cacher_spec.rb b/spec/unit/util/cacher_spec.rb index 2e43b4e20..fe93afd2b 100755 --- a/spec/unit/util/cacher_spec.rb +++ b/spec/unit/util/cacher_spec.rb @@ -42,7 +42,7 @@ describe Puppet::Util::Cacher do Puppet::Util::Cacher.singleton_class.ancestors.should be_include(Puppet::Util::Cacher::Expirer) end - it "should support defining cached attributes" do + it "should support defining cached attributes", :'fails_on_ruby_1.9.2' => true do CacheTest.methods.should be_include("cached_attr") end diff --git a/spec/unit/util/file_locking_spec.rb b/spec/unit/util/file_locking_spec.rb index 261474263..1a12244b8 100755 --- a/spec/unit/util/file_locking_spec.rb +++ b/spec/unit/util/file_locking_spec.rb @@ -16,11 +16,11 @@ describe Puppet::Util::FileLocking do Puppet::Util::FileLocking.should respond_to(:writelock) end - it "should have an instance method for getting a read lock on files" do + it "should have an instance method for getting a read lock on files", :'fails_on_ruby_1.9.2' => true do FileLocker.new.private_methods.should be_include("readlock") end - it "should have an instance method for getting a write lock on files" do + it "should have an instance method for getting a write lock on files", :'fails_on_ruby_1.9.2' => true do FileLocker.new.private_methods.should be_include("writelock") end diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb index 78411d187..1baa0d5af 100755 --- a/spec/unit/util/log_spec.rb +++ b/spec/unit/util/log_spec.rb @@ -93,7 +93,7 @@ describe Puppet::Util::Log do Puppet::Util::Log.new(:level => "notice", :message => :foo).level.should == :notice end - it "should fail if the level is not a symbol or string" do + it "should fail if the level is not a symbol or string", :'fails_on_ruby_1.9.2' => true do lambda { Puppet::Util::Log.new(:level => 50, :message => :foo) }.should raise_error(ArgumentError) end @@ -206,7 +206,7 @@ describe Puppet::Util::Log do end end - describe "to_yaml" do + describe "to_yaml", :'fails_on_ruby_1.9.2' => true do it "should not include the @version attribute" do log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :version => 100) log.to_yaml_properties.should_not include('@version') diff --git a/spec/unit/util/network_device/cisco/device_spec.rb b/spec/unit/util/network_device/cisco/device_spec.rb index 33242a1ab..8971205d3 100755 --- a/spec/unit/util/network_device/cisco/device_spec.rb +++ b/spec/unit/util/network_device/cisco/device_spec.rb @@ -145,7 +145,7 @@ eos "ATM 0/1.1" => "ATM0/1.1", "VLAN99" => "VLAN99" }.each do |input,expected| - it "should canonicalize #{input} to #{expected}" do + it "should canonicalize #{input} to #{expected}", :'fails_on_ruby_1.9.2' => true do @cisco.canonalize_ifname(input).should == expected end end @@ -232,7 +232,7 @@ eos @cisco.parse_interface("FastEthernet0/1").should == { :ensure => :absent, :duplex => :auto, :speed => :auto } end - it "should be able to parse the sh vlan brief command output" do + it "should be able to parse the sh vlan brief command output", :'fails_on_ruby_1.9.2' => true do @cisco.stubs(:support_vlan_brief?).returns(true) @transport.stubs(:command).with("sh vlan brief").returns(<<eos) Switch#sh vlan brief diff --git a/spec/unit/util/network_device/transport/ssh_spec.rb b/spec/unit/util/network_device/transport/ssh_spec.rb index 18d22a953..8fc357db3 100755 --- a/spec/unit/util/network_device/transport/ssh_spec.rb +++ b/spec/unit/util/network_device/transport/ssh_spec.rb @@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/../../../../spec_helper' require 'puppet/util/network_device/transport/ssh' -describe Puppet::Util::NetworkDevice::Transport::Ssh, :if => Puppet.features.ssh? do +describe Puppet::Util::NetworkDevice::Transport::Ssh, :if => Puppet.features.ssh?, :'fails_on_ruby_1.9.2' => true do before(:each) do @transport = Puppet::Util::NetworkDevice::Transport::Ssh.new() diff --git a/spec/unit/util/pson_spec.rb b/spec/unit/util/pson_spec.rb index 63d085a66..9331b9416 100755 --- a/spec/unit/util/pson_spec.rb +++ b/spec/unit/util/pson_spec.rb @@ -7,7 +7,7 @@ class PsonUtil include Puppet::Util::Pson end -describe Puppet::Util::Pson do +describe Puppet::Util::Pson, :'fails_on_ruby_1.9.2' => true do it "should fail if no data is provided" do lambda { PsonUtil.new.pson_create("type" => "foo") }.should raise_error(ArgumentError) end diff --git a/spec/unit/util/queue/stomp_spec.rb b/spec/unit/util/queue/stomp_spec.rb index 99c77d0b4..6799becea 100755 --- a/spec/unit/util/queue/stomp_spec.rb +++ b/spec/unit/util/queue/stomp_spec.rb @@ -2,14 +2,14 @@ require 'spec_helper' require 'puppet/util/queue' -describe Puppet::Util::Queue, :if => Puppet.features.stomp? do +describe Puppet::Util::Queue, :if => Puppet.features.stomp?, :'fails_on_ruby_1.9.2' => true do it 'should load :stomp client appropriately' do Puppet.settings.stubs(:value).returns 'faux_queue_source' Puppet::Util::Queue.queue_type_to_class(:stomp).name.should == 'Puppet::Util::Queue::Stomp' end end -describe 'Puppet::Util::Queue::Stomp', :if => Puppet.features.stomp? do +describe 'Puppet::Util::Queue::Stomp', :if => Puppet.features.stomp?, :'fails_on_ruby_1.9.2' => true do before do # So we make sure we never create a real client instance. # Otherwise we'll try to connect, and that's bad. diff --git a/spec/unit/util/rdoc/parser_spec.rb b/spec/unit/util/rdoc/parser_spec.rb index c7f99051f..92b50e09b 100755 --- a/spec/unit/util/rdoc/parser_spec.rb +++ b/spec/unit/util/rdoc/parser_spec.rb @@ -7,7 +7,7 @@ require 'puppet/util/rdoc/code_objects' require 'rdoc/options' require 'rdoc/rdoc' -describe RDoc::Parser do +describe RDoc::Parser, :'fails_on_ruby_1.9.2' => true do before :each do File.stubs(:stat).with("init.pp") @top_level = stub_everything 'toplevel', :file_relative_name => "init.pp" diff --git a/spec/unit/util/rdoc_spec.rb b/spec/unit/util/rdoc_spec.rb index 067b5b8a7..deae4ef2c 100755 --- a/spec/unit/util/rdoc_spec.rb +++ b/spec/unit/util/rdoc_spec.rb @@ -6,7 +6,7 @@ require 'rdoc/rdoc' describe Puppet::Util::RDoc do - describe "when generating RDoc HTML documentation" do + describe "when generating RDoc HTML documentation", :'fails_on_ruby_1.9.2' => true do before :each do @rdoc = stub_everything 'rdoc' RDoc::RDoc.stubs(:new).returns(@rdoc) diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb index 0eaf43cbb..cc70b53c4 100755 --- a/spec/unit/util/selinux_spec.rb +++ b/spec/unit/util/selinux_spec.rb @@ -33,7 +33,7 @@ describe Puppet::Util::SELinux do end end - describe "filesystem detection" do + describe "filesystem detection", :'fails_on_ruby_1.9.2' => true do before :each do fh = stub 'fh', :close => nil File.stubs(:open).with("/proc/mounts").returns fh @@ -192,7 +192,7 @@ describe Puppet::Util::SELinux do end end - describe "set_selinux_context" do + describe "set_selinux_context", :'fails_on_ruby_1.9.2' => true do before :each do fh = stub 'fh', :close => nil File.stubs(:open).with("/proc/mounts").returns fh |