1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rubygems/test_gem_resolver_index_specification.rb
Yusuke Endoh b957c3dbcb [rubygems/rubygems] Rename test/rubygems/test_{case,utilities}.rb to avoid "test_" prefix
This changes "test/rubygems/test_case.rb" to "test/rubygems/helper.rb",
and "test/rubygems/test_utilities.rb" to "test/rubygems/utilities.rb".

The two files are a helper for tests, not test files. However, a file
starting with "test_" prefix is handled as a test file directly loaded
by test-unit because Rakefile specifies:

```
t.test_files = FileList['test/**/test_*.rb']
```

Directly loading test/rubygems/test_utilities.rb caused "uninitialized
constant Gem::TestCase". This issue was fixed by
59c6820971, but the fix caused a
"circular require" warning because test_utilities.rb and test_case.rb
are now requiring each other.

Anyway, adding "test_" prefix to a test helper file is confusing, so
this changeset reverts the fix and solve the issue by renaming them.

https://github.com/rubygems/rubygems/commit/6460e018df
2021-06-03 12:23:22 +09:00

92 lines
2.3 KiB
Ruby

# frozen_string_literal: true
require_relative 'helper'
require 'rubygems/available_set'
class TestGemResolverIndexSpecification < Gem::TestCase
def test_initialize
set = Gem::Resolver::IndexSet.new
source = Gem::Source.new @gem_repo
version = Gem::Version.new '3.0.3'
spec = Gem::Resolver::IndexSpecification.new(
set, 'rails', version, source, Gem::Platform::RUBY)
assert_equal 'rails', spec.name
assert_equal version, spec.version
assert_equal Gem::Platform::RUBY, spec.platform
assert_equal source, spec.source
end
def test_initialize_platform
set = Gem::Resolver::IndexSet.new
source = Gem::Source::Local.new
version = Gem::Version.new '3.0.3'
spec = Gem::Resolver::IndexSpecification.new(
set, 'rails', version, source, Gem::Platform.local)
assert_equal Gem::Platform.local.to_s, spec.platform
end
def test_install
spec_fetcher do |fetcher|
fetcher.gem 'a', 2
end
set = Gem::Resolver::IndexSet.new
source = Gem::Source.new @gem_repo
spec = Gem::Resolver::IndexSpecification.new(
set, 'a', v(2), source, Gem::Platform::RUBY)
called = false
spec.install({}) do |installer|
called = installer
end
assert_path_exist File.join @gemhome, 'specifications', 'a-2.gemspec'
assert_kind_of Gem::Installer, called
end
def test_spec
specs = spec_fetcher do |fetcher|
fetcher.spec 'a', 2
fetcher.spec 'a', 2 do |s|
s.platform = Gem::Platform.local
end
end
source = Gem::Source.new @gem_repo
version = v 2
set = Gem::Resolver::IndexSet.new
i_spec = Gem::Resolver::IndexSpecification.new \
set, 'a', version, source, Gem::Platform.local
spec = i_spec.spec
assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name
end
def test_spec_local
a_2_p = util_spec 'a', 2 do |s|
s.platform = Gem::Platform.local
end
Gem::Package.build a_2_p
source = Gem::Source::Local.new
set = Gem::Resolver::InstallerSet.new :local
set.always_install << a_2_p
i_spec = Gem::Resolver::IndexSpecification.new \
set, 'a', v(2), source, Gem::Platform.local
spec = i_spec.spec
assert_equal a_2_p.full_name, spec.full_name
end
end