mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/rubygems/test_require.rb: Fix tests when 'a.rb' exists.
[ruby-trunk - Bug #7749] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6e48ce9c11
commit
48d5694f7e
2 changed files with 24 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Mar 6 08:10:15 2013 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* test/rubygems/test_require.rb: Fix tests when 'a.rb' exists.
|
||||
[ruby-trunk - Bug #7749]
|
||||
|
||||
Wed Mar 6 08:00:59 2013 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rubygems.rb: Allow specification of directory permissions.
|
||||
|
|
|
@ -2,19 +2,30 @@ require 'rubygems/test_case'
|
|||
require 'rubygems'
|
||||
|
||||
class TestGemRequire < Gem::TestCase
|
||||
|
||||
def setup
|
||||
super
|
||||
|
||||
assert_raises LoadError do
|
||||
save_loaded_features do
|
||||
require 'test_gem_require_a'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def assert_require(path)
|
||||
assert require(path), "'#{path}' was already required"
|
||||
end
|
||||
|
||||
def test_require_is_not_lazy_with_exact_req
|
||||
a1 = new_spec "a", "1", {"b" => "= 1"}, "lib/a.rb"
|
||||
a1 = new_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
|
||||
b1 = new_spec "b", "1", nil, "lib/b/c.rb"
|
||||
b2 = new_spec "b", "2", nil, "lib/b/c.rb"
|
||||
|
||||
install_specs a1, b1, b2
|
||||
|
||||
save_loaded_features do
|
||||
assert_require 'a'
|
||||
assert_require 'test_gem_require_a'
|
||||
assert_equal %w(a-1 b-1), loaded_spec_names
|
||||
assert_equal unresolved_names, []
|
||||
|
||||
|
@ -24,14 +35,14 @@ class TestGemRequire < Gem::TestCase
|
|||
end
|
||||
|
||||
def test_require_is_lazy_with_inexact_req
|
||||
a1 = new_spec "a", "1", {"b" => ">= 1"}, "lib/a.rb"
|
||||
a1 = new_spec "a", "1", {"b" => ">= 1"}, "lib/test_gem_require_a.rb"
|
||||
b1 = new_spec "b", "1", nil, "lib/b/c.rb"
|
||||
b2 = new_spec "b", "2", nil, "lib/b/c.rb"
|
||||
|
||||
install_specs a1, b1, b2
|
||||
|
||||
save_loaded_features do
|
||||
assert_require 'a'
|
||||
assert_require 'test_gem_require_a'
|
||||
assert_equal %w(a-1), loaded_spec_names
|
||||
assert_equal unresolved_names, ["b (>= 1)"]
|
||||
|
||||
|
@ -41,13 +52,13 @@ class TestGemRequire < Gem::TestCase
|
|||
end
|
||||
|
||||
def test_require_is_not_lazy_with_one_possible
|
||||
a1 = new_spec "a", "1", {"b" => ">= 1"}, "lib/a.rb"
|
||||
a1 = new_spec "a", "1", {"b" => ">= 1"}, "lib/test_gem_require_a.rb"
|
||||
b1 = new_spec "b", "1", nil, "lib/b/c.rb"
|
||||
|
||||
install_specs a1, b1
|
||||
|
||||
save_loaded_features do
|
||||
assert_require 'a'
|
||||
assert_require 'test_gem_require_a'
|
||||
assert_equal %w(a-1 b-1), loaded_spec_names
|
||||
assert_equal unresolved_names, []
|
||||
|
||||
|
@ -59,13 +70,13 @@ class TestGemRequire < Gem::TestCase
|
|||
def test_activate_via_require_respects_loaded_files
|
||||
require 'benchmark' # stdlib
|
||||
save_loaded_features do
|
||||
a1 = new_spec "a", "1", {"b" => ">= 1"}, "lib/a.rb"
|
||||
a1 = new_spec "a", "1", {"b" => ">= 1"}, "lib/test_gem_require_a.rb"
|
||||
b1 = new_spec "b", "1", nil, "lib/benchmark.rb"
|
||||
b2 = new_spec "b", "2", nil, "lib/benchmark.rb"
|
||||
|
||||
install_specs a1, b1, b2
|
||||
|
||||
require 'a'
|
||||
require 'test_gem_require_a'
|
||||
assert_equal unresolved_names, ["b (>= 1)"]
|
||||
|
||||
refute require('benchmark'), "benchmark should have already been loaded"
|
||||
|
|
Loading…
Reference in a new issue