Sha256: ba050303c26e5604e82004e08efd8768586cf2b6dd37351d8a8ef35fbe245988

Contents?: true

Size: 1.92 KB

Versions: 7

Compression:

Stored size: 1.92 KB

Contents

ENV['RAILS_ENV'] ||= 'test'
ENV['RACK_ENV'] ||= 'test'
ENV['PADRINO_ENV'] ||= 'test'

APPSIGNAL_SPEC_DIR = File.expand_path(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(APPSIGNAL_SPEC_DIR, 'support/stubs'))

Bundler.require :default
require 'rack'
require 'rspec'
require 'pry'
require 'timecop'
require 'webmock/rspec'

Dir[File.join(APPSIGNAL_SPEC_DIR, 'support/helpers', '*.rb')].each do |f|
  require f
end
if DependencyHelper.rails_present?
  Dir[File.join(DirectoryHelper.support_dir, 'rails', '*.rb')].each do |f|
    require f
  end
end
require 'appsignal'

puts "Running specs in #{RUBY_VERSION} on #{RUBY_PLATFORM}\n\n"

# Add way to clear subscribers between specs
module ActiveSupport
  module Notifications
    class Fanout
      def clear_subscribers
        @subscribers.clear
        @listeners_for.clear
      end
    end
  end
end

RSpec.configure do |config|
  config.include DirectoryHelper
  config.include StdStreamsHelper
  config.include ConfigHelpers
  config.include EnvHelpers
  config.include TimeHelpers
  config.include TransactionHelpers
  config.include ApiRequestHelper
  config.include SystemHelpers
  config.extend DependencyHelper

  config.before :all do
    # Use modified SYSTEM_TMP_DIR
    Appsignal::Config.send :remove_const, :SYSTEM_TMP_DIR
    Appsignal::Config.send :const_set, :SYSTEM_TMP_DIR,
      File.join(tmp_dir, 'system-tmp')

    FileUtils.rm_rf(tmp_dir)
    FileUtils.mkdir_p(Appsignal::Config::SYSTEM_TMP_DIR)
  end

  config.before do
    ENV['RAILS_ENV'] ||= 'test'
    ENV['RACK_ENV'] ||= 'test'
    ENV['PADRINO_ENV'] ||= 'test'

    # Clean environment
    ENV.keys.select { |key| key.start_with?('APPSIGNAL_') }.each do |key|
      ENV.delete(key)
    end
  end

  config.after do
    Thread.current[:appsignal_transaction] = nil
  end

  config.after :all do
    FileUtils.rm_f(File.join(project_fixture_path, 'log/appsignal.log'))
    Appsignal.config = nil
    Appsignal.logger = nil
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
appsignal-2.0.6 spec/spec_helper.rb
appsignal-2.0.5 spec/spec_helper.rb
appsignal-2.0.5.beta.1 spec/spec_helper.rb
appsignal-2.1.0.alpha.3 spec/spec_helper.rb
appsignal-2.1.0.alpha.2 spec/spec_helper.rb
appsignal-2.1.0.alpha.1 spec/spec_helper.rb
appsignal-2.0.4 spec/spec_helper.rb