diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-29 17:19:17 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-29 17:19:17 +0000 |
commit | 17306c01d4b608247cc76af0548a223119beac9a (patch) | |
tree | 3734c3594c67e8f8572508b8320434b5850786ba /test/other | |
parent | 96f91f6856a60492e38427234acdf756f5825ab5 (diff) | |
download | puppet-17306c01d4b608247cc76af0548a223119beac9a.tar.gz puppet-17306c01d4b608247cc76af0548a223119beac9a.tar.xz puppet-17306c01d4b608247cc76af0548a223119beac9a.zip |
Features now load dynamically using method_missing, so that undefined features never throw errors.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1987 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/other')
-rwxr-xr-x | test/other/features.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/other/features.rb b/test/other/features.rb index 2ae623335..1758de783 100755 --- a/test/other/features.rb +++ b/test/other/features.rb @@ -55,6 +55,40 @@ class TestFeatures < Test::Unit::TestCase assert(! @features.missing?, "Missing lib was considered true") end + + def test_dynamic_loading + # Make sure it defaults to false + assert_nothing_raised("Undefined features throw an exception") do + assert(! @features.nosuchfeature?, "missing feature returned true") + end + + $features = @features + cleanup { $features = nil } + # Now create a feature and make sure it loads. + Dir.mkdir(@features.path) + nope = File.join(@features.path, "nope.rb") + File.open(nope, "w") { |f| + f.puts "$features.add(:nope, :libs => %w{nosuchlib})" + } + assert_nothing_raised("Failed to autoload features") do + assert(! @features.nope?, "'nope' returned true") + end + + # First make sure "yep?" returns false + assert_nothing_raised("Missing feature threw an exception") do + assert(! @features.yep?, "'yep' returned true before definition") + end + + yep = File.join(@features.path, "yep.rb") + File.open(yep, "w") { |f| + f.puts "$features.add(:yep, :libs => %w{puppet})" + } + + # Now make sure the value is not cached or anything. + assert_nothing_raised("Failed to autoload features") do + assert(@features.yep?, "'yep' returned false") + end + end end # $Id$ |