From 922d514c7bcd56a3506c83a63476ba86b092b4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 1 Mar 2019 13:00:11 +0100 Subject: Rework DSL specs and enable them in bundler 2 To make sure all cases are covered. --- spec/bundler/dsl_spec.rb | 66 ++++++++++++++++++++++++++++++++++++------------ 1 file 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 -- cgit v1.2.1