2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2019-06-01 05:45:11 -04:00
|
|
|
|
2021-06-01 23:32:47 -04:00
|
|
|
require_relative "helper"
|
2019-06-01 05:45:11 -04:00
|
|
|
require "rubygems/validator"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
class TestGemValidator < Gem::TestCase
|
2007-11-10 02:48:56 -05:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@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'),
|
2020-12-08 02:33:39 -05:00
|
|
|
],
|
2012-11-29 01:52:18 -05:00
|
|
|
}
|
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
|