rkh-bundler 1.2.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/.travis.yml +42 -0
- data/CHANGELOG.md +1105 -0
- data/ISSUES.md +67 -0
- data/LICENSE +23 -0
- data/README.md +31 -0
- data/Rakefile +208 -0
- data/UPGRADING.md +103 -0
- data/bin/bundle +31 -0
- data/bundler.gemspec +31 -0
- data/lib/bundler.rb +353 -0
- data/lib/bundler/capistrano.rb +11 -0
- data/lib/bundler/cli.rb +693 -0
- data/lib/bundler/definition.rb +568 -0
- data/lib/bundler/dep_proxy.rb +43 -0
- data/lib/bundler/dependency.rb +134 -0
- data/lib/bundler/deployment.rb +58 -0
- data/lib/bundler/dsl.rb +256 -0
- data/lib/bundler/endpoint_specification.rb +78 -0
- data/lib/bundler/environment.rb +47 -0
- data/lib/bundler/fetcher.rb +225 -0
- data/lib/bundler/gem_helper.rb +162 -0
- data/lib/bundler/gem_helpers.rb +23 -0
- data/lib/bundler/gem_installer.rb +9 -0
- data/lib/bundler/gem_tasks.rb +2 -0
- data/lib/bundler/graph.rb +148 -0
- data/lib/bundler/index.rb +187 -0
- data/lib/bundler/installer.rb +190 -0
- data/lib/bundler/lazy_specification.rb +79 -0
- data/lib/bundler/lockfile_parser.rb +127 -0
- data/lib/bundler/match_platform.rb +13 -0
- data/lib/bundler/psyched_yaml.rb +15 -0
- data/lib/bundler/remote_specification.rb +57 -0
- data/lib/bundler/resolver.rb +486 -0
- data/lib/bundler/ruby_version.rb +94 -0
- data/lib/bundler/rubygems_ext.rb +153 -0
- data/lib/bundler/rubygems_integration.rb +394 -0
- data/lib/bundler/runtime.rb +233 -0
- data/lib/bundler/settings.rb +128 -0
- data/lib/bundler/setup.rb +23 -0
- data/lib/bundler/shared_helpers.rb +71 -0
- data/lib/bundler/source.rb +869 -0
- data/lib/bundler/spec_set.rb +137 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Executable.standalone +12 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.tt +22 -0
- data/lib/bundler/templates/newgem/README.md.tt +29 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
- data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/gitignore.tt +17 -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 +17 -0
- data/lib/bundler/ui.rb +88 -0
- data/lib/bundler/vendor/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net/http/persistent.rb +468 -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 +172 -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 +130 -0
- data/man/bundle-exec.ronn +111 -0
- data/man/bundle-install.ronn +335 -0
- data/man/bundle-package.ronn +59 -0
- data/man/bundle-update.ronn +176 -0
- data/man/bundle.ronn +83 -0
- data/man/gemfile.5.ronn +324 -0
- data/man/index.txt +6 -0
- data/spec/bundler/dsl_spec.rb +48 -0
- data/spec/bundler/gem_helper_spec.rb +174 -0
- data/spec/bundler/source_spec.rb +25 -0
- data/spec/cache/gems_spec.rb +239 -0
- data/spec/cache/git_spec.rb +124 -0
- data/spec/cache/path_spec.rb +103 -0
- data/spec/cache/platform_spec.rb +57 -0
- data/spec/install/deploy_spec.rb +211 -0
- data/spec/install/gems/c_ext_spec.rb +48 -0
- data/spec/install/gems/dependency_api_spec.rb +402 -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 +268 -0
- data/spec/install/gems/packed_spec.rb +84 -0
- data/spec/install/gems/platform_spec.rb +208 -0
- data/spec/install/gems/post_install_spec.rb +47 -0
- data/spec/install/gems/resolving_spec.rb +72 -0
- data/spec/install/gems/simple_case_spec.rb +814 -0
- data/spec/install/gems/standalone_spec.rb +260 -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 +170 -0
- data/spec/install/git_spec.rb +796 -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 +809 -0
- data/spec/other/check_spec.rb +265 -0
- data/spec/other/clean_spec.rb +492 -0
- data/spec/other/config_spec.rb +138 -0
- data/spec/other/console_spec.rb +54 -0
- data/spec/other/exec_spec.rb +229 -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 +87 -0
- data/spec/other/open_spec.rb +35 -0
- data/spec/other/outdated_spec.rb +93 -0
- data/spec/other/platform_spec.rb +881 -0
- data/spec/other/show_spec.rb +88 -0
- data/spec/quality_spec.rb +62 -0
- data/spec/realworld/edgecases_spec.rb +177 -0
- data/spec/resolver/basic_spec.rb +20 -0
- data/spec/resolver/platform_spec.rb +82 -0
- data/spec/runtime/executable_spec.rb +120 -0
- data/spec/runtime/load_spec.rb +107 -0
- data/spec/runtime/platform_spec.rb +90 -0
- data/spec/runtime/require_spec.rb +261 -0
- data/spec/runtime/setup_spec.rb +755 -0
- data/spec/runtime/with_clean_env_spec.rb +80 -0
- data/spec/spec_helper.rb +98 -0
- data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
- data/spec/support/artifice/endpoint.rb +54 -0
- data/spec/support/artifice/endpoint_500.rb +37 -0
- data/spec/support/artifice/endpoint_api_missing.rb +16 -0
- data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
- data/spec/support/artifice/endpoint_extra.rb +27 -0
- data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
- data/spec/support/artifice/endpoint_fallback.rb +18 -0
- data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
- data/spec/support/artifice/endpoint_redirect.rb +15 -0
- data/spec/support/builders.rb +604 -0
- data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
- data/spec/support/fakeweb/windows.rb +23 -0
- data/spec/support/helpers.rb +317 -0
- data/spec/support/indexes.rb +112 -0
- data/spec/support/matchers.rb +77 -0
- data/spec/support/path.rb +73 -0
- data/spec/support/platforms.rb +86 -0
- data/spec/support/ruby_ext.rb +20 -0
- data/spec/support/rubygems_ext.rb +37 -0
- data/spec/support/rubygems_hax/platform.rb +22 -0
- data/spec/support/sudo.rb +21 -0
- data/spec/update/gems_spec.rb +134 -0
- data/spec/update/git_spec.rb +196 -0
- data/spec/update/source_spec.rb +51 -0
- metadata +338 -0
@@ -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,261 @@
|
|
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
|
+
load_error_run <<-R, 'fail'
|
86
|
+
Bundler.require
|
87
|
+
R
|
88
|
+
|
89
|
+
err.should == "ZOMG LOAD ERROR"
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "with namespaced gems" do
|
93
|
+
before :each do
|
94
|
+
build_lib "jquery-rails", "1.0.0" do |s|
|
95
|
+
s.write "lib/jquery/rails.rb", "puts 'jquery/rails'"
|
96
|
+
end
|
97
|
+
lib_path('jquery-rails-1.0.0/lib/jquery-rails.rb').rmtree
|
98
|
+
end
|
99
|
+
|
100
|
+
it "requires gem names that are namespaced" do
|
101
|
+
gemfile <<-G
|
102
|
+
path '#{lib_path}'
|
103
|
+
gem 'jquery-rails'
|
104
|
+
G
|
105
|
+
|
106
|
+
run "Bundler.require"
|
107
|
+
out.should eq("jquery/rails")
|
108
|
+
end
|
109
|
+
|
110
|
+
it "does not mangle explictly given requires" do
|
111
|
+
gemfile <<-G
|
112
|
+
path "#{lib_path}"
|
113
|
+
gem 'jquery-rails', :require => 'jquery-rails'
|
114
|
+
G
|
115
|
+
|
116
|
+
load_error_run <<-R, 'jquery-rails'
|
117
|
+
Bundler.require
|
118
|
+
R
|
119
|
+
err.should == "ZOMG LOAD ERROR"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "using bundle exec" do
|
124
|
+
it "requires the locked gems" do
|
125
|
+
bundle "exec ruby -e 'Bundler.require'"
|
126
|
+
out.should eq("two")
|
127
|
+
|
128
|
+
bundle "exec ruby -e 'Bundler.require(:bar)'"
|
129
|
+
out.should eq("baz\nqux")
|
130
|
+
|
131
|
+
bundle "exec ruby -e 'Bundler.require(:default, :bar)'"
|
132
|
+
out.should == "baz\nqux\ntwo"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "order" do
|
137
|
+
before(:each) do
|
138
|
+
build_lib "one", "1.0.0" do |s|
|
139
|
+
s.write "lib/one.rb", <<-ONE
|
140
|
+
if defined?(Two)
|
141
|
+
Two.two
|
142
|
+
else
|
143
|
+
puts "two_not_loaded"
|
144
|
+
end
|
145
|
+
puts 'one'
|
146
|
+
ONE
|
147
|
+
end
|
148
|
+
|
149
|
+
build_lib "two", "1.0.0" do |s|
|
150
|
+
s.write "lib/two.rb", <<-TWO
|
151
|
+
module Two
|
152
|
+
def self.two
|
153
|
+
puts 'module_two'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
puts 'two'
|
157
|
+
TWO
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
it "works when the gems are in the Gemfile in the correct order" do
|
162
|
+
gemfile <<-G
|
163
|
+
path "#{lib_path}"
|
164
|
+
gem "two"
|
165
|
+
gem "one"
|
166
|
+
G
|
167
|
+
|
168
|
+
run "Bundler.require"
|
169
|
+
out.should eq("two\nmodule_two\none")
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "a gem with different requires for different envs" do
|
173
|
+
before(:each) do
|
174
|
+
build_gem "multi_gem", :to_system => true do |s|
|
175
|
+
s.write "lib/one.rb", "puts 'ONE'"
|
176
|
+
s.write "lib/two.rb", "puts 'TWO'"
|
177
|
+
end
|
178
|
+
|
179
|
+
install_gemfile <<-G
|
180
|
+
gem "multi_gem", :require => "one", :group => :one
|
181
|
+
gem "multi_gem", :require => "two", :group => :two
|
182
|
+
G
|
183
|
+
end
|
184
|
+
|
185
|
+
it "requires both with Bundler.require(both)" do
|
186
|
+
run "Bundler.require(:one, :two)"
|
187
|
+
out.should == "ONE\nTWO"
|
188
|
+
end
|
189
|
+
|
190
|
+
it "requires one with Bundler.require(:one)" do
|
191
|
+
run "Bundler.require(:one)"
|
192
|
+
out.should == "ONE"
|
193
|
+
end
|
194
|
+
|
195
|
+
it "requires :two with Bundler.require(:two)" do
|
196
|
+
run "Bundler.require(:two)"
|
197
|
+
out.should == "TWO"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
it "fails when the gems are in the Gemfile in the wrong order" do
|
202
|
+
gemfile <<-G
|
203
|
+
path "#{lib_path}"
|
204
|
+
gem "one"
|
205
|
+
gem "two"
|
206
|
+
G
|
207
|
+
|
208
|
+
run "Bundler.require"
|
209
|
+
out.should eq("two_not_loaded\none\ntwo")
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "with busted gems" do
|
213
|
+
it "should be busted" do
|
214
|
+
build_gem "busted_require", :to_system => true do |s|
|
215
|
+
s.write "lib/busted_require.rb", "require 'no_such_file_omg'"
|
216
|
+
end
|
217
|
+
|
218
|
+
install_gemfile <<-G
|
219
|
+
gem "busted_require"
|
220
|
+
G
|
221
|
+
|
222
|
+
load_error_run <<-R, 'no_such_file_omg'
|
223
|
+
Bundler.require
|
224
|
+
R
|
225
|
+
err.should == 'ZOMG LOAD ERROR'
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "Bundler.require with platform specific dependencies" do
|
232
|
+
it "does not require the gems that are pinned to other platforms" do
|
233
|
+
install_gemfile <<-G
|
234
|
+
source "file://#{gem_repo1}"
|
235
|
+
|
236
|
+
platforms :#{not_local_tag} do
|
237
|
+
gem "fail", :require => "omgomg"
|
238
|
+
end
|
239
|
+
|
240
|
+
gem "rack", "1.0.0"
|
241
|
+
G
|
242
|
+
|
243
|
+
run "Bundler.require", :expect_err => true
|
244
|
+
err.should be_empty
|
245
|
+
end
|
246
|
+
|
247
|
+
it "requires gems pinned to multiple platforms, including the current one" do
|
248
|
+
install_gemfile <<-G
|
249
|
+
source "file://#{gem_repo1}"
|
250
|
+
|
251
|
+
platforms :#{not_local_tag}, :#{local_tag} do
|
252
|
+
gem "rack", :require => "rack"
|
253
|
+
end
|
254
|
+
G
|
255
|
+
|
256
|
+
run "Bundler.require; puts RACK", :expect_err => true
|
257
|
+
|
258
|
+
out.should eq("1.0.0")
|
259
|
+
err.should be_empty
|
260
|
+
end
|
261
|
+
end
|