Sha256: 095a5354577a48e6264f7775b1e52ccf12c4ab99117a448b2faedd0b3e3bc1d3

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

require 'bundler/setup'

require 'simplecov'
SimpleCov.start

require 'resque'
require 'sidekiq'

require 'harness'

require 'minitest/unit'
require 'minitest/pride'
require 'minitest/autorun'

require 'webmock/minitest'

WebMock.disable_net_connect!

Harness.logger = Logger.new '/dev/null'

Harness.redis = Redis::Namespace.new 'harness-test', :redis => Redis.connect(:host => 'localhost', :port => '6379')

class IntegrationTest < MiniTest::Unit::TestCase
  def setup
    Harness.config.adapter = :memory
    Harness.config.queue = :syncronous

    gauges.clear ; counters.clear
    redis.flushall
  end

  def assert_gauge_logged(name)
    refute_empty gauges.select {|g| g.name = name }, "Expected #{gauges.inspect} to contain a #{name} result"
  end

  def assert_counter_logged(name)
    refute_empty counters.select {|c| c.name = name }, "Expected #{counters.inspect} to contain a #{name} result"
  end

  def refute_gauge_logged(name)
    assert_empty gauges.select {|g| g.name = name }, "No gauge expected to be logged"
  end

  def refute_counter_logged(name)
    assert_empty counters.select {|c| c.name = name }, "No counter expected to be logged"
  end

  def gauges
    Harness::MemoryAdapter.gauges
  end

  def counters
    Harness::MemoryAdapter.counters
  end

  def redis
    Harness.redis
  end

  def instrument(name, data = {})
    ActiveSupport::Notifications.instrument name, data do 
      # nothing
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
harness-0.3.0 test/test_helper.rb
harness-0.2.16 test/test_helper.rb