if ENV['COVERAGE'] require 'simplecov' SimpleCov.start do add_filter '/spec/' end end require 'bundler' Bundler.require(:default, :test) $:.unshift(File.dirname(__FILE__) + '/../lib') # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} # silence deprecation warning require 'i18n' I18n.enforce_available_locales = true require 'redis' require 'influxdb' # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # Require this file using `require "spec_helper"` to ensure that it is only # loaded once. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.run_all_when_everything_filtered = true config.filter_run :focus # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 # config.order = 'random' config.around(:each, :logger => true) do |example| MockLogger.configure_log('zermelo') Zermelo.logger = MockLogger.new example.run puts Zermelo.logger.messages.compact.join("\n") Zermelo.logger.clear end config.before(:all, :redis => true) do Zermelo.redis = ::Redis.new(:db => 14) end config.before(:each, :redis => true) do Zermelo.redis.select(14) Zermelo.redis.flushdb end config.after(:all, :redis => true) do Zermelo.redis.quit end config.before(:all, :influxdb => true) do Zermelo.influxdb = InfluxDB::Client.new('zermelo_test', :username => 'zermelo', :password => 'zermelo', :retry => false) end config.before(:each, :influxdb => true) do Zermelo.influxdb.query('list series')['list_series_result'].each do |ser| Zermelo.influxdb.query("DELETE FROM \"#{ser['name']}\"") end end config.after(:each, :time => true) do Timecop.return end end