[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Daniel Pittman
daniel at rimspace.net
Tue May 10 08:05:40 UTC 2011
The following commit has been merged in the experimental branch:
commit 6b8f1b724d08e62af6fcf6a2ea55d72b74876de3
Author: Daniel Pittman <daniel at rimspace.net>
Date: Wed Mar 2 21:54:40 2011 -0800
(#6582) add fixture helper methods to replace unit test code.
We validate that fixtures exist, when requested, or that they match something
when they use a glob. This catches internal errors where we don't match any
fixtures with a glob; this can reveal problems that would otherwise avoid all
assertions and result in internal failures.
The code is hidden out in a module, included in the main RSpec namespace.
This doesn't clean up the API any, but it isolates the code more effectively
and keeps the configuration file cleaner.
Reviewed-By: Nick Lewis <nick at puppetlabs.com>
diff --git a/spec/lib/puppet_spec/fixtures.rb b/spec/lib/puppet_spec/fixtures.rb
new file mode 100644
index 0000000..96bb1e3
--- /dev/null
+++ b/spec/lib/puppet_spec/fixtures.rb
@@ -0,0 +1,28 @@
+module PuppetSpec::Fixtures
+ def fixtures(*rest)
+ File.join(PuppetSpec::FIXTURE_DIR, *rest)
+ end
+ def my_fixture_dir
+ callers = caller
+ while line = callers.shift do
+ next unless found = line.match(%r{puppet/spec/(.*)_spec\.rb:})
+ return fixtures(found[1])
+ end
+ fail "sorry, I couldn't work out your path from the caller stack!"
+ end
+ def my_fixture(name)
+ file = File.join(my_fixture_dir, name)
+ unless File.readable? file then
+ fail Puppet::DevError, "fixture '#{name}' for #{my_fixture_dir} is not readable"
+ end
+ return file
+ end
+ def my_fixtures(glob = '*', flags = 0)
+ files = Dir.glob(File.join(my_fixture_dir, glob), flags)
+ unless files.length > 0 then
+ fail Puppet::DevError, "fixture '#{glob}' for #{my_fixture_dir} had no files!"
+ end
+ block_given? and files.each do |file| yield file end
+ files
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index feb8928..cf5f39b 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -24,10 +24,13 @@ module PuppetTest
end
require 'lib/puppet_spec/files'
+require 'lib/puppet_spec/fixtures'
require 'monkey_patches/alias_should_to_must'
require 'monkey_patches/publicize_methods'
RSpec.configure do |config|
+ include PuppetSpec::Fixtures
+
config.mock_with :mocha
config.before :each do
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list