mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
a357984508
Restored method bundler wants to remove for compatibility. Improvements to Gemfile compatibility. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
154 lines
2.7 KiB
Ruby
154 lines
2.7 KiB
Ruby
require 'rubygems/test_case'
|
|
require 'rubygems/request_set'
|
|
|
|
class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
|
|
|
def setup
|
|
super
|
|
|
|
@GDA = Gem::RequestSet::GemDependencyAPI
|
|
|
|
@set = Gem::RequestSet.new
|
|
|
|
@gda = @GDA.new @set, 'gem.deps.rb'
|
|
end
|
|
|
|
def test_gem
|
|
@gda.gem 'a'
|
|
|
|
assert_equal [dep('a')], @set.dependencies
|
|
end
|
|
|
|
def test_gem_group
|
|
@gda.gem 'a', :group => :test
|
|
|
|
expected = {
|
|
:test => [['a']],
|
|
}
|
|
|
|
assert_equal expected, @gda.dependency_groups
|
|
|
|
assert_empty @set.dependencies
|
|
end
|
|
|
|
def test_gem_groups
|
|
@gda.gem 'a', :groups => [:test, :development]
|
|
|
|
expected = {
|
|
:development => [['a']],
|
|
:test => [['a']],
|
|
}
|
|
|
|
assert_equal expected, @gda.dependency_groups
|
|
|
|
assert_empty @set.dependencies
|
|
end
|
|
|
|
def test_gem_requirement
|
|
@gda.gem 'a', '~> 1.0'
|
|
|
|
assert_equal [dep('a', '~> 1.0')], @set.dependencies
|
|
end
|
|
|
|
def test_gem_requirements
|
|
@gda.gem 'b', '~> 1.0', '>= 1.0.2'
|
|
|
|
assert_equal [dep('b', '~> 1.0', '>= 1.0.2')], @set.dependencies
|
|
end
|
|
|
|
def test_gem_requirements_options
|
|
@gda.gem 'c', :git => 'https://example/c.git'
|
|
|
|
assert_equal [dep('c')], @set.dependencies
|
|
end
|
|
|
|
def test_gem_deps_file
|
|
assert_equal 'gem.deps.rb', @gda.gem_deps_file
|
|
|
|
gda = @GDA.new @set, 'foo/Gemfile'
|
|
|
|
assert_equal 'Gemfile', gda.gem_deps_file
|
|
end
|
|
|
|
def test_group
|
|
@gda.group :test do
|
|
@gda.gem 'a'
|
|
end
|
|
|
|
assert_equal [['a']], @gda.dependency_groups[:test]
|
|
|
|
assert_empty @set.dependencies
|
|
end
|
|
|
|
def test_load
|
|
Tempfile.open 'gem.deps.rb' do |io|
|
|
io.write <<-GEM_DEPS
|
|
gem 'a'
|
|
|
|
group :test do
|
|
gem 'b'
|
|
end
|
|
GEM_DEPS
|
|
io.flush
|
|
|
|
gda = @GDA.new @set, io.path
|
|
|
|
gda.load
|
|
|
|
expected = {
|
|
:test => [['b']],
|
|
}
|
|
|
|
assert_equal expected, gda.dependency_groups
|
|
|
|
assert_equal [dep('a')], @set.dependencies
|
|
end
|
|
end
|
|
|
|
def test_name_typo
|
|
assert_same @GDA, Gem::RequestSet::DepedencyAPI
|
|
end
|
|
|
|
def test_platform_mswin
|
|
@gda.platform :mswin do
|
|
@gda.gem 'a'
|
|
end
|
|
|
|
assert_empty @set.dependencies
|
|
end
|
|
|
|
def test_platform_ruby
|
|
@gda.platform :ruby do
|
|
@gda.gem 'a'
|
|
end
|
|
|
|
assert_equal [dep('a')], @set.dependencies
|
|
end
|
|
|
|
def test_platforms
|
|
@gda.platforms :ruby do
|
|
@gda.gem 'a'
|
|
end
|
|
|
|
assert_equal [dep('a')], @set.dependencies
|
|
end
|
|
|
|
def test_ruby
|
|
assert @gda.ruby RUBY_VERSION
|
|
end
|
|
|
|
def test_ruby_engine
|
|
assert @gda.ruby RUBY_VERSION,
|
|
:engine => 'jruby', :engine_version => '1.7.4'
|
|
end
|
|
|
|
def test_ruby_mismatch
|
|
e = assert_raises Gem::RubyVersionMismatch do
|
|
@gda.ruby '1.8.0'
|
|
end
|
|
|
|
assert_equal "Your Ruby version is #{RUBY_VERSION}, but your gem.deps.rb specified 1.8.0", e.message
|
|
end
|
|
|
|
end
|
|
|