diff options
author | Matt Robinson <matt@puppetlabs.com> | 2010-06-04 11:05:09 -0700 |
---|---|---|
committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
commit | b5f14c6eeaaf8cc70287f3b1b2f74441157ac4b6 (patch) | |
tree | d7382c9aab6a99014cc28d512b8e8d04e551c566 /test | |
parent | 2b5bd4927569c0a87ea32628cdc4303ff1e83853 (diff) | |
download | puppet-b5f14c6eeaaf8cc70287f3b1b2f74441157ac4b6.tar.gz puppet-b5f14c6eeaaf8cc70287f3b1b2f74441157ac4b6.tar.xz puppet-b5f14c6eeaaf8cc70287f3b1b2f74441157ac4b6.zip |
{#3866] Rename the method metaclass to singleton_class to avoid the deprecation warnings from Rails ActiveSupport
The metaid.rb file came straight from why the lucky stiff's "seeing
metaclasses clearly" article. Rails used this too, but they recently
deprecated the name metaclass in favor of singleton_class to match what
ruby-core decided to do. meta, eigen and singlton class were all
suggested and in the end singleton was agreed upon.
http://redmine.ruby-lang.org/issues/show/1082
Diffstat (limited to 'test')
-rwxr-xr-x | test/language/scope.rb | 48 | ||||
-rwxr-xr-x | test/network/server/mongrel_test.rb | 2 |
2 files changed, 49 insertions, 1 deletions
diff --git a/test/language/scope.rb b/test/language/scope.rb index 0bed35c14..282a01b1d 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -228,6 +228,54 @@ Host <<||>>" "Did not add extra namespace correctly") end + def test_find_hostclass_and_find_definition + parser = mkparser + + # Make sure our scope calls the parser find_hostclass method with + # the right namespaces + scope = mkscope :parser => parser + + parser.singleton_class.send(:attr_accessor, :last) + + methods = [:find_hostclass, :find_definition] + methods.each do |m| + parser.meta_def(m) do |namespace, name| + @checked ||= [] + @checked << [namespace, name] + + # Only return a value on the last call. + if @last == namespace + ret = @checked.dup + @checked.clear + return ret + else + return nil + end + end + end + + test = proc do |should| + parser.last = scope.namespaces[-1] + methods.each do |method| + result = scope.send(method, "testing") + assert_equal(should, result, + "did not get correct value from %s with namespaces %s" % + [method, scope.namespaces.inspect]) + end + end + + # Start with the empty namespace + assert_nothing_raised { test.call([["", "testing"]]) } + + # Now add a namespace + scope.add_namespace("a") + assert_nothing_raised { test.call([["a", "testing"]]) } + + # And another + scope.add_namespace("b") + assert_nothing_raised { test.call([["a", "testing"], ["b", "testing"]]) } + end + # #629 - undef should be "" or :undef def test_lookupvar_with_undef scope = mkscope diff --git a/test/network/server/mongrel_test.rb b/test/network/server/mongrel_test.rb index 54bfb3978..4414097ab 100755 --- a/test/network/server/mongrel_test.rb +++ b/test/network/server/mongrel_test.rb @@ -18,7 +18,7 @@ class TestMongrelServer < PuppetTest::TestCase # Make sure client info is correctly extracted. def test_client_info obj = Object.new - obj.metaclass.send(:attr_accessor, :params) + obj.singleton_class.send(:attr_accessor, :params) params = {} obj.params = params |