summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Arko <mail@arko.net>2015-09-12 02:21:44 -0700
committerAndré Arko <mail@arko.net>2015-09-12 02:21:44 -0700
commit59529ead038e2f27ae91d63716eba80e8fa18e0f (patch)
treece9841015b99835eebbb01d9ef171a1d9b5fb94a
parent1131091bbe0c300ccc69c2cec0ff6be398af57bf (diff)
parent2d86ea2efe0c03940f4e46b1fb90490c7152ad87 (diff)
downloadbundler-59529ead038e2f27ae91d63716eba80e8fa18e0f.tar.gz
Merge pull request #3979 from bundler/backport-3978
Dsl#with_source should restore the previous source
-rw-r--r--lib/bundler/dsl.rb3
-rw-r--r--spec/bundler/dsl_spec.rb16
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index e5432fa467..56355d321a 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -226,13 +226,14 @@ module Bundler
end
def with_source(source)
+ old_source = @source
if block_given?
@source = source
yield
end
source
ensure
- @source = nil
+ @source = old_source
end
def normalize_hash(opts)
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb
index 5b4a52f8d3..1a0264368c 100644
--- a/spec/bundler/dsl_spec.rb
+++ b/spec/bundler/dsl_spec.rb
@@ -188,4 +188,20 @@ describe Bundler::Dsl do
end
end
+ describe "#with_source" do
+ context "if there was a rubygem source already defined" do
+ it "restores it after it's done" do
+ other_source = double("other-source")
+ allow(Bundler::Source::Rubygems).to receive(:new).and_return(other_source)
+
+ subject.source("https://other-source.org") do
+ subject.gem("dobry-pies", :path => "foo")
+ subject.gem("foo")
+ end
+
+ expect(subject.dependencies.last.source).to eq(other_source)
+ end
+ end
+ end
+
end