bundler-maglev- 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +32 -0
  3. data/CHANGELOG.md +805 -0
  4. data/ISSUES.md +62 -0
  5. data/LICENSE +23 -0
  6. data/README.md +29 -0
  7. data/Rakefile +212 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +22 -0
  10. data/bundler.gemspec +30 -0
  11. data/lib/bundler.rb +286 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +520 -0
  14. data/lib/bundler/definition.rb +438 -0
  15. data/lib/bundler/dependency.rb +134 -0
  16. data/lib/bundler/deployment.rb +58 -0
  17. data/lib/bundler/dsl.rb +257 -0
  18. data/lib/bundler/environment.rb +47 -0
  19. data/lib/bundler/gem_helper.rb +151 -0
  20. data/lib/bundler/gem_installer.rb +9 -0
  21. data/lib/bundler/gem_tasks.rb +2 -0
  22. data/lib/bundler/graph.rb +130 -0
  23. data/lib/bundler/index.rb +138 -0
  24. data/lib/bundler/installer.rb +97 -0
  25. data/lib/bundler/lazy_specification.rb +74 -0
  26. data/lib/bundler/lockfile_parser.rb +108 -0
  27. data/lib/bundler/remote_specification.rb +59 -0
  28. data/lib/bundler/resolver.rb +464 -0
  29. data/lib/bundler/rubygems_ext.rb +237 -0
  30. data/lib/bundler/rubygems_integration.rb +349 -0
  31. data/lib/bundler/runtime.rb +152 -0
  32. data/lib/bundler/settings.rb +115 -0
  33. data/lib/bundler/setup.rb +23 -0
  34. data/lib/bundler/shared_helpers.rb +71 -0
  35. data/lib/bundler/source.rb +708 -0
  36. data/lib/bundler/spec_set.rb +135 -0
  37. data/lib/bundler/templates/Executable +16 -0
  38. data/lib/bundler/templates/Gemfile +4 -0
  39. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  40. data/lib/bundler/templates/newgem/Rakefile.tt +1 -0
  41. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  42. data/lib/bundler/templates/newgem/gitignore.tt +4 -0
  43. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
  44. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  45. data/lib/bundler/templates/newgem/newgem.gemspec.tt +24 -0
  46. data/lib/bundler/ui.rb +73 -0
  47. data/lib/bundler/vendor/thor.rb +358 -0
  48. data/lib/bundler/vendor/thor/actions.rb +314 -0
  49. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  50. data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
  51. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  52. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  53. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
  54. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
  55. data/lib/bundler/vendor/thor/base.rb +576 -0
  56. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  57. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  58. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  59. data/lib/bundler/vendor/thor/error.rb +30 -0
  60. data/lib/bundler/vendor/thor/group.rb +273 -0
  61. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  62. data/lib/bundler/vendor/thor/parser.rb +4 -0
  63. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  64. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  65. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  66. data/lib/bundler/vendor/thor/parser/options.rb +175 -0
  67. data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
  68. data/lib/bundler/vendor/thor/runner.rb +309 -0
  69. data/lib/bundler/vendor/thor/shell.rb +88 -0
  70. data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
  71. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  72. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  73. data/lib/bundler/vendor/thor/task.rb +113 -0
  74. data/lib/bundler/vendor/thor/util.rb +229 -0
  75. data/lib/bundler/vendor/thor/version.rb +3 -0
  76. data/lib/bundler/vendored_thor.rb +7 -0
  77. data/lib/bundler/version.rb +6 -0
  78. data/lib/bundler/vlad.rb +11 -0
  79. data/man/bundle-config.ronn +90 -0
  80. data/man/bundle-exec.ronn +111 -0
  81. data/man/bundle-install.ronn +317 -0
  82. data/man/bundle-package.ronn +59 -0
  83. data/man/bundle-update.ronn +176 -0
  84. data/man/bundle.ronn +80 -0
  85. data/man/gemfile.5.ronn +284 -0
  86. data/man/index.txt +6 -0
  87. data/spec/bundler/gem_helper_spec.rb +143 -0
  88. data/spec/cache/gems_spec.rb +230 -0
  89. data/spec/cache/git_spec.rb +12 -0
  90. data/spec/cache/path_spec.rb +27 -0
  91. data/spec/cache/platform_spec.rb +57 -0
  92. data/spec/install/deploy_spec.rb +197 -0
  93. data/spec/install/deprecated_spec.rb +37 -0
  94. data/spec/install/gems/c_ext_spec.rb +48 -0
  95. data/spec/install/gems/env_spec.rb +107 -0
  96. data/spec/install/gems/flex_spec.rb +313 -0
  97. data/spec/install/gems/groups_spec.rb +259 -0
  98. data/spec/install/gems/packed_spec.rb +84 -0
  99. data/spec/install/gems/platform_spec.rb +192 -0
  100. data/spec/install/gems/resolving_spec.rb +72 -0
  101. data/spec/install/gems/simple_case_spec.rb +770 -0
  102. data/spec/install/gems/sudo_spec.rb +74 -0
  103. data/spec/install/gems/win32_spec.rb +26 -0
  104. data/spec/install/gemspec_spec.rb +125 -0
  105. data/spec/install/git_spec.rb +570 -0
  106. data/spec/install/invalid_spec.rb +35 -0
  107. data/spec/install/path_spec.rb +405 -0
  108. data/spec/install/upgrade_spec.rb +26 -0
  109. data/spec/lock/git_spec.rb +35 -0
  110. data/spec/lock/lockfile_spec.rb +739 -0
  111. data/spec/other/check_spec.rb +221 -0
  112. data/spec/other/config_spec.rb +40 -0
  113. data/spec/other/console_spec.rb +54 -0
  114. data/spec/other/exec_spec.rb +248 -0
  115. data/spec/other/ext_spec.rb +37 -0
  116. data/spec/other/help_spec.rb +39 -0
  117. data/spec/other/init_spec.rb +40 -0
  118. data/spec/other/newgem_spec.rb +46 -0
  119. data/spec/other/open_spec.rb +35 -0
  120. data/spec/other/show_spec.rb +82 -0
  121. data/spec/quality_spec.rb +62 -0
  122. data/spec/resolver/basic_spec.rb +20 -0
  123. data/spec/resolver/platform_spec.rb +82 -0
  124. data/spec/runtime/executable_spec.rb +110 -0
  125. data/spec/runtime/load_spec.rb +107 -0
  126. data/spec/runtime/platform_spec.rb +90 -0
  127. data/spec/runtime/require_spec.rb +231 -0
  128. data/spec/runtime/setup_spec.rb +730 -0
  129. data/spec/runtime/with_clean_env_spec.rb +15 -0
  130. data/spec/spec_helper.rb +92 -0
  131. data/spec/support/builders.rb +597 -0
  132. data/spec/support/helpers.rb +239 -0
  133. data/spec/support/indexes.rb +112 -0
  134. data/spec/support/matchers.rb +77 -0
  135. data/spec/support/path.rb +71 -0
  136. data/spec/support/platforms.rb +53 -0
  137. data/spec/support/ruby_ext.rb +20 -0
  138. data/spec/support/rubygems_ext.rb +37 -0
  139. data/spec/support/rubygems_hax/platform.rb +11 -0
  140. data/spec/support/sudo.rb +21 -0
  141. data/spec/update/gems_spec.rb +122 -0
  142. data/spec/update/git_spec.rb +196 -0
  143. data/spec/update/source_spec.rb +51 -0
  144. metadata +296 -0
@@ -0,0 +1,239 @@
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).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
+ env = opts.delete(:env)
33
+ groups = args.map {|a| a.inspect }.join(", ")
34
+ setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
35
+ @out = ruby(setup + cmd, :expect_err => expect_err, :env => env)
36
+ end
37
+
38
+ def lib
39
+ File.expand_path('../../../lib', __FILE__)
40
+ end
41
+
42
+ def bundle(cmd, options = {})
43
+ expect_err = options.delete(:expect_err)
44
+ exitstatus = options.delete(:exitstatus)
45
+ options["no-color"] = true unless options.key?("no-color") || cmd.to_s[0..3] == "exec"
46
+
47
+ env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
48
+ args = options.map do |k,v|
49
+ v == true ? " --#{k}" : " --#{k} #{v}" if v
50
+ end.join
51
+ gemfile = File.expand_path('../../../bin/bundle', __FILE__)
52
+ cmd = "#{env}#{Gem.ruby} -I#{lib} #{gemfile} #{cmd}#{args}"
53
+
54
+ if exitstatus
55
+ sys_status(cmd)
56
+ else
57
+ sys_exec(cmd, expect_err){|i| yield i if block_given? }
58
+ end
59
+ end
60
+
61
+ def ruby(ruby, options = {})
62
+ expect_err = options.delete(:expect_err)
63
+ env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
64
+ ruby.gsub!(/["`\$]/) {|m| "\\#{m}" }
65
+ sys_exec(%{#{env}#{Gem.ruby} -I#{lib} -e "#{ruby}"}, expect_err)
66
+ end
67
+
68
+ def gembin(cmd)
69
+ lib = File.expand_path("../../../lib", __FILE__)
70
+ old, ENV['RUBYOPT'] = ENV['RUBYOPT'], "#{ENV['RUBYOPT']} -I#{lib}"
71
+ cmd = bundled_app("bin/#{cmd}") unless cmd.to_s.include?("/")
72
+ sys_exec(cmd.to_s)
73
+ ensure
74
+ ENV['RUBYOPT'] = old
75
+ end
76
+
77
+ def sys_exec(cmd, expect_err = false)
78
+ Open3.popen3(cmd.to_s) do |stdin, stdout, stderr|
79
+ @in_p, @out_p, @err_p = stdin, stdout, stderr
80
+
81
+ yield @in_p if block_given?
82
+ @in_p.close
83
+
84
+ @out = @out_p.read_available_bytes.strip
85
+ @err = @err_p.read_available_bytes.strip
86
+ end
87
+
88
+ puts @err unless expect_err || @err.empty? || !$show_err
89
+ @out
90
+ end
91
+
92
+ def sys_status(cmd)
93
+ @err = nil
94
+ @out = %x{#{cmd}}.strip
95
+ @exitstatus = $?.exitstatus
96
+ end
97
+
98
+ def config(config = nil)
99
+ path = bundled_app('.bundle/config')
100
+ return YAML.load_file(path) unless config
101
+ FileUtils.mkdir_p(File.dirname(path))
102
+ File.open(path, 'w') do |f|
103
+ f.puts config.to_yaml
104
+ end
105
+ config
106
+ end
107
+
108
+ def gemfile(*args)
109
+ path = bundled_app("Gemfile")
110
+ path = args.shift if Pathname === args.first
111
+ str = args.shift || ""
112
+ path.dirname.mkpath
113
+ File.open(path.to_s, 'w') do |f|
114
+ f.puts str
115
+ end
116
+ end
117
+
118
+ def lockfile(*args)
119
+ path = bundled_app("Gemfile.lock")
120
+ path = args.shift if Pathname === args.first
121
+ str = args.shift || ""
122
+
123
+ # Trim the leading spaces
124
+ spaces = str[/\A\s+/, 0] || ""
125
+ str.gsub!(/^#{spaces}/, '')
126
+
127
+ File.open(path.to_s, 'w') do |f|
128
+ f.puts str
129
+ end
130
+ end
131
+
132
+ def install_gemfile(*args)
133
+ gemfile(*args)
134
+ opts = args.last.is_a?(Hash) ? args.last : {}
135
+ bundle :install, opts
136
+ end
137
+
138
+ def install_gems(*gems)
139
+ gems.each do |g|
140
+ path = "#{gem_repo1}/gems/#{g}.gem"
141
+
142
+ raise "OMG `#{path}` does not exist!" unless File.exist?(path)
143
+
144
+ gem_command :install, "--no-rdoc --no-ri --ignore-dependencies #{path}"
145
+ end
146
+ end
147
+
148
+ alias install_gem install_gems
149
+
150
+ def with_gem_path_as(path)
151
+ gem_home, gem_path = ENV['GEM_HOME'], ENV['GEM_PATH']
152
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = path.to_s, path.to_s
153
+ yield
154
+ ensure
155
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
156
+ end
157
+
158
+ def break_git!
159
+ FileUtils.mkdir_p(tmp("broken_path"))
160
+ File.open(tmp("broken_path/git"), "w", 0755) do |f|
161
+ f.puts "#!/usr/bin/env ruby\nSTDERR.puts 'This is not the git you are looking for'\nexit 1"
162
+ end
163
+
164
+ ENV["PATH"] = "#{tmp("broken_path")}:#{ENV["PATH"]}"
165
+ end
166
+
167
+ def fake_groff!
168
+ FileUtils.mkdir_p(tmp("fake_groff"))
169
+ File.open(tmp("fake_groff/groff"), "w", 0755) do |f|
170
+ f.puts "#!/usr/bin/env ruby\nputs ARGV.inspect\n"
171
+ end
172
+
173
+ ENV["PATH"] = "#{tmp("fake_groff")}:#{ENV["PATH"]}"
174
+ end
175
+
176
+ def kill_path!
177
+ ENV["PATH"] = ""
178
+ end
179
+
180
+ def system_gems(*gems)
181
+ gems = gems.flatten
182
+
183
+ FileUtils.rm_rf(system_gem_path)
184
+ FileUtils.mkdir_p(system_gem_path)
185
+
186
+ Gem.clear_paths
187
+
188
+ gem_home, gem_path, path = ENV['GEM_HOME'], ENV['GEM_PATH'], ENV['PATH']
189
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = system_gem_path.to_s, system_gem_path.to_s
190
+
191
+ install_gems(*gems)
192
+ if block_given?
193
+ begin
194
+ yield
195
+ ensure
196
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
197
+ ENV['PATH'] = path
198
+ end
199
+ end
200
+ end
201
+
202
+ def cache_gems(*gems)
203
+ gems = gems.flatten
204
+
205
+ FileUtils.rm_rf("#{bundled_app}/vendor/cache")
206
+ FileUtils.mkdir_p("#{bundled_app}/vendor/cache")
207
+
208
+ gems.each do |g|
209
+ path = "#{gem_repo1}/gems/#{g}.gem"
210
+ raise "OMG `#{path}` does not exist!" unless File.exist?(path)
211
+ FileUtils.cp(path, "#{bundled_app}/vendor/cache")
212
+ end
213
+ end
214
+
215
+ def simulate_new_machine
216
+ system_gems []
217
+ FileUtils.rm_rf default_bundle_path
218
+ FileUtils.rm_rf bundled_app('.bundle')
219
+ end
220
+
221
+ def simulate_platform(platform)
222
+ old, ENV['BUNDLER_SPEC_PLATFORM'] = ENV['BUNDLER_SPEC_PLATFORM'], platform.to_s
223
+ yield if block_given?
224
+ ensure
225
+ ENV['BUNDLER_SPEC_PLATFORM'] = old if block_given?
226
+ end
227
+
228
+ def simulate_bundler_version(version)
229
+ old, ENV['BUNDLER_SPEC_VERSION'] = ENV['BUNDLER_SPEC_VERSION'], version.to_s
230
+ yield if block_given?
231
+ ensure
232
+ ENV['BUNDLER_SPEC_VERSION'] = old if block_given?
233
+ end
234
+
235
+ def revision_for(path)
236
+ Dir.chdir(path) { `git rev-parse HEAD`.strip }
237
+ end
238
+ end
239
+ end
@@ -0,0 +1,112 @@
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
+ got.should == specs.sort
30
+ end
31
+
32
+ def should_conflict_on(names)
33
+ begin
34
+ got = resolve
35
+ flunk "The resolve succeeded with: #{got.map { |s| s.full_name }.sort.inspect}"
36
+ rescue Bundler::VersionConflict => e
37
+ Array(names).sort.should == e.conflicts.sort
38
+ end
39
+ end
40
+
41
+ def gem(*args, &blk)
42
+ build_spec(*args, &blk).first
43
+ end
44
+
45
+ def an_awesome_index
46
+ build_index do
47
+ gem "rack", %w(0.8 0.9 0.9.1 0.9.2 1.0 1.1)
48
+ gem "rack-mount", %w(0.4 0.5 0.5.1 0.5.2 0.6)
49
+
50
+ # --- Rails
51
+ versions "1.2.3 2.2.3 2.3.5 3.0.0.beta 3.0.0.beta1" do |version|
52
+ gem "activesupport", version
53
+ gem "actionpack", version do
54
+ dep "activesupport", version
55
+ if version >= v('3.0.0.beta')
56
+ dep "rack", '~> 1.1'
57
+ dep "rack-mount", ">= 0.5"
58
+ elsif version > v('2.3') then dep "rack", '~> 1.0.0'
59
+ elsif version > v('2.0.0') then dep "rack", '~> 0.9.0'
60
+ end
61
+ end
62
+ gem "activerecord", version do
63
+ dep "activesupport", version
64
+ dep "arel", ">= 0.2" if version >= v('3.0.0.beta')
65
+ end
66
+ gem "actionmailer", version do
67
+ dep "activesupport", version
68
+ dep "actionmailer", version
69
+ end
70
+ if version < v('3.0.0.beta')
71
+ gem "railties", version do
72
+ dep "activerecord", version
73
+ dep "actionpack", version
74
+ dep "actionmailer", version
75
+ dep "activesupport", version
76
+ end
77
+ else
78
+ gem "railties", version
79
+ gem "rails", version do
80
+ dep "activerecord", version
81
+ dep "actionpack", version
82
+ dep "actionmailer", version
83
+ dep "activesupport", version
84
+ dep "railties", version
85
+ end
86
+ end
87
+ end
88
+
89
+ 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|
90
+ platforms "ruby java mswin32 mingw32" do |platform|
91
+ next if version == v('1.4.2.1') && platform != pl('x86-mswin32')
92
+ next if version == v('1.4.2') && platform == pl('x86-mswin32')
93
+ gem "nokogiri", version, platform do
94
+ dep "weakling", ">= 0.0.3" if platform =~ pl('java')
95
+ end
96
+ end
97
+ end
98
+
99
+ versions '0.0.1 0.0.2 0.0.3' do |version|
100
+ gem "weakling", version
101
+ end
102
+
103
+ # --- Rails related
104
+ versions '1.2.3 2.2.3 2.3.5' do |version|
105
+ gem "activemerchant", version do
106
+ dep "activesupport", ">= #{version}"
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,77 @@
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 eq(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
+ def lockfile_should_be(expected)
71
+ should_be_locked
72
+ spaces = expected[/\A\s+/, 0] || ""
73
+ expected.gsub!(/^#{spaces}/, '')
74
+ bundled_app("Gemfile.lock").read.should == expected
75
+ end
76
+ end
77
+ 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/bundle/#{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