test.rake revision e59ad31cd1fb2fe0d9c9e6b7295c17beaedc63c3
namespace :test do
# We want to purge our database our own way, without deleting everything
Rake::Task['db:test:purge'].overwrite do
Rails.env = 'test'
Rake::Task['db:redis:clean'].invoke
Rake::Task['db:migrate:clean'].invoke
end
def hets_path
`which hets`.strip
end
def hets_out_file_for(ontology_file)
basename = File.basename(ontology_file).sub(/\.[^.]+$/, '.xml')
File.join('test/fixtures/ontologies/hets-out/', basename)
end
def hets_args
YAML.load(File.open('config/hets.yml'))['cmd_line_options']
end
def perform_hets_on(file)
args = hets_args << '-O test/fixtures/ontologies/hets-out'
system("hets #{args.join(' ')} #{file}")
end
def ontology_files
globbed_files = Dir.glob('test/fixtures/ontologies/**/*')
globbed_files.select do |file|
!file.end_with?('xml') && !File.directory?(file)
end
end
desc 'Update all ontology fixtures'
task :freshen_ontology_fixtures do
ontology_files.each do |file|
puts "Calling hets for: #{file}"
perform_hets_on(file)
end
end
end