blob: 5194ab80511df7d6d79ec660e5c97756a8b4dcc8 (
plain)
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
|
# frozen_string_literal: true
require "spec_helper"
describe "bundle package" do
context "with --gemfile" do
it "finds the gemfile" do
gemfile bundled_app("NotGemfile"), <<-G
source "file://#{gem_repo1}"
gem 'rack'
G
bundle "package --gemfile=NotGemfile"
ENV["BUNDLE_GEMFILE"] = "NotGemfile"
should_be_installed "rack 1.0.0"
end
end
context "with --all" do
context "without a gemspec" do
it "caches all dependencies except bundler itself" do
gemfile <<-D
source "file://#{gem_repo1}"
gem 'rack'
gem 'bundler'
D
bundle "package --all"
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
end
end
context "with a gemspec" do
before do
File.open(bundled_app("mygem.gemspec"), "w") do |f|
f.write <<-G
Gem::Specification.new do |s|
s.name = "mygem"
s.version = "0.1.1"
s.add_development_dependency "nokogiri", "=1.4.2"
end
G
end
end
it "caches all dependencies except bundler and the gemspec specified gem" do
gemfile <<-D
source "file://#{gem_repo1}"
gem 'rack'
gemspec
D
bundle "package --all"
sleep 20
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
expect(bundled_app("vendor/cache/mygem-0.1.1.gem")).to_not exist
expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
end
end
end
context "with --path" do
it "sets root directory for gems" do
gemfile <<-D
source "file://#{gem_repo1}"
gem 'rack'
D
bundle "package --path=#{bundled_app("test")}"
should_be_installed "rack 1.0.0"
expect(bundled_app("test/vendor/cache/")).to exist
end
end
context "with --no-install" do
it "puts the gems in vendor/cache but does not install them" do
gemfile <<-D
source "file://#{gem_repo1}"
gem 'rack'
D
bundle "package --no-install"
should_not_be_installed "rack 1.0.0", :expect_err => true
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
end
end
context "with --all-platforms" do
it "puts the gems in vendor/cache even for other rubies", :ruby => "2.1" do
gemfile <<-D
source "file://#{gem_repo1}"
gem 'rack', :platforms => :ruby_19
D
bundle "package --all-platforms"
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
end
end
end
describe "bundle install with gem sources" do
describe "when cached and locked" do
it "does not hit the remote at all" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rack"
G
bundle :pack
simulate_new_machine
FileUtils.rm_rf gem_repo2
bundle "install --local"
should_be_installed "rack 1.0.0"
end
it "does not hit the remote at all" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rack"
G
bundle :pack
simulate_new_machine
FileUtils.rm_rf gem_repo2
bundle "install --deployment"
should_be_installed "rack 1.0.0"
end
it "does not reinstall already-installed gems" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
bundle :pack
build_gem "rack", "1.0.0", :path => bundled_app("vendor/cache") do |s|
s.write "lib/rack.rb", "raise 'omg'"
end
bundle :install
expect(err).to be_empty
should_be_installed "rack 1.0"
end
it "ignores cached gems for the wrong platform" do
simulate_platform "java" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "platform_specific"
G
bundle :pack
end
simulate_new_machine
simulate_platform "ruby" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "platform_specific"
G
run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
expect(out).to eq("1.0.0 RUBY")
end
end
it "does not update the cache if --no-cache is passed" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
bundled_app("vendor/cache").mkpath
expect(bundled_app("vendor/cache").children).to be_empty
bundle "install --no-cache"
expect(bundled_app("vendor/cache").children).to be_empty
end
end
end
|