summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-29 12:45:05 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-29 12:45:05 -0700
commit741817402161cc08713b48456578bc92ea278020 (patch)
treeebd54ea896ecc2cbe80fd14fedc0babfba27e84d
parent77f7cea4baed7264fc0ace0bcec6477d04ffb8b2 (diff)
downloadbundler-741817402161cc08713b48456578bc92ea278020.tar.gz
Update the installer specs to be full stack
-rw-r--r--spec/bundler/installer_spec.rb218
-rw-r--r--spec/spec_helper.rb16
2 files changed, 114 insertions, 120 deletions
diff --git a/spec/bundler/installer_spec.rb b/spec/bundler/installer_spec.rb
index e946b3372e..e416ada066 100644
--- a/spec/bundler/installer_spec.rb
+++ b/spec/bundler/installer_spec.rb
@@ -3,12 +3,18 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Installing gems" do
describe "the bundle directory" do
+
+ before(:each) do
+ @gems = %w(
+ actionmailer-2.3.2 actionpack-2.3.2 activerecord-2.3.2
+ activeresource-2.3.2 activesupport-2.3.2 rails-2.3.2 rake-0.8.7)
+ end
+
def setup
@manifest = build_manifest <<-Gemfile
sources.clear
source "file://#{gem_repo1}"
source "file://#{gem_repo2}"
- bundle_path "#{tmp_file('hello')}"
gem "rails"
Gemfile
end
@@ -16,140 +22,112 @@ describe "Installing gems" do
it "creates the bundle directory if it does not exist" do
setup
@manifest.install
- tmp_file("hello").should have_cached_gems("rails-2.3.2")
+ tmp_file("vendor", "gems").should have_cached_gems("rails-2.3.2")
end
it "uses the bundle directory if it is empty" do
- tmp_file("hello").mkdir
+ tmp_file("vendor", "gems").mkdir_p
setup
@manifest.install
- tmp_file("hello").should have_cached_gems("rails-2.3.2")
+ tmp_file("vendor", "gems").should have_cached_gems("rails-2.3.2")
end
it "uses the bundle directory if it is a valid gem repo" do
- tmp_file("hello").mkdir
- %w(cache doc gems environments specifications).each { |dir| tmp_file("hello", dir).mkdir }
+ %w(cache doc gems environments specifications).each { |dir| tmp_file("vendor", "gems", dir).mkdir_p }
setup
@manifest.install
- tmp_file("hello").should have_cached_gems("rails-2.3.2")
+ tmp_file("vendor", "gems").should have_cached_gems("rails-2.3.2")
end
it "does not use the bundle directory if it is not a valid gem repo" do
- tmp_file("hello").mkdir
- FileUtils.touch(tmp_file("hello", "fail"))
+ tmp_file("vendor", "gems", "fail").touch_p
lambda {
setup
}.should raise_error(Bundler::InvalidRepository)
end
+
+ it "installs the bins in the directory you specify" do
+ tmp_file("omgbinz").mkdir
+ m = build_manifest <<-Gemfile
+ sources.clear
+ source "file://#{gem_repo1}"
+ source "file://#{gem_repo2}"
+ bin_path "#{tmp_file("omgbinz")}"
+ gem "rails"
+ Gemfile
+ m.install
+ tmp_file("omgbinz", "rails").should exist
+ end
+
+ it "does not modify any .gemspec files that are to be installed if a directory of the same name exists" do
+ dir = tmp_file("gems", "rails-2.3.2")
+ spec = tmp_file("specifications", "rails-2.3.2.gemspec")
+
+ dir.mkdir_p
+ spec.touch_p
+
+ setup
+ lambda { @manifest.install }.should_not change { [dir.mtime, spec.mtime] }
+ end
+
+ it "deletes a .gemspec file that is to be installed if a directory of the same name does not exist" do
+ spec = tmp_file("vendor", "gems", "specifications", "rails-2.3.2.gemspec")
+ spec.touch_p
+ setup
+ lambda { @manifest.install }.should change { spec.mtime }
+ end
+
+ it "deletes a directory that is to be installed if a .gemspec of the same name does not exist" do
+ dir = tmp_file("vendor", "gems", "gems", "rails-2.3.2")
+ dir.mkdir_p
+ setup
+ lambda { @manifest.install }.should change { dir.mtime }
+ end
+
+ it "keeps bin files for already installed gems" do
+ setup
+ @manifest.install
+ lambda { @manifest.install }.should_not change { tmp_file("bin", "rails").mtime }
+ end
+
+ it "each thing in the bundle has a directory in gems" do
+ setup
+ @manifest.install
+ @gems.each do |name|
+ tmp_file("vendor", "gems", "gems", name).should be_directory
+ end
+ end
+
+ it "creates a specification for each gem" do
+ setup
+ @manifest.install
+ @gems.each do |name|
+ tmp_file("vendor", "gems", "specifications", "#{name}.gemspec").should be_file
+ end
+ end
+
+ it "outputs a logger message for each gem that is installed" do
+ setup
+ @manifest.install
+ @gems.each do |name|
+ @log_output.should have_log_message("Installing #{name}.gem")
+ end
+ end
+
+ it "copies gem executables to a specified path" do
+ setup
+ @manifest.install
+ tmp_file('bin', 'rails').should be_file
+ end
+
+ it "compiles binary gems" do
+ m = build_manifest <<-Gemfile
+ sources.clear
+ source "file://#{gem_repo2}"
+ gem "json"
+ Gemfile
+ m.install
+ Dir[tmp_file('vendor', 'gems', 'gems', 'json-*', '**', "*.#{Config::CONFIG['DLEXT']}")].should have_at_least(1).item
+ end
end
-end
-#
-# describe "Bundler::Installer" do
-#
-# before(:each) do
-# pending
-# end
-#
-# before(:each) do
-# @finder = Bundler::Finder.new("file://#{gem_repo1}", "file://#{gem_repo2}")
-# end
-#
-# describe "without native gems" do
-# before(:each) do
-# @bundle = @finder.resolve(build_dep('rails', '>= 0'))
-# @bundle.download(tmp_dir)
-# end
-#
-# it "raises an ArgumentError if the path does not exist" do
-# lambda { Bundler::Installer.install(tmp_dir.join("omgomgbadpath")) }.should raise_error(ArgumentError)
-# end
-#
-# it "raises an ArgumentError if the path does not contain a 'cache' directory" do
-# lambda { Bundler::Installer.install(gem_repo1) }.should raise_error(ArgumentError)
-# end
-#
-# describe "installing gems" do
-#
-# before(:each) do
-# FileUtils.rm_rf(tmp_file("gems"))
-# FileUtils.rm_rf(tmp_file("specifications"))
-# end
-#
-# it "installs the bins in the directory you specify" do
-# FileUtils.mkdir_p tmp_file("omgbinz")
-# @environment = Bundler::Installer.install(tmp_dir, tmp_file("omgbinz"))
-# File.exist?(tmp_file("omgbinz", "rails")).should be_true
-# end
-#
-# it "does not modify any .gemspec files that are to be installed if a directory of the same name exists" do
-# dir = tmp_file("gems", "rails-2.3.2")
-# FileUtils.mkdir_p(dir)
-# FileUtils.mkdir_p(tmp_file("specifications"))
-# spec = tmp_file("specifications", "rails-2.3.2.gemspec")
-# FileUtils.touch(spec)
-# lambda { Bundler::Installer.install(tmp_dir) }.should_not change { [File.mtime(dir), File.mtime(spec)] }
-# end
-#
-# it "deletes a .gemspec file that is to be installed if a directory of the same name does not exist" do
-# spec = tmp_file("specifications", "rails-2.3.2.gemspec")
-# FileUtils.mkdir_p(tmp_file("specifications"))
-# FileUtils.touch(spec)
-# lambda { Bundler::Installer.install(tmp_dir) }.should change { File.mtime(spec) }
-# end
-#
-# it "deletes a directory that is to be installed if a .gemspec of the same name does not exist" do
-# dir = tmp_file("gems", "rails-2.3.2")
-# FileUtils.mkdir_p(dir)
-# lambda { Bundler::Installer.install(tmp_dir) }.should change { File.mtime(dir) }
-# end
-#
-# it "keeps bin files for already installed gems" do
-# Bundler::Installer.install(tmp_dir)
-# Bundler::Installer.install(tmp_dir)
-# tmp_file("bin", "rails").should exist
-# end
-# end
-#
-# describe "after installing gems" do
-#
-# before(:each) do
-# @environment = Bundler::Installer.install(tmp_dir)
-# end
-#
-# it "each thing in the bundle has a directory in gems" do
-# @bundle.each do |spec|
-# Dir[File.join(tmp_dir, 'gems', "#{spec.full_name}")].should have(1).item
-# end
-# end
-#
-# it "creates a specification for each gem" do
-# @bundle.each do |spec|
-# Dir[File.join(tmp_dir, 'specifications', "#{spec.full_name}.gemspec")].should have(1).item
-# end
-# end
-#
-# it "copies gem executables to a specified path" do
-# File.exist?(File.join(tmp_dir, 'bin', 'rails')).should be_true
-# end
-# end
-#
-# it "outputs a logger message for each gem that is installed" do
-# @environment = Bundler::Installer.install(tmp_dir)
-# @bundle.each do |spec|
-# @log_output.should have_log_message("Installing #{spec.full_name}.gem")
-# end
-# end
-# end
-#
-# describe "with native gems" do
-#
-# it "compiles binary gems" do
-# FileUtils.rm_rf(tmp_dir)
-# @bundle = @finder.resolve(build_dep('json', '>= 0'))
-# @bundle.download(tmp_dir)
-# Bundler::Installer.install(tmp_dir)
-# Dir[File.join(tmp_dir, 'gems', "json-*", "**", "*.bundle")].should have_at_least(1).item
-# end
-#
-# end
-# end
+end \ No newline at end of file
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 74cc6be0cf..5f771d6f6c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -5,6 +5,22 @@ require "builders"
require "matchers"
require "pathname"
require "pp"
+require "rbconfig"
+
+class Pathname
+ def mkdir_p
+ FileUtils.mkdir_p(self)
+ end
+
+ def touch_p
+ dirname.mkdir_p
+ touch
+ end
+
+ def touch
+ FileUtils.touch(self)
+ end
+end
module Spec
module Helpers