bundler-maglev- 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +22 -0
- data/.travis.yml +32 -0
- data/CHANGELOG.md +805 -0
- data/ISSUES.md +62 -0
- data/LICENSE +23 -0
- data/README.md +29 -0
- data/Rakefile +212 -0
- data/UPGRADING.md +103 -0
- data/bin/bundle +22 -0
- data/bundler.gemspec +30 -0
- data/lib/bundler.rb +286 -0
- data/lib/bundler/capistrano.rb +11 -0
- data/lib/bundler/cli.rb +520 -0
- data/lib/bundler/definition.rb +438 -0
- data/lib/bundler/dependency.rb +134 -0
- data/lib/bundler/deployment.rb +58 -0
- data/lib/bundler/dsl.rb +257 -0
- data/lib/bundler/environment.rb +47 -0
- data/lib/bundler/gem_helper.rb +151 -0
- data/lib/bundler/gem_installer.rb +9 -0
- data/lib/bundler/gem_tasks.rb +2 -0
- data/lib/bundler/graph.rb +130 -0
- data/lib/bundler/index.rb +138 -0
- data/lib/bundler/installer.rb +97 -0
- data/lib/bundler/lazy_specification.rb +74 -0
- data/lib/bundler/lockfile_parser.rb +108 -0
- data/lib/bundler/remote_specification.rb +59 -0
- data/lib/bundler/resolver.rb +464 -0
- data/lib/bundler/rubygems_ext.rb +237 -0
- data/lib/bundler/rubygems_integration.rb +349 -0
- data/lib/bundler/runtime.rb +152 -0
- data/lib/bundler/settings.rb +115 -0
- data/lib/bundler/setup.rb +23 -0
- data/lib/bundler/shared_helpers.rb +71 -0
- data/lib/bundler/source.rb +708 -0
- data/lib/bundler/spec_set.rb +135 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +1 -0
- data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/gitignore.tt +4 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +24 -0
- data/lib/bundler/ui.rb +73 -0
- data/lib/bundler/vendor/thor.rb +358 -0
- data/lib/bundler/vendor/thor/actions.rb +314 -0
- data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
- data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
- data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
- data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
- data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
- data/lib/bundler/vendor/thor/base.rb +576 -0
- data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
- data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/bundler/vendor/thor/error.rb +30 -0
- data/lib/bundler/vendor/thor/group.rb +273 -0
- data/lib/bundler/vendor/thor/invocation.rb +168 -0
- data/lib/bundler/vendor/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
- data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
- data/lib/bundler/vendor/thor/parser/option.rb +120 -0
- data/lib/bundler/vendor/thor/parser/options.rb +175 -0
- data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
- data/lib/bundler/vendor/thor/runner.rb +309 -0
- data/lib/bundler/vendor/thor/shell.rb +88 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
- data/lib/bundler/vendor/thor/shell/color.rb +108 -0
- data/lib/bundler/vendor/thor/shell/html.rb +121 -0
- data/lib/bundler/vendor/thor/task.rb +113 -0
- data/lib/bundler/vendor/thor/util.rb +229 -0
- data/lib/bundler/vendor/thor/version.rb +3 -0
- data/lib/bundler/vendored_thor.rb +7 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +11 -0
- data/man/bundle-config.ronn +90 -0
- data/man/bundle-exec.ronn +111 -0
- data/man/bundle-install.ronn +317 -0
- data/man/bundle-package.ronn +59 -0
- data/man/bundle-update.ronn +176 -0
- data/man/bundle.ronn +80 -0
- data/man/gemfile.5.ronn +284 -0
- data/man/index.txt +6 -0
- data/spec/bundler/gem_helper_spec.rb +143 -0
- data/spec/cache/gems_spec.rb +230 -0
- data/spec/cache/git_spec.rb +12 -0
- data/spec/cache/path_spec.rb +27 -0
- data/spec/cache/platform_spec.rb +57 -0
- data/spec/install/deploy_spec.rb +197 -0
- data/spec/install/deprecated_spec.rb +37 -0
- data/spec/install/gems/c_ext_spec.rb +48 -0
- data/spec/install/gems/env_spec.rb +107 -0
- data/spec/install/gems/flex_spec.rb +313 -0
- data/spec/install/gems/groups_spec.rb +259 -0
- data/spec/install/gems/packed_spec.rb +84 -0
- data/spec/install/gems/platform_spec.rb +192 -0
- data/spec/install/gems/resolving_spec.rb +72 -0
- data/spec/install/gems/simple_case_spec.rb +770 -0
- data/spec/install/gems/sudo_spec.rb +74 -0
- data/spec/install/gems/win32_spec.rb +26 -0
- data/spec/install/gemspec_spec.rb +125 -0
- data/spec/install/git_spec.rb +570 -0
- data/spec/install/invalid_spec.rb +35 -0
- data/spec/install/path_spec.rb +405 -0
- data/spec/install/upgrade_spec.rb +26 -0
- data/spec/lock/git_spec.rb +35 -0
- data/spec/lock/lockfile_spec.rb +739 -0
- data/spec/other/check_spec.rb +221 -0
- data/spec/other/config_spec.rb +40 -0
- data/spec/other/console_spec.rb +54 -0
- data/spec/other/exec_spec.rb +248 -0
- data/spec/other/ext_spec.rb +37 -0
- data/spec/other/help_spec.rb +39 -0
- data/spec/other/init_spec.rb +40 -0
- data/spec/other/newgem_spec.rb +46 -0
- data/spec/other/open_spec.rb +35 -0
- data/spec/other/show_spec.rb +82 -0
- data/spec/quality_spec.rb +62 -0
- data/spec/resolver/basic_spec.rb +20 -0
- data/spec/resolver/platform_spec.rb +82 -0
- data/spec/runtime/executable_spec.rb +110 -0
- data/spec/runtime/load_spec.rb +107 -0
- data/spec/runtime/platform_spec.rb +90 -0
- data/spec/runtime/require_spec.rb +231 -0
- data/spec/runtime/setup_spec.rb +730 -0
- data/spec/runtime/with_clean_env_spec.rb +15 -0
- data/spec/spec_helper.rb +92 -0
- data/spec/support/builders.rb +597 -0
- data/spec/support/helpers.rb +239 -0
- data/spec/support/indexes.rb +112 -0
- data/spec/support/matchers.rb +77 -0
- data/spec/support/path.rb +71 -0
- data/spec/support/platforms.rb +53 -0
- data/spec/support/ruby_ext.rb +20 -0
- data/spec/support/rubygems_ext.rb +37 -0
- data/spec/support/rubygems_hax/platform.rb +11 -0
- data/spec/support/sudo.rb +21 -0
- data/spec/update/gems_spec.rb +122 -0
- data/spec/update/git_spec.rb +196 -0
- data/spec/update/source_spec.rb +51 -0
- metadata +296 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Running bin/* commands" do
|
4
|
+
before :each do
|
5
|
+
gemfile <<-G
|
6
|
+
source "file://#{gem_repo1}"
|
7
|
+
gem "rack"
|
8
|
+
G
|
9
|
+
end
|
10
|
+
|
11
|
+
it "runs the bundled command when in the bundle" do
|
12
|
+
bundle "install --binstubs"
|
13
|
+
|
14
|
+
build_gem "rack", "2.0", :to_system => true do |s|
|
15
|
+
s.executables = "rackup"
|
16
|
+
end
|
17
|
+
|
18
|
+
gembin "rackup"
|
19
|
+
out.should == "1.0.0"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "allows the location of the gem stubs to be specified" do
|
23
|
+
bundle "install --binstubs gbin"
|
24
|
+
|
25
|
+
bundled_app("bin").should_not exist
|
26
|
+
bundled_app("gbin/rackup").should exist
|
27
|
+
|
28
|
+
gembin bundled_app("gbin/rackup")
|
29
|
+
out.should == "1.0.0"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "allows absolute paths as a specification of where to install bin stubs" do
|
33
|
+
bundle "install --binstubs #{tmp}/bin"
|
34
|
+
|
35
|
+
gembin tmp("bin/rackup")
|
36
|
+
out.should == "1.0.0"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "runs the bundled command when out of the bundle" do
|
40
|
+
bundle "install --binstubs"
|
41
|
+
|
42
|
+
build_gem "rack", "2.0", :to_system => true do |s|
|
43
|
+
s.executables = "rackup"
|
44
|
+
end
|
45
|
+
|
46
|
+
Dir.chdir(tmp) do
|
47
|
+
gembin "rackup"
|
48
|
+
out.should == "1.0.0"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "works with gems in path" do
|
53
|
+
build_lib "rack", :path => lib_path("rack") do |s|
|
54
|
+
s.executables = 'rackup'
|
55
|
+
end
|
56
|
+
|
57
|
+
gemfile <<-G
|
58
|
+
gem "rack", :path => "#{lib_path('rack')}"
|
59
|
+
G
|
60
|
+
|
61
|
+
bundle "install --binstubs"
|
62
|
+
|
63
|
+
build_gem 'rack', '2.0', :to_system => true do |s|
|
64
|
+
s.executables = 'rackup'
|
65
|
+
end
|
66
|
+
|
67
|
+
gembin "rackup"
|
68
|
+
out.should == '1.0'
|
69
|
+
end
|
70
|
+
|
71
|
+
it "don't bundle da bundla" do
|
72
|
+
build_gem "bundler", Bundler::VERSION, :to_system => true do |s|
|
73
|
+
s.executables = "bundle"
|
74
|
+
end
|
75
|
+
|
76
|
+
gemfile <<-G
|
77
|
+
source "file://#{gem_repo1}"
|
78
|
+
gem "bundler"
|
79
|
+
G
|
80
|
+
|
81
|
+
bundle "install --binstubs"
|
82
|
+
|
83
|
+
bundled_app("bin/bundle").should_not exist
|
84
|
+
end
|
85
|
+
|
86
|
+
it "does not generate bin stubs if the option was not specified" do
|
87
|
+
bundle "install"
|
88
|
+
|
89
|
+
bundled_app("bin/rackup").should_not exist
|
90
|
+
end
|
91
|
+
|
92
|
+
it "remembers that the option was specified" do
|
93
|
+
gemfile <<-G
|
94
|
+
source "file://#{gem_repo1}"
|
95
|
+
gem "activesupport"
|
96
|
+
G
|
97
|
+
|
98
|
+
bundle "install --binstubs"
|
99
|
+
|
100
|
+
gemfile <<-G
|
101
|
+
source "file://#{gem_repo1}"
|
102
|
+
gem "activesupport"
|
103
|
+
gem "rack"
|
104
|
+
G
|
105
|
+
|
106
|
+
bundle "install"
|
107
|
+
|
108
|
+
bundled_app("bin/rackup").should exist
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Bundler.load" do
|
4
|
+
before :each do
|
5
|
+
system_gems "rack-1.0.0"
|
6
|
+
# clear memoized method results
|
7
|
+
# TODO: Don't reset internal ivars
|
8
|
+
Bundler.instance_eval do
|
9
|
+
@load = nil
|
10
|
+
@runtime = nil
|
11
|
+
@definition = nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "with a gemfile" do
|
16
|
+
before(:each) do
|
17
|
+
gemfile <<-G
|
18
|
+
source "file://#{gem_repo1}"
|
19
|
+
gem "rack"
|
20
|
+
G
|
21
|
+
end
|
22
|
+
|
23
|
+
it "provides a list of the env dependencies" do
|
24
|
+
Bundler.load.dependencies.should have_dep("rack", ">= 0")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "provides a list of the resolved gems" do
|
28
|
+
Bundler.load.gems.should have_gem("rack-1.0.0", "bundler-#{Bundler::VERSION}")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "ignores blank BUNDLE_GEMFILEs" do
|
32
|
+
lambda {
|
33
|
+
ENV['BUNDLE_GEMFILE'] = ""
|
34
|
+
Bundler.load
|
35
|
+
}.should_not raise_error(Bundler::GemfileNotFound)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "without a gemfile" do
|
41
|
+
it "raises an exception if the default gemfile is not found" do
|
42
|
+
lambda {
|
43
|
+
Bundler.load
|
44
|
+
}.should raise_error(Bundler::GemfileNotFound, /could not locate gemfile/i)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "raises an exception if a specified gemfile is not found" do
|
48
|
+
lambda {
|
49
|
+
ENV['BUNDLE_GEMFILE'] = "omg.rb"
|
50
|
+
Bundler.load
|
51
|
+
}.should raise_error(Bundler::GemfileNotFound, /omg\.rb/)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "does not find a Gemfile above the testing directory" do
|
55
|
+
bundler_gemfile = tmp.join("../Gemfile")
|
56
|
+
unless File.exists?(bundler_gemfile)
|
57
|
+
FileUtils.touch(bundler_gemfile)
|
58
|
+
@remove_bundler_gemfile = true
|
59
|
+
end
|
60
|
+
begin
|
61
|
+
lambda { Bundler.load }.should raise_error(Bundler::GemfileNotFound)
|
62
|
+
ensure
|
63
|
+
bundler_gemfile.rmtree if @remove_bundler_gemfile
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "when called twice" do
|
70
|
+
it "doesn't try to load the runtime twice" do
|
71
|
+
system_gems "rack-1.0.0", "activesupport-2.3.5"
|
72
|
+
gemfile <<-G
|
73
|
+
gem "rack"
|
74
|
+
gem "activesupport", :group => :test
|
75
|
+
G
|
76
|
+
|
77
|
+
ruby <<-RUBY
|
78
|
+
require "bundler"
|
79
|
+
Bundler.setup :default
|
80
|
+
Bundler.require :default
|
81
|
+
puts RACK
|
82
|
+
begin
|
83
|
+
require "activesupport"
|
84
|
+
rescue LoadError
|
85
|
+
puts "no activesupport"
|
86
|
+
end
|
87
|
+
RUBY
|
88
|
+
|
89
|
+
out.split("\n").should == ["1.0.0", "no activesupport"]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "not hurting brittle rubygems" do
|
94
|
+
it "does not inject #source into the generated YAML of the gem specs" do
|
95
|
+
system_gems "activerecord-2.3.2", "activesupport-2.3.2"
|
96
|
+
gemfile <<-G
|
97
|
+
gem "activerecord"
|
98
|
+
G
|
99
|
+
|
100
|
+
Bundler.load.specs.each do |spec|
|
101
|
+
spec.to_yaml.should_not =~ /^\s+source:/
|
102
|
+
spec.to_yaml.should_not =~ /^\s+groups:/
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Bundler.setup with multi platform stuff" do
|
4
|
+
it "raises a friendly error when gems are missing locally" do
|
5
|
+
gemfile <<-G
|
6
|
+
source "file://#{gem_repo1}"
|
7
|
+
gem "rack"
|
8
|
+
G
|
9
|
+
|
10
|
+
lockfile <<-G
|
11
|
+
GEM
|
12
|
+
remote: file:#{gem_repo1}/
|
13
|
+
specs:
|
14
|
+
rack (1.0)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
#{local_tag}
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
rack
|
21
|
+
G
|
22
|
+
|
23
|
+
ruby <<-R
|
24
|
+
begin
|
25
|
+
require 'bundler'
|
26
|
+
Bundler.setup
|
27
|
+
rescue Bundler::GemNotFound => e
|
28
|
+
puts "WIN"
|
29
|
+
end
|
30
|
+
R
|
31
|
+
|
32
|
+
out.should == "WIN"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "will resolve correctly on the current platform when the lockfile was targetted for a different one" do
|
36
|
+
lockfile <<-G
|
37
|
+
GEM
|
38
|
+
remote: file:#{gem_repo1}/
|
39
|
+
specs:
|
40
|
+
nokogiri (1.4.2-java)
|
41
|
+
weakling (= 0.0.3)
|
42
|
+
weakling (0.0.3)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
java
|
46
|
+
|
47
|
+
DEPENDENCIES
|
48
|
+
nokogiri
|
49
|
+
G
|
50
|
+
|
51
|
+
system_gems "nokogiri-1.4.2"
|
52
|
+
|
53
|
+
simulate_platform "x86-darwin-10"
|
54
|
+
gemfile <<-G
|
55
|
+
source "file://#{gem_repo1}"
|
56
|
+
gem "nokogiri"
|
57
|
+
G
|
58
|
+
|
59
|
+
should_be_installed "nokogiri 1.4.2"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "will add the resolve for the current platform" do
|
63
|
+
lockfile <<-G
|
64
|
+
GEM
|
65
|
+
remote: file:#{gem_repo1}/
|
66
|
+
specs:
|
67
|
+
nokogiri (1.4.2-java)
|
68
|
+
weakling (= 0.0.3)
|
69
|
+
weakling (0.0.3)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
java
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
nokogiri
|
76
|
+
G
|
77
|
+
|
78
|
+
system_gems "nokogiri-1.4.2", "platform_specific-1.0-x86-darwin-100"
|
79
|
+
|
80
|
+
simulate_platform "x86-darwin-100"
|
81
|
+
|
82
|
+
gemfile <<-G
|
83
|
+
source "file://#{gem_repo1}"
|
84
|
+
gem "nokogiri"
|
85
|
+
gem "platform_specific"
|
86
|
+
G
|
87
|
+
|
88
|
+
should_be_installed "nokogiri 1.4.2", "platform_specific 1.0 x86-darwin-100"
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Bundler.require" do
|
4
|
+
before :each do
|
5
|
+
build_lib "one", "1.0.0" do |s|
|
6
|
+
s.write "lib/baz.rb", "puts 'baz'"
|
7
|
+
s.write "lib/qux.rb", "puts 'qux'"
|
8
|
+
end
|
9
|
+
|
10
|
+
build_lib "two", "1.0.0" do |s|
|
11
|
+
s.write "lib/two.rb", "puts 'two'"
|
12
|
+
s.add_dependency "three", "= 1.0.0"
|
13
|
+
end
|
14
|
+
|
15
|
+
build_lib "three", "1.0.0" do |s|
|
16
|
+
s.write "lib/three.rb", "puts 'three'"
|
17
|
+
s.add_dependency "seven", "= 1.0.0"
|
18
|
+
end
|
19
|
+
|
20
|
+
build_lib "four", "1.0.0" do |s|
|
21
|
+
s.write "lib/four.rb", "puts 'four'"
|
22
|
+
end
|
23
|
+
|
24
|
+
build_lib "five", "1.0.0", :no_default => true do |s|
|
25
|
+
s.write "lib/mofive.rb", "puts 'five'"
|
26
|
+
end
|
27
|
+
|
28
|
+
build_lib "six", "1.0.0" do |s|
|
29
|
+
s.write "lib/six.rb", "puts 'six'"
|
30
|
+
end
|
31
|
+
|
32
|
+
build_lib "seven", "1.0.0" do |s|
|
33
|
+
s.write "lib/seven.rb", "puts 'seven'"
|
34
|
+
end
|
35
|
+
|
36
|
+
gemfile <<-G
|
37
|
+
path "#{lib_path}"
|
38
|
+
gem "one", :group => :bar, :require => %w(baz qux)
|
39
|
+
gem "two"
|
40
|
+
gem "three", :group => :not
|
41
|
+
gem "four", :require => false
|
42
|
+
gem "five"
|
43
|
+
gem "six", :group => "string"
|
44
|
+
gem "seven", :group => :not
|
45
|
+
G
|
46
|
+
end
|
47
|
+
|
48
|
+
it "requires the gems" do
|
49
|
+
# default group
|
50
|
+
run "Bundler.require"
|
51
|
+
out.should eq("two")
|
52
|
+
|
53
|
+
# specific group
|
54
|
+
run "Bundler.require(:bar)"
|
55
|
+
out.should eq("baz\nqux")
|
56
|
+
|
57
|
+
# default and specific group
|
58
|
+
run "Bundler.require(:default, :bar)"
|
59
|
+
out.should eq("baz\nqux\ntwo")
|
60
|
+
|
61
|
+
# specific group given as a string
|
62
|
+
run "Bundler.require('bar')"
|
63
|
+
out.should eq("baz\nqux")
|
64
|
+
|
65
|
+
# specific group declared as a string
|
66
|
+
run "Bundler.require(:string)"
|
67
|
+
out.should eq("six")
|
68
|
+
|
69
|
+
# required in resolver order instead of gemfile order
|
70
|
+
run("Bundler.require(:not)")
|
71
|
+
out.split("\n").sort.should == ['seven', 'three']
|
72
|
+
end
|
73
|
+
|
74
|
+
it "allows requiring gems with non standard names explicitly" do
|
75
|
+
run "Bundler.require ; require 'mofive'"
|
76
|
+
out.should == "two\nfive"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "raises an exception if a require is specified but the file does not exist" do
|
80
|
+
gemfile <<-G
|
81
|
+
path "#{lib_path}"
|
82
|
+
gem "two", :require => 'fail'
|
83
|
+
G
|
84
|
+
|
85
|
+
run <<-R
|
86
|
+
begin
|
87
|
+
Bundler.require
|
88
|
+
rescue LoadError => e
|
89
|
+
puts e.message
|
90
|
+
end
|
91
|
+
R
|
92
|
+
out.should == 'no such file to load -- fail'
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "using bundle exec" do
|
96
|
+
it "requires the locked gems" do
|
97
|
+
bundle "exec ruby -e 'Bundler.require'"
|
98
|
+
out.should eq("two")
|
99
|
+
|
100
|
+
bundle "exec ruby -e 'Bundler.require(:bar)'"
|
101
|
+
out.should eq("baz\nqux")
|
102
|
+
|
103
|
+
bundle "exec ruby -e 'Bundler.require(:default, :bar)'"
|
104
|
+
out.should == "baz\nqux\ntwo"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "order" do
|
109
|
+
before(:each) do
|
110
|
+
build_lib "one", "1.0.0" do |s|
|
111
|
+
s.write "lib/one.rb", <<-ONE
|
112
|
+
if defined?(Two)
|
113
|
+
Two.two
|
114
|
+
else
|
115
|
+
puts "two_not_loaded"
|
116
|
+
end
|
117
|
+
puts 'one'
|
118
|
+
ONE
|
119
|
+
end
|
120
|
+
|
121
|
+
build_lib "two", "1.0.0" do |s|
|
122
|
+
s.write "lib/two.rb", <<-TWO
|
123
|
+
module Two
|
124
|
+
def self.two
|
125
|
+
puts 'module_two'
|
126
|
+
end
|
127
|
+
end
|
128
|
+
puts 'two'
|
129
|
+
TWO
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it "works when the gems are in the Gemfile in the correct order" do
|
134
|
+
gemfile <<-G
|
135
|
+
path "#{lib_path}"
|
136
|
+
gem "two"
|
137
|
+
gem "one"
|
138
|
+
G
|
139
|
+
|
140
|
+
run "Bundler.require"
|
141
|
+
out.should eq("two\nmodule_two\none")
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "a gem with different requires for different envs" do
|
145
|
+
before(:each) do
|
146
|
+
build_gem "multi_gem", :to_system => true do |s|
|
147
|
+
s.write "lib/one.rb", "puts 'ONE'"
|
148
|
+
s.write "lib/two.rb", "puts 'TWO'"
|
149
|
+
end
|
150
|
+
|
151
|
+
install_gemfile <<-G
|
152
|
+
gem "multi_gem", :require => "one", :group => :one
|
153
|
+
gem "multi_gem", :require => "two", :group => :two
|
154
|
+
G
|
155
|
+
end
|
156
|
+
|
157
|
+
it "requires both with Bundler.require(both)" do
|
158
|
+
run "Bundler.require(:one, :two)"
|
159
|
+
out.should == "ONE\nTWO"
|
160
|
+
end
|
161
|
+
|
162
|
+
it "requires one with Bundler.require(:one)" do
|
163
|
+
run "Bundler.require(:one)"
|
164
|
+
out.should == "ONE"
|
165
|
+
end
|
166
|
+
|
167
|
+
it "requires :two with Bundler.require(:two)" do
|
168
|
+
run "Bundler.require(:two)"
|
169
|
+
out.should == "TWO"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
it "fails when the gems are in the Gemfile in the wrong order" do
|
174
|
+
gemfile <<-G
|
175
|
+
path "#{lib_path}"
|
176
|
+
gem "one"
|
177
|
+
gem "two"
|
178
|
+
G
|
179
|
+
|
180
|
+
run "Bundler.require"
|
181
|
+
out.should eq("two_not_loaded\none\ntwo")
|
182
|
+
end
|
183
|
+
|
184
|
+
describe "with busted gems" do
|
185
|
+
it "should be busted" do
|
186
|
+
build_gem "busted_require", :to_system => true do |s|
|
187
|
+
s.write "lib/busted_require.rb", "require 'no_such_file_omg'"
|
188
|
+
end
|
189
|
+
|
190
|
+
install_gemfile <<-G
|
191
|
+
gem "busted_require"
|
192
|
+
G
|
193
|
+
|
194
|
+
run "Bundler.require", :expect_err => true
|
195
|
+
err.should include("no such file to load -- no_such_file_omg")
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "Bundler.require with platform specific dependencies" do
|
202
|
+
it "does not require the gems that are pinned to other platforms" do
|
203
|
+
install_gemfile <<-G
|
204
|
+
source "file://#{gem_repo1}"
|
205
|
+
|
206
|
+
platforms :#{not_local_tag} do
|
207
|
+
gem "fail", :require => "omgomg"
|
208
|
+
end
|
209
|
+
|
210
|
+
gem "rack", "1.0.0"
|
211
|
+
G
|
212
|
+
|
213
|
+
run "Bundler.require", :expect_err => true
|
214
|
+
err.should be_empty
|
215
|
+
end
|
216
|
+
|
217
|
+
it "requires gems pinned to multiple platforms, including the current one" do
|
218
|
+
install_gemfile <<-G
|
219
|
+
source "file://#{gem_repo1}"
|
220
|
+
|
221
|
+
platforms :#{not_local_tag}, :#{local_tag} do
|
222
|
+
gem "rack", :require => "rack"
|
223
|
+
end
|
224
|
+
G
|
225
|
+
|
226
|
+
run "Bundler.require; puts RACK", :expect_err => true
|
227
|
+
|
228
|
+
out.should eq("1.0.0")
|
229
|
+
err.should be_empty
|
230
|
+
end
|
231
|
+
end
|