summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-03-01 13:00:11 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-03-12 10:15:43 +0100
commitecd437368cb5193347fc0d5b4dc2f84261b2eef3 (patch)
tree4b0e7ae59aaa243e14bf1390d74f5ea3f409412f
parente49c588a33eb391b0c5f098ec2cf1352954015ec (diff)
downloadbundler-ecd437368cb5193347fc0d5b4dc2f84261b2eef3.tar.gz
Rework DSL specs and enable them in bundler 2
To make sure all cases are covered.
-rw-r--r--spec/bundler/dsl_spec.rb66
1 files changed, 50 insertions, 16 deletions
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb
index c4cf72b53e..2a4a198d24 100644
--- a/spec/bundler/dsl_spec.rb
+++ b/spec/bundler/dsl_spec.rb
@@ -32,20 +32,47 @@ RSpec.describe Bundler::Dsl do
end
end
- context "default hosts (git, gist)", :bundler => "< 2" do
- context "when github.https config is true" do
- before { bundle "config set github.https true" }
- it "converts :github to :git using https" do
- subject.gem("sparks", :github => "indirect/sparks")
- github_uri = "https://github.com/indirect/sparks.git"
+ shared_examples_for "the github DSL" do |protocol|
+ context "when full repo is used" do
+ let(:repo) { "indirect/sparks" }
+
+ it "converts :github to URI using #{protocol}" do
+ subject.gem("sparks", :github => repo)
+ github_uri = "#{protocol}://github.com/#{repo}.git"
expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
end
- it "converts :github to :git" do
- subject.gem("sparks", :github => "indirect/sparks")
- github_uri = "git://github.com/indirect/sparks.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
+ context "when shortcut repo is used" do
+ let(:repo) { "rails" }
+
+ it "converts :github to URI using #{protocol}" do
+ subject.gem("sparks", :github => repo)
+ github_uri = "#{protocol}://github.com/#{repo}/#{repo}.git"
+ expect(subject.dependencies.first.source.uri).to eq(github_uri)
+ end
+ end
+ end
+
+ context "default hosts (git, gist)" do
+ context "when github.https config is true" do
+ before { bundle "config set github.https true" }
+
+ it_behaves_like "the github DSL", "https"
+ end
+
+ context "when github.https config is false" do
+ before { bundle "config set github.https false" }
+
+ it_behaves_like "the github DSL", "git"
+ end
+
+ context "by default", :bundler => "< 2" do
+ it_behaves_like "the github DSL", "git"
+ end
+
+ context "by default", :bundler => "2" do
+ it_behaves_like "the github DSL", "https"
end
it "converts numeric :gist to :git" do
@@ -60,12 +87,6 @@ RSpec.describe Bundler::Dsl do
expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
- it "converts 'rails' to 'rails/rails'" do
- subject.gem("rails", :github => "rails")
- github_uri = "git://github.com/rails/rails.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
- end
-
it "converts :bitbucket to :git" do
subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails")
bitbucket_uri = "https://mcorp@bitbucket.org/mcorp/flatlab-rails.git"
@@ -258,6 +279,19 @@ RSpec.describe Bundler::Dsl do
end
end
+ describe "#github", :bundler => "2" do
+ it "from github" do
+ spree_gems = %w[spree_core spree_api spree_backend]
+ subject.github "spree" do
+ spree_gems.each {|spree_gem| subject.send :gem, spree_gem }
+ end
+
+ subject.dependencies.each do |d|
+ expect(d.source.uri).to eq("https://github.com/spree/spree.git")
+ end
+ end
+ end
+
describe "#github", :bundler => "3" do
it "from github" do
expect do