aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/lib')
-rw-r--r--actionpack/test/lib/testing_sandbox.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/test/lib/testing_sandbox.rb b/actionpack/test/lib/testing_sandbox.rb
new file mode 100644
index 0000000000..c36585104f
--- /dev/null
+++ b/actionpack/test/lib/testing_sandbox.rb
@@ -0,0 +1,15 @@
+module TestingSandbox
+ # Temporarily replaces KCODE for the block
+ def with_kcode(kcode)
+ if RUBY_VERSION < '1.9'
+ old_kcode, $KCODE = $KCODE, kcode
+ begin
+ yield
+ ensure
+ $KCODE = old_kcode
+ end
+ else
+ yield
+ end
+ end
+end