Skip to content

Commit

Permalink
Merge pull request #3132 from rubygems/improve_tests
Browse files Browse the repository at this point in the history
Little cleanup in test suite
  • Loading branch information
simi committed Dec 5, 2021
2 parents a151035 + b0bbb27 commit 7befe7e
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions test/rubygems/test_require.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ def await
end
end

def setup
super

@old_loaded_features = $LOADED_FEATURES.dup
assert_raise LoadError do
require 'test_gem_require_a'
end
$LOADED_FEATURES.replace @old_loaded_features
end

def assert_require(path)
assert require(path), "'#{path}' was already required"
end
Expand Down Expand Up @@ -88,8 +78,6 @@ def test_dash_i_beats_gems
FileUtils.mkdir_p File.dirname c_rb
File.open(c_rb, 'w') {|f| f.write "class Object; HELLO = 'world' end" }

lp = $LOAD_PATH.dup

# Pretend to provide a commandline argument that overrides a file in gem b
$LOAD_PATH.unshift dash_i_arg

Expand All @@ -98,7 +86,6 @@ def test_dash_i_beats_gems
assert_equal "world", ::Object::HELLO
assert_equal %w[a-1 b-1], loaded_spec_names
ensure
$LOAD_PATH.replace lp
Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
end

Expand Down Expand Up @@ -132,8 +119,6 @@ def test_dash_i_beats_default_gems

assert_require 'test_gem_require_a'

lp = $LOAD_PATH.dup

# Pretend to provide a commandline argument that overrides a file in gem b
$LOAD_PATH.unshift dash_i_arg

Expand All @@ -142,7 +127,6 @@ def test_dash_i_beats_default_gems
assert_equal "world", ::Object::HELLO
assert_equal %w[a-1 b-1], loaded_spec_names
ensure
$LOAD_PATH.replace lp
Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
end

Expand All @@ -153,16 +137,10 @@ def test_dash_i_respects_default_library_extension_priority
dash_i_ext_arg = util_install_extension_file('a')
dash_i_lib_arg = util_install_ruby_file('a')

lp = $LOAD_PATH.dup

begin
$LOAD_PATH.unshift dash_i_lib_arg
$LOAD_PATH.unshift dash_i_ext_arg
assert_require 'a'
assert_match(/a\.rb$/, $LOADED_FEATURES.last)
ensure
$LOAD_PATH.replace lp
end
$LOAD_PATH.unshift dash_i_lib_arg
$LOAD_PATH.unshift dash_i_ext_arg
assert_require 'a'
assert_match(/a\.rb$/, $LOADED_FEATURES.last)
end

def test_concurrent_require
Expand Down

0 comments on commit 7befe7e

Please sign in to comment.