diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-08-20 02:28:33 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-08-20 02:28:33 +0000 |
| commit | b2031aa32995331474244150bbc97f467e3ada7b (patch) | |
| tree | 1d7beabef0b5f34716a11f3c0c2916036fbbcd2a /test/util/classgen.rb | |
| parent | beba3e480c7ad7f942414a8aa31f96b5b42b53e4 (diff) | |
| download | puppet-b2031aa32995331474244150bbc97f467e3ada7b.tar.gz puppet-b2031aa32995331474244150bbc97f467e3ada7b.tar.xz puppet-b2031aa32995331474244150bbc97f467e3ada7b.zip | |
Making some of the metaprogramming a bit more explicit and a bit easier to manage. In the process, I have created multiple Util modules, only one of which is used for this current commit.
The main work in this commit is that I created a single, common method for dynamically creating classes and moved all of the Class.new users to using this class. It handles a lot of the complexity for me, and most of the users have just a couple of lines of code, now, instead of tens.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1473 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/util/classgen.rb')
| -rwxr-xr-x | test/util/classgen.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/util/classgen.rb b/test/util/classgen.rb new file mode 100755 index 000000000..2fdcf5d6a --- /dev/null +++ b/test/util/classgen.rb @@ -0,0 +1,43 @@ +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $puppetbase = ".." +end + +require 'puppet' +require 'puppettest' +require 'test/unit' + +class TestPuppetUtilClassGen < Test::Unit::TestCase + include TestPuppet + + class FakeBase + end + + class GenTest + class << self + include Puppet::Util::ClassGen + end + end + + def test_genclass + hash = {} + + name = "yayness" + klass = nil + assert_nothing_raised { + klass = GenTest.genclass(name, :hash => hash, :parent => FakeBase) do + class << self + attr_accessor :name + end + end + } + + assert(klass.respond_to?(:name), "Class did not execute block") + + assert(hash.include?(klass.name), + "Class did not get added to hash") + end +end + +# $Id$ |
