2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2011-01-28 18:46:47 -05:00
|
|
|
require 'rubygems/test_case'
|
2011-03-07 03:44:45 -05:00
|
|
|
require "rubygems/simple_gem"
|
2007-11-10 02:48:56 -05:00
|
|
|
require 'rubygems/validator'
|
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
class TestGemValidator < Gem::TestCase
|
2007-11-10 02:48:56 -05:00
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@simple_gem = SIMPLE_GEM
|
|
|
|
@validator = Gem::Validator.new
|
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_alien
|
|
|
|
@spec = quick_gem 'a' do |s|
|
|
|
|
s.files = %w[lib/a.rb lib/b.rb]
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
util_build_gem @spec
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
FileUtils.rm File.join(@spec.gem_dir, 'lib/b.rb')
|
|
|
|
FileUtils.touch File.join(@spec.gem_dir, 'lib/c.rb')
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
alien = @validator.alien 'a'
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
expected = {
|
|
|
|
@spec.file_name => [
|
|
|
|
Gem::Validator::ErrorData.new('lib/b.rb', 'Missing file'),
|
|
|
|
Gem::Validator::ErrorData.new('lib/c.rb', 'Extra file'),
|
|
|
|
]
|
|
|
|
}
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
assert_equal expected, alien
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
2013-11-30 18:27:52 -05:00
|
|
|
|
|
|
|
def test_alien_default
|
|
|
|
new_default_spec 'c', 1, nil, 'lib/c.rb'
|
|
|
|
|
|
|
|
alien = @validator.alien 'c'
|
|
|
|
|
|
|
|
assert_empty alien
|
|
|
|
end
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|