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 | 30 | ||||
| -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/util/backups_spec.rb | 1 |
9 files changed, 27 insertions, 38 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..ab7ff6caf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,20 +6,8 @@ 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 - -require 'puppettest' -require 'puppettest/runnable_test' +require 'puppet' require 'mocha' gem 'rspec', '>=1.2.9' require 'spec/autorun' @@ -29,17 +17,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 +72,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/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/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 |
