diff options
Diffstat (limited to 'lib/puppet/util/monkey_patches.rb')
-rw-r--r-- | lib/puppet/util/monkey_patches.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/puppet/util/monkey_patches.rb b/lib/puppet/util/monkey_patches.rb index 1c35ae523..a93c66b07 100644 --- a/lib/puppet/util/monkey_patches.rb +++ b/lib/puppet/util/monkey_patches.rb @@ -21,6 +21,9 @@ class Symbol z.emit("!ruby/sym ") to_s.to_zaml(z) end + def <=> (other) + self.to_s <=> other.to_s + end end [Object, Exception, Integer, Struct, Date, Time, Range, Regexp, Hash, Array, Float, String, FalseClass, TrueClass, Symbol, NilClass, Class].each { |cls| @@ -48,7 +51,6 @@ if RUBY_VERSION == '1.8.7' end end - class Object # ActiveSupport 2.3.x mixes in a dangerous method # that can cause rspec to fork bomb @@ -56,6 +58,23 @@ class Object def daemonize raise NotImplementedError, "Kernel.daemonize is too dangerous, please don't try to use it." end + + # The following code allows callers to make assertions that are only + # checked when the environment variable PUPPET_ENABLE_ASSERTIONS is + # set to a non-empty string. For example: + # + # assert_that { condition } + # assert_that(message) { condition } + if ENV["PUPPET_ENABLE_ASSERTIONS"].to_s != '' + def assert_that(message = nil) + unless yield + raise Exception.new("Assertion failure: #{message}") + end + end + else + def assert_that(message = nil) + end + end end # Workaround for yaml_initialize, which isn't supported before Ruby |