bundler_package_git 1.1.pre.1

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 (149) hide show
  1. data/.gitignore +22 -0
  2. data/.rvmrc +1 -0
  3. data/CHANGELOG.md +659 -0
  4. data/ISSUES.md +47 -0
  5. data/LICENSE +23 -0
  6. data/README.md +29 -0
  7. data/Rakefile +167 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +22 -0
  10. data/bundler.gemspec +30 -0
  11. data/lib/bundler.rb +283 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +490 -0
  14. data/lib/bundler/definition.rb +429 -0
  15. data/lib/bundler/dependency.rb +130 -0
  16. data/lib/bundler/deployment.rb +53 -0
  17. data/lib/bundler/dsl.rb +243 -0
  18. data/lib/bundler/environment.rb +47 -0
  19. data/lib/bundler/fetcher.rb +101 -0
  20. data/lib/bundler/gem_helper.rb +146 -0
  21. data/lib/bundler/graph.rb +130 -0
  22. data/lib/bundler/index.rb +131 -0
  23. data/lib/bundler/installer.rb +117 -0
  24. data/lib/bundler/lazy_specification.rb +71 -0
  25. data/lib/bundler/lockfile_parser.rb +108 -0
  26. data/lib/bundler/remote_specification.rb +57 -0
  27. data/lib/bundler/resolver.rb +470 -0
  28. data/lib/bundler/rubygems_ext.rb +226 -0
  29. data/lib/bundler/runtime.rb +201 -0
  30. data/lib/bundler/settings.rb +117 -0
  31. data/lib/bundler/setup.rb +16 -0
  32. data/lib/bundler/shared_helpers.rb +167 -0
  33. data/lib/bundler/source.rb +675 -0
  34. data/lib/bundler/spec_set.rb +134 -0
  35. data/lib/bundler/templates/Executable +16 -0
  36. data/lib/bundler/templates/Gemfile +4 -0
  37. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  38. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  39. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  40. data/lib/bundler/templates/newgem/gitignore.tt +4 -0
  41. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -0
  42. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  43. data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -0
  44. data/lib/bundler/ui.rb +73 -0
  45. data/lib/bundler/vendor/net/http/faster.rb +27 -0
  46. data/lib/bundler/vendor/net/http/persistent.rb +464 -0
  47. data/lib/bundler/vendor/thor.rb +319 -0
  48. data/lib/bundler/vendor/thor/actions.rb +297 -0
  49. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  50. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  51. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  52. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +229 -0
  53. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +104 -0
  54. data/lib/bundler/vendor/thor/base.rb +556 -0
  55. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  56. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  57. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  58. data/lib/bundler/vendor/thor/error.rb +30 -0
  59. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  60. data/lib/bundler/vendor/thor/parser.rb +4 -0
  61. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  62. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  63. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  64. data/lib/bundler/vendor/thor/parser/options.rb +174 -0
  65. data/lib/bundler/vendor/thor/shell.rb +88 -0
  66. data/lib/bundler/vendor/thor/shell/basic.rb +275 -0
  67. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  68. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  69. data/lib/bundler/vendor/thor/task.rb +114 -0
  70. data/lib/bundler/vendor/thor/util.rb +229 -0
  71. data/lib/bundler/vendor/thor/version.rb +3 -0
  72. data/lib/bundler/version.rb +6 -0
  73. data/lib/bundler/vlad.rb +9 -0
  74. data/man/bundle-config.ronn +90 -0
  75. data/man/bundle-exec.ronn +111 -0
  76. data/man/bundle-install.ronn +314 -0
  77. data/man/bundle-package.ronn +59 -0
  78. data/man/bundle-update.ronn +176 -0
  79. data/man/bundle.ronn +80 -0
  80. data/man/gemfile.5.ronn +279 -0
  81. data/man/index.txt +6 -0
  82. data/spec/cache/gems_spec.rb +219 -0
  83. data/spec/cache/git_spec.rb +9 -0
  84. data/spec/cache/path_spec.rb +27 -0
  85. data/spec/cache/platform_spec.rb +57 -0
  86. data/spec/install/deploy_spec.rb +197 -0
  87. data/spec/install/deprecated_spec.rb +37 -0
  88. data/spec/install/gems/c_ext_spec.rb +48 -0
  89. data/spec/install/gems/dependency_api_spec.rb +85 -0
  90. data/spec/install/gems/env_spec.rb +107 -0
  91. data/spec/install/gems/flex_spec.rb +313 -0
  92. data/spec/install/gems/groups_spec.rb +245 -0
  93. data/spec/install/gems/packed_spec.rb +84 -0
  94. data/spec/install/gems/platform_spec.rb +208 -0
  95. data/spec/install/gems/resolving_spec.rb +72 -0
  96. data/spec/install/gems/simple_case_spec.rb +715 -0
  97. data/spec/install/gems/standalone_spec.rb +162 -0
  98. data/spec/install/gems/sudo_spec.rb +73 -0
  99. data/spec/install/gems/win32_spec.rb +26 -0
  100. data/spec/install/gemspec_spec.rb +108 -0
  101. data/spec/install/git_spec.rb +571 -0
  102. data/spec/install/invalid_spec.rb +17 -0
  103. data/spec/install/path_spec.rb +353 -0
  104. data/spec/install/upgrade_spec.rb +26 -0
  105. data/spec/lock/git_spec.rb +35 -0
  106. data/spec/lock/lockfile_spec.rb +683 -0
  107. data/spec/other/check_spec.rb +221 -0
  108. data/spec/other/clean_spec.rb +202 -0
  109. data/spec/other/config_spec.rb +40 -0
  110. data/spec/other/console_spec.rb +54 -0
  111. data/spec/other/exec_spec.rb +241 -0
  112. data/spec/other/ext_spec.rb +16 -0
  113. data/spec/other/gem_helper_spec.rb +128 -0
  114. data/spec/other/help_spec.rb +38 -0
  115. data/spec/other/init_spec.rb +40 -0
  116. data/spec/other/newgem_spec.rb +24 -0
  117. data/spec/other/open_spec.rb +35 -0
  118. data/spec/other/show_spec.rb +82 -0
  119. data/spec/pack/gems_spec.rb +54 -0
  120. data/spec/quality_spec.rb +58 -0
  121. data/spec/resolver/basic_spec.rb +20 -0
  122. data/spec/resolver/platform_spec.rb +82 -0
  123. data/spec/runtime/executable_spec.rb +110 -0
  124. data/spec/runtime/load_spec.rb +107 -0
  125. data/spec/runtime/platform_spec.rb +90 -0
  126. data/spec/runtime/require_spec.rb +231 -0
  127. data/spec/runtime/setup_spec.rb +688 -0
  128. data/spec/runtime/with_clean_env_spec.rb +15 -0
  129. data/spec/spec_helper.rb +85 -0
  130. data/spec/support/artifice/endpoint.rb +50 -0
  131. data/spec/support/artifice/endpoint_fallback.rb +22 -0
  132. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  133. data/spec/support/artifice/endpoint_redirect.rb +11 -0
  134. data/spec/support/builders.rb +574 -0
  135. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  136. data/spec/support/fakeweb/windows.rb +23 -0
  137. data/spec/support/helpers.rb +246 -0
  138. data/spec/support/indexes.rb +112 -0
  139. data/spec/support/matchers.rb +89 -0
  140. data/spec/support/path.rb +73 -0
  141. data/spec/support/platforms.rb +53 -0
  142. data/spec/support/ruby_ext.rb +20 -0
  143. data/spec/support/rubygems_ext.rb +35 -0
  144. data/spec/support/rubygems_hax/platform.rb +11 -0
  145. data/spec/support/sudo.rb +21 -0
  146. data/spec/update/gems_spec.rb +121 -0
  147. data/spec/update/git_spec.rb +196 -0
  148. data/spec/update/source_spec.rb +51 -0
  149. metadata +294 -0
@@ -0,0 +1,2 @@
1
+ [{ :dependencies[ [" thin" >= 0["ruby-openid"
2
+ 1.0.0
@@ -0,0 +1,23 @@
1
+ require File.expand_path("../../path.rb", __FILE__)
2
+ include Spec::Path
3
+
4
+ files = [ 'specs.4.8.gz',
5
+ 'prerelease_specs.4.8.gz',
6
+ 'quick/Marshal.4.8/rcov-1.0-mswin32.gemspec.rz',
7
+ 'gems/rcov-1.0-mswin32.gem' ]
8
+
9
+ # Set up pretend http gem server with FakeWeb
10
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/fakeweb*/lib")].first}"
11
+ require 'fakeweb'
12
+
13
+ FakeWeb.allow_net_connect = false
14
+
15
+ files.each do |file|
16
+ FakeWeb.register_uri(:get, "http://localgemserver.test/#{file}",
17
+ :body => File.read("#{gem_repo1}/#{file}"))
18
+ end
19
+ FakeWeb.register_uri(:get, "http://localgemserver.test/gems/rcov-1.0-x86-mswin32.gem",
20
+ :status => ["404", "Not Found"])
21
+
22
+ FakeWeb.register_uri(:get, "http://localgemserver.test/api/v1/dependencies?gems=rcov",
23
+ :status => ["404", "Not Found"])
@@ -0,0 +1,246 @@
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
+ bundle_bin = File.expand_path('../../../bin/bundle', __FILE__)
48
+ fake_file = options.delete(:fakeweb)
49
+ fakeweb = fake_file ? "-r#{File.expand_path('../fakeweb/'+fake_file+'.rb', __FILE__)}" : nil
50
+ artifice_file = options.delete(:artifice)
51
+ artifice = artifice_file ? "-r#{File.expand_path('../artifice/'+artifice_file+'.rb', __FILE__)}" : nil
52
+
53
+ env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
54
+ args = options.map do |k,v|
55
+ v == true ? " --#{k}" : " --#{k} #{v}" if v
56
+ end.join
57
+
58
+ cmd = "#{env}#{Gem.ruby} -I#{lib} #{fakeweb} #{artifice} #{bundle_bin} #{cmd}#{args}"
59
+
60
+ if exitstatus
61
+ sys_status(cmd)
62
+ else
63
+ sys_exec(cmd, expect_err){|i| yield i if block_given? }
64
+ end
65
+ end
66
+
67
+ def ruby(ruby, options = {})
68
+ expect_err = options.delete(:expect_err)
69
+ env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
70
+ ruby.gsub!(/["`\$]/) {|m| "\\#{m}" }
71
+ lib_option = options[:no_lib] ? "" : " -I#{lib}"
72
+ sys_exec(%{#{env}#{Gem.ruby}#{lib_option} -e "#{ruby}"}, expect_err)
73
+ end
74
+
75
+ def gembin(cmd)
76
+ lib = File.expand_path("../../../lib", __FILE__)
77
+ old, ENV['RUBYOPT'] = ENV['RUBYOPT'], "#{ENV['RUBYOPT']} -I#{lib}"
78
+ cmd = bundled_app("bin/#{cmd}") unless cmd.to_s.include?("/")
79
+ sys_exec(cmd.to_s)
80
+ ensure
81
+ ENV['RUBYOPT'] = old
82
+ end
83
+
84
+ def sys_exec(cmd, expect_err = false)
85
+ Open3.popen3(cmd.to_s) do |stdin, stdout, stderr|
86
+ @in_p, @out_p, @err_p = stdin, stdout, stderr
87
+
88
+ yield @in_p if block_given?
89
+ @in_p.close
90
+
91
+ @out = @out_p.read_available_bytes.strip
92
+ @err = @err_p.read_available_bytes.strip
93
+ end
94
+
95
+ puts @err unless expect_err || @err.empty? || !$show_err
96
+ @out
97
+ end
98
+
99
+ def sys_status(cmd)
100
+ @err = nil
101
+ @out = %x{#{cmd}}.strip
102
+ @exitstatus = $?.exitstatus
103
+ end
104
+
105
+ def config(config = nil)
106
+ path = bundled_app('.bundle/config')
107
+ return YAML.load_file(path) unless config
108
+ FileUtils.mkdir_p(File.dirname(path))
109
+ File.open(path, 'w') do |f|
110
+ f.puts config.to_yaml
111
+ end
112
+ config
113
+ end
114
+
115
+ def gemfile(*args)
116
+ path = bundled_app("Gemfile")
117
+ path = args.shift if Pathname === args.first
118
+ str = args.shift || ""
119
+ path.dirname.mkpath
120
+ File.open(path.to_s, 'w') do |f|
121
+ f.puts str
122
+ end
123
+ end
124
+
125
+ def lockfile(*args)
126
+ path = bundled_app("Gemfile.lock")
127
+ path = args.shift if Pathname === args.first
128
+ str = args.shift || ""
129
+
130
+ # Trim the leading spaces
131
+ spaces = str[/\A\s+/, 0] || ""
132
+ str.gsub!(/^#{spaces}/, '')
133
+
134
+ File.open(path.to_s, 'w') do |f|
135
+ f.puts str
136
+ end
137
+ end
138
+
139
+ def install_gemfile(*args)
140
+ gemfile(*args)
141
+ opts = args.last.is_a?(Hash) ? args.last : {}
142
+ bundle :install, opts
143
+ end
144
+
145
+ def install_gems(*gems)
146
+ gems.each do |g|
147
+ path = "#{gem_repo1}/gems/#{g}.gem"
148
+
149
+ raise "OMG `#{path}` does not exist!" unless File.exist?(path)
150
+
151
+ gem_command :install, "--no-rdoc --no-ri --ignore-dependencies #{path}"
152
+ end
153
+ end
154
+
155
+ alias install_gem install_gems
156
+
157
+ def with_gem_path_as(path)
158
+ gem_home, gem_path = ENV['GEM_HOME'], ENV['GEM_PATH']
159
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = path.to_s, path.to_s
160
+ yield
161
+ ensure
162
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
163
+ end
164
+
165
+ def break_git!
166
+ FileUtils.mkdir_p(tmp("broken_path"))
167
+ File.open(tmp("broken_path/git"), "w", 0755) do |f|
168
+ f.puts "#!/usr/bin/env ruby\nSTDERR.puts 'This is not the git you are looking for'\nexit 1"
169
+ end
170
+
171
+ ENV["PATH"] = "#{tmp("broken_path")}:#{ENV["PATH"]}"
172
+ end
173
+
174
+ def fake_groff!
175
+ FileUtils.mkdir_p(tmp("fake_groff"))
176
+ File.open(tmp("fake_groff/groff"), "w", 0755) do |f|
177
+ f.puts "#!/usr/bin/env ruby\nputs ARGV.inspect\n"
178
+ end
179
+
180
+ ENV["PATH"] = "#{tmp("fake_groff")}:#{ENV["PATH"]}"
181
+ end
182
+
183
+ def kill_path!
184
+ ENV["PATH"] = ""
185
+ end
186
+
187
+ def system_gems(*gems)
188
+ gems = gems.flatten
189
+
190
+ FileUtils.rm_rf(system_gem_path)
191
+ FileUtils.mkdir_p(system_gem_path)
192
+
193
+ Gem.clear_paths
194
+
195
+ gem_home, gem_path, path = ENV['GEM_HOME'], ENV['GEM_PATH'], ENV['PATH']
196
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = system_gem_path.to_s, system_gem_path.to_s
197
+
198
+ install_gems(*gems)
199
+ if block_given?
200
+ begin
201
+ yield
202
+ ensure
203
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
204
+ ENV['PATH'] = path
205
+ end
206
+ end
207
+ end
208
+
209
+ def cache_gems(*gems)
210
+ gems = gems.flatten
211
+
212
+ FileUtils.rm_rf("#{bundled_app}/vendor/cache")
213
+ FileUtils.mkdir_p("#{bundled_app}/vendor/cache")
214
+
215
+ gems.each do |g|
216
+ path = "#{gem_repo1}/gems/#{g}.gem"
217
+ raise "OMG `#{path}` does not exist!" unless File.exist?(path)
218
+ FileUtils.cp(path, "#{bundled_app}/vendor/cache")
219
+ end
220
+ end
221
+
222
+ def simulate_new_machine
223
+ system_gems []
224
+ FileUtils.rm_rf default_bundle_path
225
+ FileUtils.rm_rf bundled_app('.bundle')
226
+ end
227
+
228
+ def simulate_platform(platform)
229
+ old, ENV['BUNDLER_SPEC_PLATFORM'] = ENV['BUNDLER_SPEC_PLATFORM'], platform.to_s
230
+ yield if block_given?
231
+ ensure
232
+ ENV['BUNDLER_SPEC_PLATFORM'] = old if block_given?
233
+ end
234
+
235
+ def simulate_bundler_version(version)
236
+ old, ENV['BUNDLER_SPEC_VERSION'] = ENV['BUNDLER_SPEC_VERSION'], version.to_s
237
+ yield if block_given?
238
+ ensure
239
+ ENV['BUNDLER_SPEC_VERSION'] = old if block_given?
240
+ end
241
+
242
+ def revision_for(path)
243
+ Dir.chdir(path) { `git rev-parse HEAD`.strip }
244
+ end
245
+ end
246
+ 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,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
+ check 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