mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
eb807d42ec
environment variables. based on a patch from funny-falcon at https://gist.github.com/856296, but honors safe level. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
69 lines
1.7 KiB
Ruby
69 lines
1.7 KiB
Ruby
######################################################################
|
|
# This file is imported from the rubygems project.
|
|
# DO NOT make modifications in this repo. They _will_ be reverted!
|
|
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
|
|
######################################################################
|
|
|
|
require 'rubygems/test_case'
|
|
require "test/rubygems/simple_gem"
|
|
require 'rubygems/validator'
|
|
|
|
class TestGemValidator < Gem::TestCase
|
|
|
|
def setup
|
|
super
|
|
|
|
@simple_gem = SIMPLE_GEM
|
|
@validator = Gem::Validator.new
|
|
end
|
|
|
|
def test_verify_gem_file
|
|
gem_file = File.join @tempdir, 'simple_gem.gem'
|
|
File.open gem_file, 'wb' do |fp| fp.write @simple_gem end
|
|
|
|
assert_equal nil, @validator.verify_gem_file(gem_file)
|
|
end
|
|
|
|
def test_verify_gem_file_empty
|
|
e = assert_raises Gem::VerificationError do
|
|
@validator.verify_gem_file ''
|
|
end
|
|
|
|
assert_equal 'missing gem file ', e.message
|
|
end
|
|
|
|
def test_verify_gem_file_nonexistent
|
|
file = '/nonexistent/nonexistent.gem'
|
|
e = assert_raises Gem::VerificationError do
|
|
@validator.verify_gem_file file
|
|
end
|
|
|
|
assert_equal "missing gem file #{file}", e.message
|
|
end
|
|
|
|
def test_verify_gem
|
|
assert_equal nil, @validator.verify_gem(@simple_gem)
|
|
end
|
|
|
|
def test_verify_gem_empty
|
|
e = assert_raises Gem::VerificationError do
|
|
@validator.verify_gem ''
|
|
end
|
|
|
|
assert_equal 'empty gem file', e.message
|
|
end
|
|
|
|
def test_verify_gem_invalid_checksum
|
|
e = assert_raises Gem::VerificationError do
|
|
@validator.verify_gem @simple_gem.upcase
|
|
end
|
|
|
|
assert_equal 'invalid checksum for gem file', e.message
|
|
end
|
|
|
|
def test_verify_gem_no_sum
|
|
assert_equal nil, @validator.verify_gem('words')
|
|
end
|
|
|
|
end
|
|
|