1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
require "spec_helper"
describe "bundle exec" do
before :each do
system_gems "rack-1.0.0", "rack-0.9.1"
end
it "activates the correct gem" do
gemfile <<-G
gem "rack", "0.9.1"
G
bundle "exec rackup"
out.should == "0.9.1"
end
it "works when the bins are in ~/.bundle" do
install_gemfile <<-G
gem "rack"
G
bundle "exec rackup"
out.should == "1.0.0"
end
it "works when running from a random directory" do
install_gemfile <<-G
gem "rack"
G
bundle "exec 'cd #{tmp('gems')} && rackup'"
out.should == "1.0.0"
end
it "handles different versions in different bundles" do
build_repo2 do
build_gem "rack_two", "1.0.0" do |s|
s.executables = "rackup"
end
end
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", "0.9.1"
G
Dir.chdir bundled_app2 do
install_gemfile bundled_app2('Gemfile'), <<-G
source "file://#{gem_repo2}"
gem "rack_two", "1.0.0"
G
end
bundle "exec rackup"
check out.should == "0.9.1"
Dir.chdir bundled_app2 do
bundle "exec rackup"
out.should == "1.0.0"
end
end
it "handles gems installed with --without" do
install_gemfile <<-G, :without => :middleware
source "file://#{gem_repo1}"
gem "rack" # rack 0.9.1 and 1.0 exist
group :middleware do
gem "rack_middleware" # rack_middleware depends on rack 0.9.1
end
G
bundle "exec rackup"
check out.should == "0.9.1"
should_not_be_installed "rack_middleware 1.0"
end
it "should not duplicate already exec'ed RUBYOPT or PATH" do
install_gemfile <<-G
gem "rack"
G
rubyopt = "-I#{bundler_path} -rbundler/setup"
bundle "exec 'echo $RUBYOPT'"
out.should have_rubyopts(rubyopt)
bundle "exec 'echo $RUBYOPT'", :env => {"RUBYOPT" => rubyopt}
out.should have_rubyopts(rubyopt)
end
it "errors nicely when the argument doesn't exist" do
install_gemfile <<-G
gem "rack"
G
bundle "exec foobarbaz"
out.should include("bundler: command not found: foobarbaz")
out.should include("Install missing gem binaries with `bundle install`")
end
it "errors nicely when the argument is not executable" do
install_gemfile <<-G
gem "rack"
G
bundle "exec touch foo"
bundle "exec ./foo"
out.should include("bundler: not executable: ./foo")
end
describe "with gem binaries" do
describe "run from a random directory" do
before(:each) do
install_gemfile <<-G
gem "rack"
G
end
it "works when unlocked" do
bundle "exec 'cd #{tmp('gems')} && rackup'"
out.should == "1.0.0"
end
it "works when locked" do
bundle "lock"
should_be_locked
bundle "exec 'cd #{tmp('gems')} && rackup'"
out.should == "1.0.0"
end
end
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
it "works when unlocked" do
bundle "exec fizz"
out.should == "1.0"
end
it "works when locked" do
bundle "lock"
should_be_locked
bundle "exec fizz"
out.should == "1.0"
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
describe "bundling bundler" do
before(:each) do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
bundle "install vendor --disable-shared-gems"
end
it "does not explode with --disable-shared-gems" do
bundle "exec bundle check", :exit_status => true
exitstatus.should == 0
end
it "does not explode when starting with Bundler.setup" do
ruby <<-R
require "rubygems"
require "bundler"
Bundler.setup
puts `bundle check`
puts $?
R
out.should include("satisfied")
out.should include("\n0")
end
end
end
|