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
|
require "spec_helper"
describe "gemcutter's dependency API" do
let(:source_uri) { "http://localgemserver.test" }
it "should use the API" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
G
bundle :install, :artifice => "endpoint"
out.should include("Fetching dependency information from the API at #{source_uri}")
should_be_installed "rack 1.0.0"
end
it "should handle nested dependencies" do
gemfile <<-G
source "#{source_uri}"
gem "rails"
G
bundle :install, :artifice => "endpoint"
out.should include("Fetching dependency information from the API at #{source_uri}/...")
should_be_installed(
"rails 2.3.2",
"actionpack 2.3.2",
"activerecord 2.3.2",
"actionmailer 2.3.2",
"activeresource 2.3.2",
"activesupport 2.3.2")
end
it "should handle multiple gem dependencies on the same gem" do
gemfile <<-G
source "#{source_uri}"
gem "net-sftp"
G
bundle :install, :artifice => "endpoint"
should_be_installed "net-sftp 1.1.1"
end
it "should use the endpoint when using --deployment" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
G
bundle :install, :artifice => "endpoint"
bundle "install --deployment", :artifice => "endpoint"
out.should include("Fetching dependency information from the API at #{source_uri}")
should_be_installed "rack 1.0.0"
end
it "passes basic authentication details" do
uri = URI.parse(source_uri)
uri.user = "hello"
uri.password = "there"
gemfile <<-G
source "#{uri}"
gem "rack"
G
bundle :install, :artifice => "endpoint_basic_authentication"
out.should include("Fetching dependency information from the API at #{uri}")
should_be_installed "rack 1.0.0"
end
it "handles git dependencies that are in rubygems" do
build_git "foo" do |s|
s.executables = "foobar"
s.add_dependency "rails", "2.3.2"
end
install_gemfile <<-G
source "file://#{gem_repo1}"
git "#{lib_path('foo-1.0')}" do
gem 'foo'
end
G
should_be_installed("rails 2.3.2")
end
it "falls back when the API errors out" do
simulate_platform mswin
gemfile <<-G
source "#{source_uri}"
gem "rcov"
G
bundle :install, :fakeweb => "windows"
out.should include("\nError using the API\nFetching source index for #{source_uri}")
should_be_installed "rcov 1.0.0"
end
it "falls back when hitting the Gemcutter Dependency Limit" do
gemfile <<-G
source "#{source_uri}"
gem "activesupport"
gem "actionpack"
gem "actionmailer"
gem "activeresource"
gem "thin"
gem "rack"
gem "rails"
G
bundle :install, :artifice => "endpoint_fallback"
out.should include("\nError using the API\nFetching source index for #{source_uri}")
should_be_installed(
"activesupport 2.3.2",
"actionpack 2.3.2",
"actionmailer 2.3.2",
"activeresource 2.3.2",
"activesupport 2.3.2",
"thin 1.0.0",
"rack 1.0.0",
"rails 2.3.2")
end
it "falls back when Gemcutter API doesn't return proper Marshal format" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
G
bundle :install, :artifice => "endpoint_marshal_fail"
out.should include("\nError using the API\nFetching source index for #{source_uri}")
should_be_installed "rack 1.0.0"
end
it "timeouts when Bundler::Fetcher redirects too much" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
G
bundle :install, :artifice => "endpoint_redirect"
out.should match(/Too many redirects/)
end
it "should use the modern index when the --full-index" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
G
bundle "install --full-index", :artifice => "endpoint"
out.should include("Fetching source index for #{source_uri}")
should_be_installed "rack 1.0.0"
end
it "fetches again when more dependencies are found in subsequent sources" do
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
end
FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
end
gemfile <<-G
source "#{source_uri}"
source "#{source_uri}/extra"
gem "back_deps"
G
bundle :install, :artifice => "endpoint_extra"
should_be_installed "back_deps 1.0"
end
it "does not fetch every specs if the index of gems is large when doing back deps" do
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
end
build_gem "missing"
# need to hit the limit
1.upto(Bundler::Source::Rubygems::FORCE_MODERN_INDEX_LIMIT) do |i|
build_gem "gem#{i}"
end
FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
end
gemfile <<-G
source "#{source_uri}"
source "#{source_uri}/extra"
gem "back_deps"
G
bundle :install, :artifice => "endpoint_extra_missing"
should_be_installed "back_deps 1.0"
end
it "uses the endpoint if all sources support it" do
gemfile <<-G
source "#{source_uri}"
gem 'foo'
G
bundle :install, :artifice => "endpoint_api_missing"
should_be_installed "foo 1.0"
end
end
|