This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for bundle install --standalone, which will allow a bundl…
…e to work without rubygems or bundler at runtime. This is useful for packaging up an app using something like warbler, rawr, or as a .app using MacRuby
- Loading branch information
Showing
4 changed files
with
204 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
require "spec_helper" | ||
|
||
describe "bundle install --standalone" do | ||
describe "with simple gems" do | ||
before do | ||
install_gemfile <<-G, :standalone => true | ||
source "file://#{gem_repo1}" | ||
gem "rails" | ||
G | ||
end | ||
|
||
it "still makes the gems available to normal bundler" do | ||
should_be_installed "actionpack 2.3.2", "rails 2.3.2" | ||
end | ||
|
||
it "generates a bundle/bundler/setup.rb" do | ||
bundled_app("bundle/bundler/setup.rb").should exist | ||
end | ||
|
||
it "makes the gems available without bundler" do | ||
ruby <<-RUBY, :no_lib => true | ||
$:.unshift File.expand_path("bundle") | ||
require "bundler/setup" | ||
require "actionpack" | ||
puts ACTIONPACK | ||
RUBY | ||
|
||
out.should == "2.3.2" | ||
end | ||
|
||
it "works on a different system" do | ||
FileUtils.mv(bundled_app, "#{bundled_app}2") | ||
Dir.chdir("#{bundled_app}2") | ||
|
||
ruby <<-RUBY, :no_lib => true | ||
$:.unshift File.expand_path("bundle") | ||
require "bundler/setup" | ||
require "actionpack" | ||
puts ACTIONPACK | ||
RUBY | ||
|
||
out.should == "2.3.2" | ||
end | ||
end | ||
|
||
describe "with a combination of gems and git repos" do | ||
before do | ||
build_git "devise", "1.0" | ||
|
||
install_gemfile <<-G, :standalone => true | ||
source "file://#{gem_repo1}" | ||
gem "rails" | ||
gem "devise", :git => "#{lib_path('devise-1.0')}" | ||
G | ||
end | ||
|
||
it "still makes the gems available to normal bundler" do | ||
should_be_installed "actionpack 2.3.2", "rails 2.3.2", "devise 1.0" | ||
end | ||
|
||
it "generates a bundle/bundler/setup.rb" do | ||
bundled_app("bundle/bundler/setup.rb").should exist | ||
end | ||
|
||
it "makes the gems available without bundler" do | ||
ruby <<-RUBY, :no_lib => true | ||
$:.unshift File.expand_path("bundle") | ||
require "bundler/setup" | ||
require "devise" | ||
require "actionpack" | ||
puts DEVISE | ||
puts ACTIONPACK | ||
RUBY | ||
|
||
out.should == "1.0\n2.3.2" | ||
end | ||
end | ||
|
||
describe "with groups" do | ||
before do | ||
build_git "devise", "1.0" | ||
|
||
install_gemfile <<-G, :standalone => true | ||
source "file://#{gem_repo1}" | ||
gem "rails" | ||
group :test do | ||
gem "rspec" | ||
gem "rack-test" | ||
end | ||
G | ||
end | ||
|
||
it "makes the gems available without bundler" do | ||
ruby <<-RUBY, :no_lib => true | ||
$:.unshift File.expand_path("bundle") | ||
require "bundler/setup" | ||
require "actionpack" | ||
require "spec" | ||
require "rack/test" | ||
puts ACTIONPACK | ||
puts SPEC | ||
puts RACK_TEST | ||
RUBY | ||
|
||
out.should == "2.3.2\n1.2.7\n1.0" | ||
end | ||
|
||
it "allows creating a standalone file with limited groups" do | ||
bundle "install --standalone default" | ||
|
||
ruby <<-RUBY, :no_lib => true, :expect_err => true | ||
$:.unshift File.expand_path("bundle") | ||
require "bundler/setup" | ||
require "actionpack" | ||
puts ACTIONPACK | ||
require "spec" | ||
RUBY | ||
|
||
out.should == "2.3.2" | ||
err.should =~ /no such file to load.*spec/ | ||
end | ||
|
||
it "allows --without to limit the groups used in a standalone" do | ||
bundle "install --standalone --without test" | ||
|
||
ruby <<-RUBY, :no_lib => true, :expect_err => true | ||
$:.unshift File.expand_path("bundle") | ||
require "bundler/setup" | ||
require "actionpack" | ||
puts ACTIONPACK | ||
require "spec" | ||
RUBY | ||
|
||
out.should == "2.3.2" | ||
err.should =~ /no such file to load.*spec/ | ||
end | ||
|
||
it "allows remembered --without to limit the groups used in a standalone" do | ||
bundle "install --without test" | ||
bundle "install --standalone" | ||
|
||
ruby <<-RUBY, :no_lib => true, :expect_err => true | ||
$:.unshift File.expand_path("bundle") | ||
require "bundler/setup" | ||
require "actionpack" | ||
puts ACTIONPACK | ||
require "spec" | ||
RUBY | ||
|
||
out.should == "2.3.2" | ||
err.should =~ /no such file to load.*spec/ | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9278bf5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! This should knock off a few megs of ram from each ruby process (if rubygems isn't being loaded).
(right?)
9278bf5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
♥
forever
9278bf5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty fantastic. Gems and Shoes are sometimes pretty rough... I can see this being ultra useful.
9278bf5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES! We do a lot of Debian packaging for our ruby applications (including rails) and this is definitely going to help a lot.
<3 Yehuda
9278bf5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job!
9278bf5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about native extensions?
9278bf5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one! we're also doing debian packaging of a ruby-based app, and were keen to avoid bundler as a runtime dependency. This will really help.
Looking forward to v1.1...