Sha256: 8148cfcfdb2ec1269232d4f9c425005b4faa59c15eda34543237bc9fca70d67f

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require 'helper'

class Rack::JiraExceptionCollector::TestLogException < Test::Unit::TestCase
  def setup
    @collector_url = "http://example.com/rest/collectors/1.0/template/form/ac29dace"
    FakeWeb.register_uri(:post, @collector_url,
                         :body => "Thanks for providing your feedback", :status => ["200", "OK"])

    @app = Rack::Lobster.new
    @collector = Rack::JiraExceptionCollector.new @app, @collector_url
    @request = Rack::MockRequest.new @collector
  end

  def test_exception_was_sent
    ENV['RACK_ENV'] = 'test'
    env = Rack::MockRequest.env_for('/?flip=crash', :method => 'GET')
    assert_raise(RuntimeError) { @collector.call(env) }
    assert_true env['jira.notified'], "JIRA exception created"
  end

  def test_exception_can_be_sent_from_a_custom_env
    ENV['RACK_ENV'] = "my_custom_env"
    env = Rack::MockRequest.env_for('/?flip=crash', :method => 'GET')
    collector = Rack::JiraExceptionCollector.new @app, @collector_url, "my_custom_env"
    assert_raise(RuntimeError) { collector.call(env) }
    assert_true env['jira.notified'], "JIRA exception created"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jira_exception_collector-0.8.0 test/test_log_exception.rb
jira_exception_collector-0.0.1 test/test_log_exception.rb