Permalink
Browse files

Include executables in virtual gemspecs

  - Add tests for gem binaries when locked and unlocked:
	- with :path
	- with :git
	- with :git and no gemspec
  - Add should_be_locked matcher
  • Loading branch information...
1 parent 426a85c commit 7147a13b01e8943d28d38814521fc7343d7d479f @indirect indirect committed Mar 24, 2010
Showing with 109 additions and 32 deletions.
  1. +16 −11 lib/bundler/source.rb
  2. +87 −17 spec/other/exec_spec.rb
  3. +2 −4 spec/runtime/environment_rb_spec.rb
  4. +4 −0 spec/support/matchers.rb
View
@@ -138,7 +138,7 @@ def install(spec)
end
class Path
- attr_reader :path, :options, :default_spec
+ attr_reader :path, :options
def initialize(options)
@options = options
@@ -148,15 +148,8 @@ def initialize(options)
@path = Pathname.new(options["path"]).expand_path(Bundler.root)
end
- if options["name"]
- @default_spec = Specification.new do |s|
- s.name = options["name"]
- s.source = self
- s.version = Gem::Version.new(options["version"])
- s.summary = "Fake gemspec for #{options["name"]}"
- s.relative_loaded_from = "#{options["name"]}.gemspec"
- end
- end
+ @name = options["name"]
+ @version = options["version"]
end
def to_s
@@ -178,7 +171,19 @@ def load_spec_files
end
end
- index << default_spec if default_spec && index.empty?
+ if index.empty? && @name && @version
+ index << Specification.new do |s|
+ s.name = @name
+ s.source = self
+ s.version = Gem::Version.new(@version)
+ s.summary = "Fake gemspec for #{@name}"
+ s.relative_loaded_from = "#{@name}.gemspec"
+ if path.join("bin").exist?
+ binaries = path.join("bin").children.map{|c| c.basename.to_s }
+ s.executables = binaries
+ end
+ end
+ end
else
raise PathError, "The path `#{path}` does not exist."
end
View
@@ -85,36 +85,106 @@
G
bundle "lock"
+ should_be_locked
File.open(".bundle/environment.rb", 'a') { |f| f.puts "puts 'using environment.rb'" }
bundle "exec rackup"
out.should == "using environment.rb\n1.0.0"
end
+ end
- it "works when running from a random directory" do
- install_gemfile <<-G
- gem "rack"
- G
+ describe "with gem binaries" do
+ describe "run from a random directory" do
+ before(:each) do
+ install_gemfile <<-G
+ gem "rack"
+ G
+ end
- bundle "lock"
- bundle "exec 'cd #{tmp('gems')} && rackup'"
+ it "works when unlocked" do
+ bundle "exec 'cd #{tmp('gems')} && rackup'"
+ out.should == "1.0.0"
+ end
- out.should == "1.0.0"
+ it "works when locked" do
+ bundle "lock"
+ should_be_locked
+ bundle "exec 'cd #{tmp('gems')} && rackup'"
+ out.should == "1.0.0"
+ end
end
- it "works with gems from a path" do
- build_lib "fizz", :path => home("fizz") do |s|
- s.executables = "fizz"
+ describe "from gems bundled via :path" do
+ before(:each) do
+ build_lib "fizz", :path => home("fizz") do |s|
+ s.executables = "fizz"
+ end
+
+ install_gemfile <<-G
+ gem "fizz", :path => "#{File.expand_path(home("fizz"))}"
+ G
end
- install_gemfile <<-G
- gem "fizz", :path => "#{File.expand_path(home("fizz"))}"
- G
+ it "works when unlocked" do
+ bundle "exec fizz"
+ out.should == "1.0"
+ end
- bundle "lock"
- bundle "exec fizz"
- out.should == "1.0"
+ it "works when locked" do
+ bundle "lock"
+ should_be_locked
+ bundle "exec fizz"
+ out.should == "1.0"
+ end
end
- end
+ describe "from gems bundled via :git" do
+ before(:each) do
+ build_git "fizz_git" do |s|
+ s.executables = "fizz_git"
+ end
+
+ install_gemfile <<-G
+ gem "fizz_git", :git => "#{lib_path('fizz_git-1.0')}"
+ G
+ end
+
+ it "works when unlocked" do
+ bundle "exec fizz_git"
+ out.should == "1.0"
+ end
+
+ it "works when locked" do
+ bundle "lock"
+ should_be_locked
+ bundle "exec fizz_git"
+ out.should == "1.0"
+ end
+ end
+
+ describe "from gems bundled via :git with no gemspec" do
+ before(:each) do
+ build_git "fizz_no_gemspec", :gemspec => false do |s|
+ s.executables = "fizz_no_gemspec"
+ end
+
+ install_gemfile <<-G
+ gem "fizz_no_gemspec", "1.0", :git => "#{lib_path('fizz_no_gemspec-1.0')}"
+ G
+ end
+
+ it "works when unlocked" do
+ bundle "exec fizz_no_gemspec"
+ out.should == "1.0"
+ end
+
+ it "works when locked" do
+ bundle "lock"
+ should_be_locked
+ bundle "exec fizz_no_gemspec"
+ out.should == "1.0"
+ end
+ end
+
+ end
end
@@ -7,15 +7,13 @@
build_git "no-gemspec", :gemspec => false
install_gemfile <<-G
- source "file://#{gem_repo1}"
-
- gem "no-gemspec", '1.0', :git => "#{lib_path('no-gemspec-1.0')}"
+ gem "no-gemspec", "1.0", :git => "#{lib_path('no-gemspec-1.0')}"
G
bundle :lock
end
- it "works with gems from git that don't have gemspecs" do
+ it "loads the library via a virtual spec" do
run <<-R, :lite_runtime => true
require 'no-gemspec'
puts NOGEMSPEC
View
@@ -43,5 +43,9 @@ def should_not_be_installed(*names)
out.should == "WIN" || Gem::Version.new(out).should_not == Gem::Version.new(version)
end
end
+
+ def should_be_locked
+ Pathname.new(".bundle/environment.rb").should exist
+ end
end
end

0 comments on commit 7147a13

Please sign in to comment.