aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorHemant Kumar <gethemant@gmail.com>2013-07-22 09:36:38 +0530
committerHemant Kumar <gethemant@gmail.com>2013-07-22 09:36:38 +0530
commit0931feeec3b0f314f4d76720a7f04ccf8829c334 (patch)
tree57e660cab1fb6ac6f07a34dfd3e54161ab016b95 /spec
parent9187a2707878abd15a74fe09f1722ca0f8929724 (diff)
downloadbundler-0931feeec3b0f314f4d76720a7f04ccf8829c334.tar.gz
Add specs for safe_catch
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/safe_catch_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/bundler/safe_catch_spec.rb b/spec/bundler/safe_catch_spec.rb
new file mode 100644
index 00000000..40b6ec09
--- /dev/null
+++ b/spec/bundler/safe_catch_spec.rb
@@ -0,0 +1,37 @@
+# encoding: utf-8
+require 'spec_helper'
+require 'bundler'
+require "bundler/safe_catch"
+require "bundler/current_ruby"
+
+class RecursiveTmpResolver
+ include Bundler::SafeCatch
+end
+
+describe Bundler::SafeCatch do
+ let(:resolver) { RecursiveTmpResolver.new() }
+
+ it "should use safe_catch on jruby" do
+ if Bundler.current_ruby.jruby?
+ Bundler::SafeCatch::Internal.should_receive(:catch).and_call_original
+ Bundler::SafeCatch::Internal.should_receive(:throw).and_call_original
+
+ retval = resolver.safe_catch(:resolve) do
+ resolver.safe_throw(:resolve, "good bye world")
+ end
+ expect(retval).to eq("good bye world")
+ end
+ end
+
+ it "should use regular catch/throw on MRI" do
+ if Bundler.current_ruby.mri?
+ Bundler::SafeCatch::Internal.should_not_receive(:catch)
+ Bundler::SafeCatch::Internal.should_not_receive(:throw)
+
+ retval = resolver.safe_catch(:resolve) do
+ resolver.safe_throw(:resolve, "good bye world")
+ end
+ expect(retval).to eq("good bye world")
+ end
+ end
+end