blob: 088a34709d7b779bbc12a5b877933b72650f04be (
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
|
require "spec_helper"
describe "bundle cache" do
describe "when there are only gemsources" do
before :each do
gemfile <<-G
gem 'rack'
G
system_gems "rack-1.0.0"
bundle :cache
end
it "copies the .gem file to vendor/cache" do
bundled_app("vendor/cache/rack-1.0.0.gem").should exist
end
it "uses the cache as a source when installing gems" do
system_gems []
bundle "install --local"
should_be_installed("rack 1.0.0")
end
it "does not reinstall gems from the cache if they exist on the system" do
build_gem "rack", "1.0.0", :path => bundled_app('vendor/cache') do |s|
s.write "lib/rack.rb", "RACK = 'FAIL'"
end
install_gemfile <<-G
gem "rack"
G
should_be_installed("rack 1.0.0")
end
it "does not reinstall gems from the cache if they exist in the bundle" do
system_gems "rack-1.0.0"
gemfile <<-G
gem "rack"
G
build_gem "rack", "1.0.0", :path => bundled_app('vendor/cache') do |s|
s.write "lib/rack.rb", "RACK = 'FAIL'"
end
bundle "install --local"
should_be_installed("rack 1.0.0")
end
end
describe "when there are also git sources" do
it "still works" do
build_git "foo"
system_gems "rack-1.0.0"
install_gemfile <<-G
source "file://#{gem_repo1}"
git "#{lib_path("foo-1.0")}" do
gem 'foo'
end
gem 'rack'
G
bundle :cache
system_gems []
bundle "install --local"
should_be_installed("rack 1.0.0", "foo 1.0")
end
end
describe "when previously cached" do
before :each do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rack"
gem "actionpack"
G
bundle :cache
cached_gem("rack-1.0.0").should exist
cached_gem("actionpack-2.3.2").should exist
cached_gem("activesupport-2.3.2").should exist
end
it "re-caches during install" do
cached_gem("rack-1.0.0").rmtree
bundle :install
out.should include("Updating .gem files in vendor/cache")
cached_gem("rack-1.0.0").should exist
end
it "adds and removes when gems are updated" do
update_repo2
bundle 'update'
cached_gem("rack-1.2").should exist
cached_gem("rack-1.0.0").should_not exist
end
it "adds new gems and dependencies" do
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rails"
G
cached_gem("rails-2.3.2").should exist
cached_gem("activerecord-2.3.2").should exist
end
it "removes .gems for removed gems and dependencies" do
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rack"
G
cached_gem("rack-1.0.0").should exist
cached_gem("actionpack-2.3.2").should_not exist
cached_gem("activesupport-2.3.2").should_not exist
end
it "doesn't remove gems that are for another platform" do
simulate_platform "java" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "platform_specific"
G
bundle :cache
cached_gem("platform_specific-1.0-java").should exist
end
simulate_new_machine
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "platform_specific"
G
cached_gem("platform_specific-1.0-#{Gem::Platform.local}").should exist
cached_gem("platform_specific-1.0-java").should exist
end
it "doesn't remove gems with mismatched :rubygems_version or :date" do
cached_gem("rack-1.0.0").rmtree
build_gem "rack", "1.0.0",
:path => bundled_app('vendor/cache'),
:rubygems_version => "1.3.2"
simulate_new_machine
bundle :install
cached_gem("rack-1.0.0").should exist
end
it "handles directories and non .gem files in the cache" do
bundled_app("vendor/cache/foo").mkdir
File.open(bundled_app("vendor/cache/bar"), 'w'){|f| f.write("not a gem") }
bundle :cache
end
it "does not say that it is removing gems when it isn't actually doing so" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
bundle "cache"
bundle "install"
out.should_not =~ /removing/i
end
end
end
|