diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-01-25 12:52:37 -0800 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-01-25 12:52:37 -0800 |
commit | 87201e7684d9bc2bd667f5298750ee376cc5526b (patch) | |
tree | e7d558c3e015bfe3e8a7e81ec0dcd923ef70d00b | |
parent | 3750e07e62096597081bc05e9cdbeb1cdfd044ec (diff) | |
download | bundler-87201e7684d9bc2bd667f5298750ee376cc5526b.tar.gz |
Add a spec for using git source at a specific ref
-rw-r--r-- | spec/install/git_spec.rb | 72 | ||||
-rw-r--r-- | spec/lock/git_spec.rb | 25 | ||||
-rw-r--r-- | spec/support/helpers.rb | 15 |
3 files changed, 77 insertions, 35 deletions
diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb index 3a1f89178e..76cc998e7a 100644 --- a/spec/install/git_spec.rb +++ b/spec/install/git_spec.rb @@ -1,42 +1,66 @@ require File.expand_path('../../spec_helper', __FILE__) describe "bbl install with git sources" do - before :each do - in_app_root + describe "when floating on master" do + before :each do + in_app_root - build_git "foo" + build_git "foo" - install_gemfile <<-G - git "#{lib_path('foo-1.0')}" - gem 'foo' - G - end + install_gemfile <<-G + git "#{lib_path('foo-1.0')}" + gem 'foo' + G + end - it "fetches gems" do - should_be_installed("foo 1.0") + it "fetches gems" do + should_be_installed("foo 1.0") - run <<-RUBY - require 'foo' - puts "WIN" unless defined?(FOO_PREV_REF) - RUBY + run <<-RUBY + require 'foo' + puts "WIN" unless defined?(FOO_PREV_REF) + RUBY - out.should == "WIN" + out.should == "WIN" + end + + it "floats on master if no ref is specified" do + update_git "foo" + + in_app_root2 do + install_gemfile bundled_app2("Gemfile"), <<-G + git "#{lib_path('foo-1.0')}" + gem 'foo' + G + end + + in_app_root do + run <<-RUBY + require 'foo' + puts "WIN" if defined?(FOO_PREV_REF) + RUBY + + out.should == "WIN" + end + end end - it "floats on master if no ref is specified" do - update_git "foo" + describe "when specifying a revision" do + it "works" do + in_app_root - in_app_root2 do - install_gemfile bundled_app2("Gemfile"), <<-G - git "#{lib_path('foo-1.0')}" - gem 'foo' + build_git "foo" + @revision = revision_for(lib_path("foo-1.0")) + update_git "foo" + + install_gemfile <<-G + git "#{lib_path('foo-1.0')}", :ref => "#{@revision}" + gem "foo" G - end - in_app_root do run <<-RUBY require 'foo' - puts "WIN" if defined?(FOO_PREV_REF) + puts "WIN" unless defined?(FOO_PREV_REF) RUBY out.should == "WIN" diff --git a/spec/lock/git_spec.rb b/spec/lock/git_spec.rb new file mode 100644 index 0000000000..419befa36f --- /dev/null +++ b/spec/lock/git_spec.rb @@ -0,0 +1,25 @@ +require File.expand_path('../../spec_helper', __FILE__) + +describe "bbl lock with git" do + it "locks a git source to the current ref" do + in_app_root + + build_git "foo" + + install_gemfile <<-G + git "#{lib_path('foo-1.0')}" + gem 'foo' + G + + bbl :lock + update_git "foo" + bbl :install + + run <<-RUBY + require 'foo' + puts "WIN" unless defined?(FOO_PREV_REF) + RUBY + + out.should == "WIN" + end +end
\ No newline at end of file diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 3f615f05aa..f57208c121 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -63,17 +63,6 @@ module Spec bbl :install end - # def bubble(*args) - # path = bundled_app("Gemfile") - # path = args.shift if Pathname === args.first - # str = args.shift || "" - # FileUtils.mkdir_p(path.dirname) - # Dir.chdir(path.dirname) do - # gemfile(path, str) - # Bubble.load(path) - # end - # end - def install_gems(*gems) Dir["#{gem_repo1}/**/*.gem"].each do |path| if gems.include?(File.basename(path, ".gem")) @@ -110,5 +99,9 @@ module Spec end end end + + def revision_for(path) + Dir.chdir(path) { `git rev-parse HEAD`.strip } + end end end
\ No newline at end of file |