Skip to content

Commit

Permalink
specs: check :branch for local overrides on runtime
Browse files Browse the repository at this point in the history
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
  • Loading branch information
dlee authored and José Valim committed Jun 14, 2012
1 parent 723330b commit a8128bf
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 5 deletions.
10 changes: 5 additions & 5 deletions spec/install/git_spec.rb
Expand Up @@ -156,7 +156,7 @@
end
end

describe "when specifying local" do
describe "when specifying local override" do
it "uses the local repository instead of checking a new one out" do
# We don't generate it because we actually don't need it
# build_git "rack", "0.8"
Expand Down Expand Up @@ -241,7 +241,7 @@
lockfile1.should_not == lockfile0
end

it "explodes if given path does not exist" do
it "explodes if given path does not exist on install" do
build_git "rack", "0.8"

install_gemfile <<-G
Expand All @@ -254,7 +254,7 @@
out.should =~ /Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/
end

it "explodes if branch is not given" do
it "explodes if branch is not given on install" do
build_git "rack", "0.8"
FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))

Expand Down Expand Up @@ -283,7 +283,7 @@
out.should =~ /Your bundle is complete!/
end

it "explodes on different branches" do
it "explodes on different branches on install" do
build_git "rack", "0.8"

FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))
Expand All @@ -302,7 +302,7 @@
out.should =~ /is using branch another but Gemfile specifies master/
end

it "explodes on invalid revision" do
it "explodes on invalid revision on install" do
build_git "rack", "0.8"

build_git "rack", "0.8", :path => lib_path('local-rack') do |s|
Expand Down
87 changes: 87 additions & 0 deletions spec/runtime/setup_spec.rb
Expand Up @@ -374,6 +374,93 @@
end
end

describe "when specifying local override" do
it "explodes if given path does not exist on runtime" do
build_git "rack", "0.8"

FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))

gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
G

bundle %|config local.rack #{lib_path('local-rack')}|
bundle :install
out.should =~ /at #{lib_path('local-rack')}/

FileUtils.rm_rf(lib_path('local-rack'))
run "require 'rack'"
err.should =~ /Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/
end

it "explodes if branch is not given on runtime" do
build_git "rack", "0.8"

FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))

gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
G

bundle %|config local.rack #{lib_path('local-rack')}|
bundle :install
out.should =~ /at #{lib_path('local-rack')}/

gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", :git => "#{lib_path('rack-0.8')}"
G

run "require 'rack'"
err.should =~ /because :branch is not specified in Gemfile/
end

it "explodes on different branches on runtime" do
build_git "rack", "0.8"

FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))

gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
G

bundle %|config local.rack #{lib_path('local-rack')}|
bundle :install
out.should =~ /at #{lib_path('local-rack')}/

gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "changed"
G

run "require 'rack'"
err.should =~ /is using branch master but Gemfile specifies changed/
end

it "explodes on refs with different branches on runtime" do
build_git "rack", "0.8"

FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))

install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", :git => "#{lib_path('rack-0.8')}", :ref => "master", :branch => "master"
G

gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", :git => "#{lib_path('rack-0.8')}", :ref => "master", :branch => "nonexistant"
G

bundle %|config local.rack #{lib_path('local-rack')}|
run "require 'rack'"
err.should =~ /is using branch master but Gemfile specifies nonexistant/
end
end

describe "when excluding groups" do
it "doesn't change the resolve if --without is used" do
install_gemfile <<-G, :without => :rails
Expand Down

0 comments on commit a8128bf

Please sign in to comment.