Sha256: 7e282553856a2e67b3000b0a3dd7c07a5246a931370b0a7adba41b7419b7940f

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

# 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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bundler-1.5.2 spec/bundler/safe_catch_spec.rb
bundler-1.5.1 spec/bundler/safe_catch_spec.rb
bundler-1.5.0 spec/bundler/safe_catch_spec.rb
bundler-1.5.0.rc.2 spec/bundler/safe_catch_spec.rb
bundler-1.5.0.rc.1 spec/bundler/safe_catch_spec.rb
bundler-1.4.0.rc.1 spec/bundler/safe_catch_spec.rb
bundler-1.4.0.pre.2 spec/bundler/safe_catch_spec.rb
bundler-1.4.0.pre.1 spec/bundler/safe_catch_spec.rb