diff options
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/integration/provider/mailalias/aliases_spec.rb | 10 | ||||
-rw-r--r-- | spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb | 1 | ||||
-rw-r--r-- | spec/monkey_patches/publicize_methods.rb | 11 | ||||
-rw-r--r-- | spec/spec_helper.rb | 31 | ||||
-rwxr-xr-x | spec/unit/application/apply_spec.rb | 2 | ||||
-rwxr-xr-x | spec/unit/application/cert_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/application/master_spec.rb | 2 | ||||
-rwxr-xr-x | spec/unit/network/http/webrick/rest_spec.rb | 1 | ||||
-rwxr-xr-x | spec/unit/parser/lexer_spec.rb | 1 | ||||
-rwxr-xr-x | spec/unit/provider/ssh_authorized_key/parsed_spec.rb | 6 | ||||
-rwxr-xr-x | spec/unit/reports/tagmail_spec.rb | 4 | ||||
-rwxr-xr-x | spec/unit/type/file/content_spec.rb | 1 | ||||
-rwxr-xr-x | spec/unit/util/backups_spec.rb | 1 |
13 files changed, 33 insertions, 40 deletions
diff --git a/spec/integration/provider/mailalias/aliases_spec.rb b/spec/integration/provider/mailalias/aliases_spec.rb index 8106c2cb5..0511205f2 100755 --- a/spec/integration/provider/mailalias/aliases_spec.rb +++ b/spec/integration/provider/mailalias/aliases_spec.rb @@ -2,7 +2,6 @@ require File.dirname(__FILE__) + '/../../../spec_helper' -require 'puppettest' require 'puppettest/support/utils' require 'puppettest/fileparsing' @@ -11,15 +10,16 @@ provider_class = Puppet::Type.type(:mailalias).provider(:aliases) describe provider_class do include PuppetTest include PuppetTest::FileParsing + include PuppetTest::Support::Utils before :each do @provider = provider_class end # #1560 - PuppetTest.fakedata("data/providers/mailalias/aliases").each { |file| - it "should be able to parse the examples in #{file}" do + it "should be able to parse the mailalias examples" do + fakedata("data/providers/mailalias/aliases").each { |file| fakedataparse(file) - end - } + } + end end diff --git a/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb b/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb index 15a7cd0ac..3762b7033 100644 --- a/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +++ b/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb @@ -5,7 +5,6 @@ dir = File.expand_path(File.dirname(__FILE__)) end require 'spec' -require 'puppettest' require 'puppettest/runnable_test' module Spec diff --git a/spec/monkey_patches/publicize_methods.rb b/spec/monkey_patches/publicize_methods.rb new file mode 100644 index 000000000..b39e9c002 --- /dev/null +++ b/spec/monkey_patches/publicize_methods.rb @@ -0,0 +1,11 @@ +# Some monkey-patching to allow us to test private methods. +class Class + def publicize_methods(*methods) + saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods + + self.class_eval { public(*saved_private_instance_methods) } + yield + self.class_eval { private(*saved_private_instance_methods) } + end +end + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 539ae2040..2fe0c36a3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,20 +6,11 @@ dir = File.expand_path(File.dirname(__FILE__)) $LOAD_PATH.unshift("#{dir}/") $LOAD_PATH.unshift("#{dir}/lib") # a spec-specific test lib dir $LOAD_PATH.unshift("#{dir}/../lib") -$LOAD_PATH.unshift("#{dir}/../test/lib") # Add the old test dir, so that we can still find our local mocha and spec -# include any gems in vendor/gems -Dir["#{dir}/../vendor/gems/**"].each do |path| - libpath = File.join(path, "lib") - if File.directory?(libpath) - $LOAD_PATH.unshift(libpath) - else - $LOAD_PATH.unshift(path) - end -end +# Don't want puppet getting the command line arguments for rake or autotest +ARGV.clear -require 'puppettest' -require 'puppettest/runnable_test' +require 'puppet' require 'mocha' gem 'rspec', '>=1.2.9' require 'spec/autorun' @@ -29,17 +20,13 @@ module PuppetSpec FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR) end -# load any monkey-patches -Dir["#{dir}/monkey_patches/*.rb"].map { |file| require file } +require 'monkey_patches/alias_should_to_must' +require 'monkey_patches/add_confine_and_runnable_to_rspec_dsl' +require 'monkey_patches/publicize_methods' Spec::Runner.configure do |config| config.mock_with :mocha -# config.prepend_before :all do -# setup_mocks_for_rspec -# setup if respond_to? :setup -# end -# config.prepend_after :each do Puppet.settings.clear Puppet::Node::Environment.clear @@ -88,10 +75,4 @@ Spec::Runner.configure do |config| end end -# We need this because the RAL uses 'should' as a method. This -# allows us the same behaviour but with a different method name. -class Object - alias :must :should -end - end diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb index 8c53136d0..85098f490 100755 --- a/spec/unit/application/apply_spec.rb +++ b/spec/unit/application/apply_spec.rb @@ -312,7 +312,7 @@ describe Puppet::Application::Apply do end it "should apply the catalog" do - @catalog.expects(:apply) + @catalog.expects(:apply).returns(stub_everything 'transaction') @apply.main end diff --git a/spec/unit/application/cert_spec.rb b/spec/unit/application/cert_spec.rb index b82a2fe89..4663fc938 100755 --- a/spec/unit/application/cert_spec.rb +++ b/spec/unit/application/cert_spec.rb @@ -12,7 +12,7 @@ describe Puppet::Application::Cert do end it "should operate in master run_mode" do - @cert_app.class.run_mode.name.should equal :master + @cert_app.class.run_mode.name.should equal(:master) end it "should ask Puppet::Application to parse Puppet configuration file" do diff --git a/spec/unit/application/master_spec.rb b/spec/unit/application/master_spec.rb index 0baa8229b..216c7dc90 100644 --- a/spec/unit/application/master_spec.rb +++ b/spec/unit/application/master_spec.rb @@ -23,7 +23,7 @@ describe Puppet::Application::Master do end it "should operate in master run_mode" do - @master.class.run_mode.name.should equal :master + @master.class.run_mode.name.should equal(:master) end it "should ask Puppet::Application to parse Puppet configuration file" do diff --git a/spec/unit/network/http/webrick/rest_spec.rb b/spec/unit/network/http/webrick/rest_spec.rb index aa2b93176..b00c62dc4 100755 --- a/spec/unit/network/http/webrick/rest_spec.rb +++ b/spec/unit/network/http/webrick/rest_spec.rb @@ -2,6 +2,7 @@ require File.dirname(__FILE__) + '/../../../../spec_helper' require 'puppet/network/http' +require 'webrick' require 'puppet/network/http/webrick/rest' describe Puppet::Network::HTTP::WEBrickREST do diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb index 7e51423f4..b27980bf2 100755 --- a/spec/unit/parser/lexer_spec.rb +++ b/spec/unit/parser/lexer_spec.rb @@ -644,7 +644,6 @@ end require 'puppettest/support/utils' describe "Puppet::Parser::Lexer in the old tests when lexing example files" do - extend PuppetTest extend PuppetTest::Support::Utils textfiles do |file| it "should correctly lex #{file}" do diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb index 059d010bb..648527924 100755 --- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb @@ -3,14 +3,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper' require 'puppet_spec/files' -require 'puppettest' require 'puppettest/support/utils' require 'puppettest/fileparsing' +require 'tmpdir' +require 'puppettest/fakes' provider_class = Puppet::Type.type(:ssh_authorized_key).provider(:parsed) describe provider_class do include PuppetSpec::Files + extend PuppetTest::Support::Utils include PuppetTest include PuppetTest::FileParsing @@ -49,7 +51,7 @@ describe provider_class do @provider.target_object(@keyfile).read end - PuppetTest.fakedata("data/providers/ssh_authorized_key/parsed").each { |file| + fakedata("data/providers/ssh_authorized_key/parsed").each { |file| it "should be able to parse example data in #{file}" do fakedataparse(file) end diff --git a/spec/unit/reports/tagmail_spec.rb b/spec/unit/reports/tagmail_spec.rb index 4349e999d..59cb5b2b8 100755 --- a/spec/unit/reports/tagmail_spec.rb +++ b/spec/unit/reports/tagmail_spec.rb @@ -3,12 +3,12 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } require 'puppet/reports' -require 'puppettest' +require 'puppettest/support/utils' tagmail = Puppet::Reports.report(:tagmail) describe tagmail do - extend PuppetTest + extend PuppetTest::Support::Utils before do @processor = Puppet::Transaction::Report.new diff --git a/spec/unit/type/file/content_spec.rb b/spec/unit/type/file/content_spec.rb index a01a14a59..cde643fc8 100755 --- a/spec/unit/type/file/content_spec.rb +++ b/spec/unit/type/file/content_spec.rb @@ -6,6 +6,7 @@ content = Puppet::Type.type(:file).attrclass(:content) describe content do before do @resource = Puppet::Type.type(:file).new :path => "/foo/bar" + content.stubs(:standalone?).returns(false) end it "should be a subclass of Property" do diff --git a/spec/unit/util/backups_spec.rb b/spec/unit/util/backups_spec.rb index 5c10d4c3c..259b18652 100755 --- a/spec/unit/util/backups_spec.rb +++ b/spec/unit/util/backups_spec.rb @@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/util/backups' -include PuppetTest describe Puppet::Util::Backups do before do |