-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathtest
executable file
·82 lines (68 loc) · 2.47 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env ruby
require File.expand_path(File.join(__FILE__, '..', 'helper.rb'))
require 'minitest/spec'
require 'minitest/autorun'
class MiniTest::Spec
include Helper
end
describe 'gems.yml' do
it 'is sorted' do
sorted = YAML.dump(sort_hash(YAML.load_file(SciRuby::GEMS_YML)))
if File.read(SciRuby::GEMS_YML) != sorted
puts 'gems.yml has been sorted'
File.write(SciRuby::GEMS_YML, sorted)
fail
end
end
it 'contains no gratuitous keys' do
YAML.load_file(SciRuby::GEMS_YML).each do |name, gem|
gem.each_key {|k| %w(category owner description exclude version module require).include?(k).must_equal true }
gem['require'].wont_equal name if gem['require']
end
end
end
describe SciRuby do
it 'provides Hash of gems' do
SciRuby.gems.must_be_instance_of Hash
SciRuby.gems.each_key {|k| k.must_be_instance_of String }
SciRuby.gems.each do |name, gem|
check_gem(name, gem)
end
end
it 'provides Hash of installed gems' do
SciRuby.installed_gems.must_be_instance_of Hash
SciRuby.installed_gems.each_key {|k| k.must_be_instance_of String }
SciRuby.installed_gems.each do |name, gem|
check_gem(name, gem)
gem[:installed_version].must_be_instance_of String
end
end
it 'provides list of modules' do
SciRuby.modules.must_be_instance_of Array
SciRuby.modules.each {|m| m.must_be_instance_of String }
end
it 'provides list of installed modules' do
SciRuby.installed_modules.must_be_instance_of Array
SciRuby.installed_modules.each {|m| m.must_be_instance_of String }
end
it 'provides list of autoloadable modules' do
SciRuby.autoload_modules.must_be_instance_of Hash
SciRuby.autoload_modules.each_key {|k| k.must_be_instance_of String }
SciRuby.autoload_modules.each_value {|v| v.must_be_instance_of Array }
end
it 'has unique modules' do
mods = SciRuby.gems.each_value.map {|gem| gem[:module] }.flatten
mods.uniq.must_equal mods
end
it 'autoloads modules' do
SciRuby.autoload_modules.must_include 'Prime'
Object.const_defined?('Prime').must_equal false
Prime.must_be_instance_of Class
Object.const_defined?('Prime').must_equal true
SciRuby.autoload_modules.wont_include 'Prime'
SciRuby.installed_gems.each_value.map {|gem| gem[:module] }.flatten.each do |mod|
next if mod == 'R' || mod == 'RinRuby' # FIXME, don't test RinRuby for now since it requires an installaion of R
eval(mod).wont_equal nil
end
end
end