summaryrefslogtreecommitdiff
path: root/test/rubygems/test_require.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems/test_require.rb')
-rw-r--r--test/rubygems/test_require.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index dc722f2e0f7..b341249391b 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -41,6 +41,10 @@ class TestGemRequire < Gem::TestCase
assert require(path), "'#{path}' was already required"
end
+ def refute_require(path)
+ refute require(path), "'#{path}' was not yet required"
+ end
+
# Providing -I on the commandline should always beat gems
def test_dash_i_beats_gems
a1 = util_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
@@ -334,6 +338,22 @@ class TestGemRequire < Gem::TestCase
assert_equal %w(default-2.0.0.0), loaded_spec_names
end
+ def test_default_gem_require_activates_just_once
+ default_gem_spec = new_default_spec("default", "2.0.0.0",
+ nil, "default/gem.rb")
+ install_default_specs(default_gem_spec)
+
+ assert_require "default/gem"
+
+ times_called = 0
+
+ Kernel.stub(:gem, ->(name, requirement) { times_called += 1 }) do
+ refute_require "default/gem"
+ end
+
+ assert_equal 0, times_called
+ end
+
def test_realworld_default_gem
begin
gem 'json'