test_helper.rb revision daa05c1ca31894d2bcba80bea773829908efbef8
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../test/shared_helper", __FILE__)
include SharedHelper
use_simplecov
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'mocha/mini_test'
require Rails.root.join('config', 'database_cleaner.rb')
WebMock.disable_net_connect!(allow_localhost: true)
elasticsearch_port = ENV['ELASTIC_TEST_PORT'].present? ? ENV['ELASTIC_TEST_PORT'] : '9250'
Elasticsearch::Model.client = Elasticsearch::Client.new host: "localhost:#{elasticsearch_port}"
class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
def fixture_file(name)
Rails.root + 'test/fixtures/ontologies/xml/' + name
end
def open_fixture(name)
File.open(fixture_file(name))
end
setup do
# clean git repositories
FileUtils.rmtree Ontohub::Application.config.data_root
FileUtils.rmtree Repository::Symlink::PATH
redis = WrappingRedis::RedisWrapper.new
redis.del redis.keys.join(' ')
end
end
# for devise
class ActionController::TestCase
include Devise::TestHelpers
end
# for strip_attributes
require "strip_attributes/matchers"
class Test::Unit::TestCase
extend StripAttributes::Matchers
end
# For Sidekiq
require 'sidekiq/testing'
# Setting the default for sidekiq testing
# many unit-tests rely on this being the default.
# However specs use a different default (inline!)
Sidekiq::Testing.fake!
# Recording HTTP Requests
VCR.configure do |c|
c.cassette_library_dir = 'test/fixtures/vcr'
c.hook_into :webmock
c.ignore_localhost = true
c.ignore_hosts \
'127.0.0.1',
'localhost',
'colore.googlecode.com',
'trac.informatik.uni-bremen.de'
end