Sha256: 0b3c26e067071c406a8cbdf6884d7e1257fe239733c250a0e69414a91c72157f

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

# -*- coding: utf-8 -*-
require_relative "../test_helper.rb"
require 'stringio'

class FakeLogger
  def initialize
    @logger = StringIO.new
  end

  def info(message)
    @logger.write(message)
  end

  def reset
    @logger.string = ""
  end

  def get
    @logger.string
  end
end

class RaygunTest < Raygun::UnitTest
  def test_raygun_is_not_configured_with_no_api_key
    Raygun.configuration.api_key = nil
    assert !Raygun.configured?
  end

  def test_should_report_logs_silence_reporting_when_debug_is_on
    logger = setup_logging
    Raygun.configuration.silence_reporting = true
    Raygun.send(:should_report?, Exception.new)

    assert logger.get.include?("silence_reporting"), "silence_reporting was not logged"
  end

  def test_should_report_logs_ignored_exceptions_when_debug_is_on
    logger = setup_logging
    Raygun.configuration.ignore = ["Exception"]
    Raygun.send(:should_report?, Exception.new)

    assert logger.get =~ /skipping reporting of.*Exception.*/, "ignored exception was not logged"
  end

  def setup_logging
    logger = FakeLogger.new
    Raygun.configuration.debug = true
    Raygun.configuration.logger = logger

    logger
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
raygun4ruby-2.0.0 test/unit/raygun_test.rb
raygun4ruby-1.5.0 test/unit/raygun_test.rb
raygun4ruby-1.4.0 test/unit/raygun_test.rb
raygun4ruby-1.3.0 test/unit/raygun_test.rb