Permalink
Browse files

specs: check :branch for local overrides on runtime

  • Loading branch information...
1 parent b3e9c1a commit 416605d671b1a33c010f8636dc81176041dad6ba @dlee dlee committed Apr 11, 2012
Showing with 92 additions and 5 deletions.
  1. +5 −5 spec/install/git_spec.rb
  2. +87 −0 spec/runtime/setup_spec.rb
@@ -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"
@@ -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
@@ -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'))
@@ -268,7 +268,7 @@
out.should =~ /because :branch is not specified in Gemfile/
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'))
@@ -287,7 +287,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|
@@ -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

0 comments on commit 416605d

Please sign in to comment.