summaryrefslogtreecommitdiffstats
path: root/test/lib/spec/runner/extensions
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-17 02:48:41 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-17 02:48:41 +0000
commitba23a5ac276e59fdda8186750c6d0fd2cfecdeac (patch)
tree1e14b25ade74ea52d8da2788ede9b12b507867e8 /test/lib/spec/runner/extensions
parent8ea6adaeb1e3d0aa6348c2a2c3a385d185372d06 (diff)
Adding spec libs, so we can use them some day
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2283 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/lib/spec/runner/extensions')
-rw-r--r--test/lib/spec/runner/extensions/kernel.rb17
-rw-r--r--test/lib/spec/runner/extensions/object.rb32
2 files changed, 49 insertions, 0 deletions
diff --git a/test/lib/spec/runner/extensions/kernel.rb b/test/lib/spec/runner/extensions/kernel.rb
new file mode 100644
index 000000000..f060ec859
--- /dev/null
+++ b/test/lib/spec/runner/extensions/kernel.rb
@@ -0,0 +1,17 @@
+module Kernel
+ def context(name, &block)
+ context = Spec::Runner::Context.new(name, &block)
+ context_runner.add_context(context)
+ end
+
+private
+
+ def context_runner
+ # TODO: Figure out a better way to get this considered "covered" and keep this statement on multiple lines
+ unless $context_runner; \
+ $context_runner = ::Spec::Runner::OptionParser.new.create_context_runner(ARGV.dup, STDERR, STDOUT, false); \
+ at_exit { $context_runner.run(false) }; \
+ end
+ $context_runner
+ end
+end
diff --git a/test/lib/spec/runner/extensions/object.rb b/test/lib/spec/runner/extensions/object.rb
new file mode 100644
index 000000000..49745352f
--- /dev/null
+++ b/test/lib/spec/runner/extensions/object.rb
@@ -0,0 +1,32 @@
+# The following copyright applies to Object#copy_instance_variables_from,
+# which we borrowed from active_support.
+#
+# Copyright (c) 2004 David Heinemeier Hansson
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+class Object
+ # From active_support
+ def copy_instance_variables_from(object, exclude = []) # :nodoc:
+ exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables
+
+ instance_variables = object.instance_variables - exclude.map { |name| name.to_s }
+ instance_variables.each { |name| instance_variable_set(name, object.instance_variable_get(name)) }
+ end
+end