Sha256: e6301bfd881dc6e0419bbd1d6fe16096ad8fba5cc87132deaff5a29a35e466fb

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'test_helper'

class ExceptionMonitorRackTest < ChilloutTestCase
  include Rack::Test::Methods

  def setup
    api_key = "xyz123"
    stub_api_request(api_key, "events")
    @config = Chillout::Config.new(api_key)
    @config.ssl = false
    @client = Chillout::Client.new(@config)
  end

  def app
    client = @client # Only local variable can be passed to the block below
    Rack::Builder.new do
      use Chillout::Middleware::ExceptionMonitor, client
      run(lambda { |env| raise ChilloutTestException.new("Something went wrong") })
    end
  end

  def test_exception_class
    trigger_error
    assert_equal "ChilloutTestException", request_body["content"]["class"]
  end

  def test_exception_message
    trigger_error
    assert_equal "Something went wrong", request_body["content"]["message"]
  end

  def test_rack_environment
    trigger_error
    assert_request_body "events" do |body|
      assert_equal last_request.env.keys, body["content"]["rack_environment"].keys
    end
  end

  private
  def trigger_error
    begin
      get "/"
    rescue ChilloutTestException
    end
  end

  def request_body
    assert_request_body("events"){ |body| return body }
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chillout-0.2.3 test/integration/exception_monitor_rack_test.rb
chillout-0.2.2 test/integration/exception_monitor_rack_test.rb
chillout-0.2.1 test/integration/exception_monitor_rack_test.rb
chillout-0.2.0 test/integration/exception_monitor_rack_test.rb