honkster-bundler 1.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -0
- data/CHANGELOG.md +547 -0
- data/ISSUES.md +32 -0
- data/LICENSE +20 -0
- data/README.md +29 -0
- data/Rakefile +150 -0
- data/UPGRADING.md +103 -0
- data/bin/bundle +21 -0
- data/bundler.gemspec +30 -0
- data/lib/bundler.rb +268 -0
- data/lib/bundler/capistrano.rb +11 -0
- data/lib/bundler/cli.rb +515 -0
- data/lib/bundler/definition.rb +427 -0
- data/lib/bundler/dependency.rb +114 -0
- data/lib/bundler/deployment.rb +37 -0
- data/lib/bundler/dsl.rb +245 -0
- data/lib/bundler/environment.rb +47 -0
- data/lib/bundler/gem_helper.rb +145 -0
- data/lib/bundler/graph.rb +130 -0
- data/lib/bundler/index.rb +114 -0
- data/lib/bundler/installer.rb +84 -0
- data/lib/bundler/lazy_specification.rb +71 -0
- data/lib/bundler/lockfile_parser.rb +108 -0
- data/lib/bundler/remote_specification.rb +59 -0
- data/lib/bundler/resolver.rb +454 -0
- data/lib/bundler/rubygems_ext.rb +203 -0
- data/lib/bundler/runtime.rb +148 -0
- data/lib/bundler/settings.rb +117 -0
- data/lib/bundler/setup.rb +15 -0
- data/lib/bundler/shared_helpers.rb +151 -0
- data/lib/bundler/source.rb +662 -0
- data/lib/bundler/spec_set.rb +134 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -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 +3 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -0
- data/lib/bundler/ui.rb +60 -0
- data/lib/bundler/vendor/thor.rb +319 -0
- data/lib/bundler/vendor/thor/actions.rb +297 -0
- data/lib/bundler/vendor/thor/actions/create_file.rb +105 -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 +229 -0
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +104 -0
- data/lib/bundler/vendor/thor/base.rb +556 -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/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 +174 -0
- data/lib/bundler/vendor/thor/shell.rb +88 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +275 -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 +114 -0
- data/lib/bundler/vendor/thor/util.rb +229 -0
- data/lib/bundler/vendor/thor/version.rb +3 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +9 -0
- data/man/bundle-config.ronn +90 -0
- data/man/bundle-exec.ronn +98 -0
- data/man/bundle-install.ronn +310 -0
- data/man/bundle-package.ronn +59 -0
- data/man/bundle-update.ronn +176 -0
- data/man/bundle.ronn +77 -0
- data/man/gemfile.5.ronn +273 -0
- data/man/index.txt +6 -0
- data/spec/cache/gems_spec.rb +205 -0
- data/spec/cache/git_spec.rb +9 -0
- data/spec/cache/path_spec.rb +27 -0
- data/spec/cache/platform_spec.rb +57 -0
- data/spec/install/deploy_spec.rb +197 -0
- data/spec/install/deprecated_spec.rb +43 -0
- data/spec/install/gems/c_ext_spec.rb +48 -0
- data/spec/install/gems/env_spec.rb +107 -0
- data/spec/install/gems/flex_spec.rb +272 -0
- data/spec/install/gems/groups_spec.rb +228 -0
- data/spec/install/gems/packed_spec.rb +72 -0
- data/spec/install/gems/platform_spec.rb +195 -0
- data/spec/install/gems/resolving_spec.rb +72 -0
- data/spec/install/gems/simple_case_spec.rb +749 -0
- data/spec/install/gems/sudo_spec.rb +77 -0
- data/spec/install/gems/win32_spec.rb +26 -0
- data/spec/install/gemspec_spec.rb +96 -0
- data/spec/install/git_spec.rb +553 -0
- data/spec/install/invalid_spec.rb +17 -0
- data/spec/install/path_spec.rb +329 -0
- data/spec/install/upgrade_spec.rb +26 -0
- data/spec/lock/flex_spec.rb +650 -0
- data/spec/lock/git_spec.rb +35 -0
- data/spec/other/check_spec.rb +221 -0
- data/spec/other/config_spec.rb +40 -0
- data/spec/other/console_spec.rb +54 -0
- data/spec/other/exec_spec.rb +241 -0
- data/spec/other/ext_spec.rb +16 -0
- data/spec/other/gem_helper_spec.rb +126 -0
- data/spec/other/help_spec.rb +36 -0
- data/spec/other/init_spec.rb +40 -0
- data/spec/other/newgem_spec.rb +24 -0
- data/spec/other/open_spec.rb +35 -0
- data/spec/other/show_spec.rb +82 -0
- data/spec/pack/gems_spec.rb +22 -0
- data/spec/quality_spec.rb +55 -0
- data/spec/resolver/basic_spec.rb +20 -0
- data/spec/resolver/platform_spec.rb +57 -0
- data/spec/runtime/environment_rb_spec.rb +162 -0
- data/spec/runtime/executable_spec.rb +110 -0
- data/spec/runtime/load_spec.rb +102 -0
- data/spec/runtime/platform_spec.rb +90 -0
- data/spec/runtime/require_spec.rb +231 -0
- data/spec/runtime/setup_spec.rb +412 -0
- data/spec/runtime/with_clean_env_spec.rb +15 -0
- data/spec/spec_helper.rb +82 -0
- data/spec/support/builders.rb +566 -0
- data/spec/support/helpers.rb +243 -0
- data/spec/support/indexes.rb +113 -0
- data/spec/support/matchers.rb +89 -0
- data/spec/support/path.rb +71 -0
- data/spec/support/platforms.rb +49 -0
- data/spec/support/ruby_ext.rb +19 -0
- data/spec/support/rubygems_ext.rb +30 -0
- data/spec/support/rubygems_hax/rubygems_plugin.rb +9 -0
- data/spec/support/sudo.rb +21 -0
- data/spec/update/gems_spec.rb +112 -0
- data/spec/update/git_spec.rb +159 -0
- data/spec/update/source_spec.rb +50 -0
- metadata +251 -0
@@ -0,0 +1,243 @@
|
|
1
|
+
module Spec
|
2
|
+
module Helpers
|
3
|
+
def reset!
|
4
|
+
@in_p, @out_p, @err_p = nil, nil, nil
|
5
|
+
Dir["#{tmp}/{gems/*,*}"].each do |dir|
|
6
|
+
next if %(base remote1 gems rubygems_1_3_5 rubygems_1_3_6 rubygems_master).include?(File.basename(dir))
|
7
|
+
unless ENV['BUNDLER_SUDO_TESTS']
|
8
|
+
FileUtils.rm_rf(dir)
|
9
|
+
else
|
10
|
+
`sudo rm -rf #{dir}`
|
11
|
+
end
|
12
|
+
end
|
13
|
+
FileUtils.mkdir_p(tmp)
|
14
|
+
FileUtils.mkdir_p(home)
|
15
|
+
Gem.sources = ["file://#{gem_repo1}/"]
|
16
|
+
Gem.configuration.write
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :out, :err, :exitstatus
|
20
|
+
|
21
|
+
def in_app_root(&blk)
|
22
|
+
Dir.chdir(bundled_app, &blk)
|
23
|
+
end
|
24
|
+
|
25
|
+
def in_app_root2(&blk)
|
26
|
+
Dir.chdir(bundled_app2, &blk)
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(cmd, *args)
|
30
|
+
opts = args.last.is_a?(Hash) ? args.pop : {}
|
31
|
+
expect_err = opts.delete(:expect_err)
|
32
|
+
groups = args.map {|a| a.inspect }.join(", ")
|
33
|
+
|
34
|
+
if opts[:lite_runtime]
|
35
|
+
setup = "require 'rubygems' ; require 'bundler/setup' ; Bundler.setup(#{groups})\n"
|
36
|
+
else
|
37
|
+
setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
|
38
|
+
end
|
39
|
+
|
40
|
+
@out = ruby(setup + cmd, :expect_err => expect_err)
|
41
|
+
end
|
42
|
+
|
43
|
+
def lib
|
44
|
+
File.expand_path('../../../lib', __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def bundle(cmd, options = {})
|
48
|
+
expect_err = options.delete(:expect_err)
|
49
|
+
exitstatus = options.delete(:exitstatus)
|
50
|
+
options["no-color"] = true unless options.key?("no-color") || cmd.to_s[0..3] == "exec"
|
51
|
+
|
52
|
+
env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
|
53
|
+
args = options.map do |k,v|
|
54
|
+
v == true ? " --#{k}" : " --#{k} #{v}" if v
|
55
|
+
end.join
|
56
|
+
gemfile = File.expand_path('../../../bin/bundle', __FILE__)
|
57
|
+
cmd = "#{env}#{Gem.ruby} -I#{lib} #{gemfile} #{cmd}#{args}"
|
58
|
+
|
59
|
+
if exitstatus
|
60
|
+
sys_status(cmd)
|
61
|
+
else
|
62
|
+
sys_exec(cmd, expect_err){|i| yield i if block_given? }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def ruby(ruby, options = {})
|
67
|
+
expect_err = options.delete(:expect_err)
|
68
|
+
ruby.gsub!(/["`\$]/) {|m| "\\#{m}" }
|
69
|
+
sys_exec(%'#{Gem.ruby} -I#{lib} -e "#{ruby}"', expect_err)
|
70
|
+
end
|
71
|
+
|
72
|
+
def gembin(cmd)
|
73
|
+
lib = File.expand_path("../../../lib", __FILE__)
|
74
|
+
old, ENV['RUBYOPT'] = ENV['RUBYOPT'], "#{ENV['RUBYOPT']} -I#{lib}"
|
75
|
+
cmd = bundled_app("bin/#{cmd}") unless cmd.to_s.include?("/")
|
76
|
+
sys_exec(cmd.to_s)
|
77
|
+
ensure
|
78
|
+
ENV['RUBYOPT'] = old
|
79
|
+
end
|
80
|
+
|
81
|
+
def sys_exec(cmd, expect_err = false)
|
82
|
+
Open3.popen3(cmd.to_s) do |stdin, stdout, stderr|
|
83
|
+
@in_p, @out_p, @err_p = stdin, stdout, stderr
|
84
|
+
|
85
|
+
yield @in_p if block_given?
|
86
|
+
@in_p.close
|
87
|
+
|
88
|
+
@out = @out_p.read_available_bytes.strip
|
89
|
+
@err = @err_p.read_available_bytes.strip
|
90
|
+
end
|
91
|
+
|
92
|
+
puts @err unless expect_err || @err.empty? || !$show_err
|
93
|
+
@out
|
94
|
+
end
|
95
|
+
|
96
|
+
def sys_status(cmd)
|
97
|
+
@err = nil
|
98
|
+
@out = %x{#{cmd}}.strip
|
99
|
+
@exitstatus = $?.exitstatus
|
100
|
+
end
|
101
|
+
|
102
|
+
def config(config = nil)
|
103
|
+
path = bundled_app('.bundle/config')
|
104
|
+
return YAML.load_file(path) unless config
|
105
|
+
FileUtils.mkdir_p(File.dirname(path))
|
106
|
+
File.open(path, 'w') do |f|
|
107
|
+
f.puts config.to_yaml
|
108
|
+
end
|
109
|
+
config
|
110
|
+
end
|
111
|
+
|
112
|
+
def gemfile(*args)
|
113
|
+
path = bundled_app("Gemfile")
|
114
|
+
path = args.shift if Pathname === args.first
|
115
|
+
str = args.shift || ""
|
116
|
+
path.dirname.mkpath
|
117
|
+
File.open(path.to_s, 'w') do |f|
|
118
|
+
f.puts str
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def lockfile(*args)
|
123
|
+
path = bundled_app("Gemfile.lock")
|
124
|
+
path = args.shift if Pathname === args.first
|
125
|
+
str = args.shift || ""
|
126
|
+
|
127
|
+
# Trim the leading spaces
|
128
|
+
spaces = str[/\A\s+/, 0] || ""
|
129
|
+
str.gsub!(/^#{spaces}/, '')
|
130
|
+
|
131
|
+
File.open(path.to_s, 'w') do |f|
|
132
|
+
f.puts str
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def install_gemfile(*args)
|
137
|
+
gemfile(*args)
|
138
|
+
opts = args.last.is_a?(Hash) ? args.last : {}
|
139
|
+
bundle :install, opts
|
140
|
+
end
|
141
|
+
|
142
|
+
def install_gems(*gems)
|
143
|
+
gems.each do |g|
|
144
|
+
path = "#{gem_repo1}/gems/#{g}.gem"
|
145
|
+
|
146
|
+
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
|
147
|
+
|
148
|
+
gem_command :install, "--no-rdoc --no-ri --ignore-dependencies #{path}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
alias install_gem install_gems
|
153
|
+
|
154
|
+
def with_gem_path_as(path)
|
155
|
+
gem_home, gem_path = ENV['GEM_HOME'], ENV['GEM_PATH']
|
156
|
+
ENV['GEM_HOME'], ENV['GEM_PATH'] = path.to_s, path.to_s
|
157
|
+
yield
|
158
|
+
ensure
|
159
|
+
ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
|
160
|
+
end
|
161
|
+
|
162
|
+
def break_git!
|
163
|
+
FileUtils.mkdir_p(tmp("broken_path"))
|
164
|
+
File.open(tmp("broken_path/git"), "w", 0755) do |f|
|
165
|
+
f.puts "#!/usr/bin/env ruby\nSTDERR.puts 'This is not the git you are looking for'\nexit 1"
|
166
|
+
end
|
167
|
+
|
168
|
+
ENV["PATH"] = "#{tmp("broken_path")}:#{ENV["PATH"]}"
|
169
|
+
end
|
170
|
+
|
171
|
+
def fake_groff!
|
172
|
+
FileUtils.mkdir_p(tmp("fake_groff"))
|
173
|
+
File.open(tmp("fake_groff/groff"), "w", 0755) do |f|
|
174
|
+
f.puts "#!/usr/bin/env ruby\nputs ARGV.inspect\n"
|
175
|
+
end
|
176
|
+
|
177
|
+
ENV["PATH"] = "#{tmp("fake_groff")}:#{ENV["PATH"]}"
|
178
|
+
end
|
179
|
+
|
180
|
+
def kill_path!
|
181
|
+
ENV["PATH"] = ""
|
182
|
+
end
|
183
|
+
|
184
|
+
def system_gems(*gems)
|
185
|
+
gems = gems.flatten
|
186
|
+
|
187
|
+
FileUtils.rm_rf(system_gem_path)
|
188
|
+
FileUtils.mkdir_p(system_gem_path)
|
189
|
+
|
190
|
+
Gem.clear_paths
|
191
|
+
|
192
|
+
gem_home, gem_path, path = ENV['GEM_HOME'], ENV['GEM_PATH'], ENV['PATH']
|
193
|
+
ENV['GEM_HOME'], ENV['GEM_PATH'] = system_gem_path.to_s, system_gem_path.to_s
|
194
|
+
|
195
|
+
install_gems(*gems)
|
196
|
+
if block_given?
|
197
|
+
begin
|
198
|
+
yield
|
199
|
+
ensure
|
200
|
+
ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
|
201
|
+
ENV['PATH'] = path
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def cache_gems(*gems)
|
207
|
+
gems = gems.flatten
|
208
|
+
|
209
|
+
FileUtils.rm_rf("#{bundled_app}/vendor/cache")
|
210
|
+
FileUtils.mkdir_p("#{bundled_app}/vendor/cache")
|
211
|
+
|
212
|
+
gems.each do |g|
|
213
|
+
path = "#{gem_repo1}/gems/#{g}.gem"
|
214
|
+
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
|
215
|
+
FileUtils.cp(path, "#{bundled_app}/vendor/cache")
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def simulate_new_machine
|
220
|
+
system_gems []
|
221
|
+
FileUtils.rm_rf default_bundle_path
|
222
|
+
FileUtils.rm_rf bundled_app('.bundle')
|
223
|
+
end
|
224
|
+
|
225
|
+
def simulate_platform(platform)
|
226
|
+
old, ENV['BUNDLER_SPEC_PLATFORM'] = ENV['BUNDLER_SPEC_PLATFORM'], platform.to_s
|
227
|
+
yield if block_given?
|
228
|
+
ensure
|
229
|
+
ENV['BUNDLER_SPEC_PLATFORM'] = old if block_given?
|
230
|
+
end
|
231
|
+
|
232
|
+
def simulate_bundler_version(version)
|
233
|
+
old, ENV['BUNDLER_SPEC_VERSION'] = ENV['BUNDLER_SPEC_VERSION'], version.to_s
|
234
|
+
yield if block_given?
|
235
|
+
ensure
|
236
|
+
ENV['BUNDLER_SPEC_VERSION'] = old if block_given?
|
237
|
+
end
|
238
|
+
|
239
|
+
def revision_for(path)
|
240
|
+
Dir.chdir(path) { `git rev-parse HEAD`.strip }
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module Spec
|
2
|
+
module Indexes
|
3
|
+
def dep(name, reqs = nil)
|
4
|
+
@deps ||= []
|
5
|
+
@deps << Bundler::Dependency.new(name, :version => reqs)
|
6
|
+
end
|
7
|
+
|
8
|
+
def platform(*args)
|
9
|
+
@platforms ||= []
|
10
|
+
@platforms.concat args.map { |p| Gem::Platform.new(p) }
|
11
|
+
end
|
12
|
+
|
13
|
+
alias platforms platform
|
14
|
+
|
15
|
+
def resolve
|
16
|
+
@platforms ||= ['ruby']
|
17
|
+
deps = []
|
18
|
+
@deps.each do |d|
|
19
|
+
@platforms.each do |p|
|
20
|
+
deps << Bundler::DepProxy.new(d, p)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
Bundler::Resolver.resolve(deps, @index)
|
24
|
+
end
|
25
|
+
|
26
|
+
def should_resolve_as(specs)
|
27
|
+
got = resolve
|
28
|
+
got = got.map { |s| s.full_name }.sort
|
29
|
+
|
30
|
+
got.should == specs.sort
|
31
|
+
end
|
32
|
+
|
33
|
+
def should_conflict_on(names)
|
34
|
+
begin
|
35
|
+
got = resolve
|
36
|
+
flunk "The resolve succeeded with: #{got.map { |s| s.full_name }.sort.inspect}"
|
37
|
+
rescue Bundler::VersionConflict => e
|
38
|
+
Array(names).sort.should == e.conflicts.sort
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def gem(*args, &blk)
|
43
|
+
build_spec(*args, &blk).first
|
44
|
+
end
|
45
|
+
|
46
|
+
def an_awesome_index
|
47
|
+
build_index do
|
48
|
+
gem "rack", %w(0.8 0.9 0.9.1 0.9.2 1.0 1.1)
|
49
|
+
gem "rack-mount", %w(0.4 0.5 0.5.1 0.5.2 0.6)
|
50
|
+
|
51
|
+
# --- Rails
|
52
|
+
versions "1.2.3 2.2.3 2.3.5 3.0.0.beta 3.0.0.beta1" do |version|
|
53
|
+
gem "activesupport", version
|
54
|
+
gem "actionpack", version do
|
55
|
+
dep "activesupport", version
|
56
|
+
if version >= v('3.0.0.beta')
|
57
|
+
dep "rack", '~> 1.1'
|
58
|
+
dep "rack-mount", ">= 0.5"
|
59
|
+
elsif version > v('2.3') then dep "rack", '~> 1.0.0'
|
60
|
+
elsif version > v('2.0.0') then dep "rack", '~> 0.9.0'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
gem "activerecord", version do
|
64
|
+
dep "activesupport", version
|
65
|
+
dep "arel", ">= 0.2" if version >= v('3.0.0.beta')
|
66
|
+
end
|
67
|
+
gem "actionmailer", version do
|
68
|
+
dep "activesupport", version
|
69
|
+
dep "actionmailer", version
|
70
|
+
end
|
71
|
+
if version < v('3.0.0.beta')
|
72
|
+
gem "railties", version do
|
73
|
+
dep "activerecord", version
|
74
|
+
dep "actionpack", version
|
75
|
+
dep "actionmailer", version
|
76
|
+
dep "activesupport", version
|
77
|
+
end
|
78
|
+
else
|
79
|
+
gem "railties", version
|
80
|
+
gem "rails", version do
|
81
|
+
dep "activerecord", version
|
82
|
+
dep "actionpack", version
|
83
|
+
dep "actionmailer", version
|
84
|
+
dep "activesupport", version
|
85
|
+
dep "railties", version
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
versions '1.0 1.2 1.2.1 1.2.2 1.3 1.3.0.1 1.3.5 1.4.0 1.4.2 1.4.2.1' do |version|
|
91
|
+
platforms "ruby java mswin32" do |platform|
|
92
|
+
next if version == v('1.4.2.1') && platform != pl('x86-mswin32')
|
93
|
+
next if version == v('1.4.2') && platform == pl('x86-mswin32')
|
94
|
+
gem "nokogiri", version, platform do
|
95
|
+
dep "weakling", ">= 0.0.3" if platform =~ 'java'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
versions '0.0.1 0.0.2 0.0.3' do |version|
|
101
|
+
gem "weakling", version #, pl('java')
|
102
|
+
end
|
103
|
+
|
104
|
+
# --- Rails related
|
105
|
+
versions '1.2.3 2.2.3 2.3.5' do |version|
|
106
|
+
gem "activemerchant", version do
|
107
|
+
dep "activesupport", ">= #{version}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Spec
|
2
|
+
module Matchers
|
3
|
+
RSpec::Matchers.define :have_dep do |*args|
|
4
|
+
dep = Bundler::Dependency.new(*args)
|
5
|
+
|
6
|
+
match do |actual|
|
7
|
+
actual.length == 1 && actual.all? { |d| d == dep }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec::Matchers.define :have_gem do |*args|
|
12
|
+
match do |actual|
|
13
|
+
actual.length == args.length && actual.all? { |a| args.include?(a.full_name) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec::Matchers.define :have_rubyopts do |*args|
|
18
|
+
args = args.flatten
|
19
|
+
args = args.first.split(/\s+/) if args.size == 1
|
20
|
+
|
21
|
+
#failure_message_for_should "Expected RUBYOPT to have options #{args.join(" ")}. It was #{ENV["RUBYOPT"]}"
|
22
|
+
|
23
|
+
match do |actual|
|
24
|
+
actual = actual.split(/\s+/) if actual.is_a?(String)
|
25
|
+
args.all? {|arg| actual.include?(arg) } && actual.uniq.size == actual.size
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def should_be_installed(*names)
|
30
|
+
opts = names.last.is_a?(Hash) ? names.pop : {}
|
31
|
+
groups = Array(opts[:groups])
|
32
|
+
groups << opts
|
33
|
+
names.each do |name|
|
34
|
+
name, version, platform = name.split(/\s+/)
|
35
|
+
version_const = name == 'bundler' ? 'Bundler::VERSION' : Spec::Builders.constantize(name)
|
36
|
+
run "require '#{name}.rb'; puts #{version_const}", *groups
|
37
|
+
actual_version, actual_platform = out.split(/\s+/)
|
38
|
+
Gem::Version.new(actual_version).should == Gem::Version.new(version)
|
39
|
+
actual_platform.should == platform
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
alias should_be_available should_be_installed
|
44
|
+
|
45
|
+
def should_not_be_installed(*names)
|
46
|
+
opts = names.last.is_a?(Hash) ? names.pop : {}
|
47
|
+
groups = Array(opts[:groups]) || []
|
48
|
+
names.each do |name|
|
49
|
+
name, version = name.split(/\s+/)
|
50
|
+
run <<-R, *(groups + [opts])
|
51
|
+
begin
|
52
|
+
require '#{name}'
|
53
|
+
puts #{Spec::Builders.constantize(name)}
|
54
|
+
rescue LoadError, NameError
|
55
|
+
puts "WIN"
|
56
|
+
end
|
57
|
+
R
|
58
|
+
if version.nil? || out == "WIN"
|
59
|
+
out.should == "WIN"
|
60
|
+
else
|
61
|
+
Gem::Version.new(out).should_not == Gem::Version.new(version)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def should_be_locked
|
67
|
+
bundled_app("Gemfile.lock").should exist
|
68
|
+
end
|
69
|
+
|
70
|
+
RSpec::Matchers.define :be_with_diff do |expected|
|
71
|
+
spaces = expected[/\A\s+/, 0] || ""
|
72
|
+
expected.gsub!(/^#{spaces}/, '')
|
73
|
+
|
74
|
+
failure_message_for_should do |actual|
|
75
|
+
"The lockfile did not match.\n=== Expected:\n" <<
|
76
|
+
expected << "\n=== Got:\n" << actual << "\n===========\n"
|
77
|
+
end
|
78
|
+
|
79
|
+
match do |actual|
|
80
|
+
expected == actual
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def lockfile_should_be(expected)
|
85
|
+
lock = File.read(bundled_app("Gemfile.lock"))
|
86
|
+
lock.should be_with_diff(expected)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Spec
|
2
|
+
module Path
|
3
|
+
def root
|
4
|
+
@root ||= Pathname.new(File.expand_path("../../..", __FILE__))
|
5
|
+
end
|
6
|
+
|
7
|
+
def tmp(*path)
|
8
|
+
root.join("tmp", *path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def home(*path)
|
12
|
+
tmp.join("home", *path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def default_bundle_path(*path)
|
16
|
+
system_gem_path(*path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def bundled_app(*path)
|
20
|
+
root = tmp.join("bundled_app")
|
21
|
+
FileUtils.mkdir_p(root)
|
22
|
+
root.join(*path)
|
23
|
+
end
|
24
|
+
|
25
|
+
alias bundled_app1 bundled_app
|
26
|
+
|
27
|
+
def bundled_app2(*path)
|
28
|
+
root = tmp.join("bundled_app2")
|
29
|
+
FileUtils.mkdir_p(root)
|
30
|
+
root.join(*path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def vendored_gems(path = nil)
|
34
|
+
bundled_app("vendor/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}/#{path}")
|
35
|
+
end
|
36
|
+
|
37
|
+
def cached_gem(path)
|
38
|
+
bundled_app("vendor/cache/#{path}.gem")
|
39
|
+
end
|
40
|
+
|
41
|
+
def base_system_gems
|
42
|
+
tmp.join("gems/base")
|
43
|
+
end
|
44
|
+
|
45
|
+
def gem_repo1(*args)
|
46
|
+
tmp("gems/remote1", *args)
|
47
|
+
end
|
48
|
+
|
49
|
+
def gem_repo2(*args)
|
50
|
+
tmp("gems/remote2", *args)
|
51
|
+
end
|
52
|
+
|
53
|
+
def gem_repo3(*args)
|
54
|
+
tmp("gems/remote3", *args)
|
55
|
+
end
|
56
|
+
|
57
|
+
def system_gem_path(*path)
|
58
|
+
tmp("gems/system", *path)
|
59
|
+
end
|
60
|
+
|
61
|
+
def lib_path(*args)
|
62
|
+
tmp("libs", *args)
|
63
|
+
end
|
64
|
+
|
65
|
+
def bundler_path
|
66
|
+
Pathname.new(File.expand_path('../../../lib', __FILE__))
|
67
|
+
end
|
68
|
+
|
69
|
+
extend self
|
70
|
+
end
|
71
|
+
end
|