]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - 3rdparty/modules/stdlib/spec/monkey_patches/publicize_methods.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / monkey_patches / publicize_methods.rb
diff --git a/3rdparty/modules/stdlib/spec/monkey_patches/publicize_methods.rb b/3rdparty/modules/stdlib/spec/monkey_patches/publicize_methods.rb
new file mode 100755 (executable)
index 0000000..3ae59f9
--- /dev/null
@@ -0,0 +1,11 @@
+#! /usr/bin/env ruby -S rspec
+# Some monkey-patching to allow us to test private methods.
+class Class
+    def publicize_methods(*methods)
+        saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods
+
+        self.class_eval { public(*saved_private_instance_methods) }
+        yield
+        self.class_eval { private(*saved_private_instance_methods) }
+    end
+end