Sha256: adaedf9125df94a0ab1dde0d31fa38603c135778c406d828c2ac9345ca6956ce

Contents?: true

Size: 944 Bytes

Versions: 2

Compression:

Stored size: 944 Bytes

Contents

require File.dirname(__FILE__) + '/helper'

class UserInformerTest < Test::Unit::TestCase
  should "modify output if there is a hoptoad id" do
    main_app = lambda do |env|
      env['hoptoad.error_id'] = 1
      [200, {}, "<!-- HOPTOAD ERROR -->"]
    end
    informer_app = HoptoadNotifier::UserInformer.new(main_app)

    ShamRack.mount(informer_app, "example.com")

    response = Net::HTTP.get_response(URI.parse("http://example.com/"))
    assert_equal "Hoptoad Error 1", response.body
    assert_equal 15, response["Content-Length"].to_i
  end

  should "not modify output if there is no hoptoad id" do
    main_app = lambda do |env|
      [200, {}, "<!-- HOPTOAD ERROR -->"]
    end
    informer_app = HoptoadNotifier::UserInformer.new(main_app)

    ShamRack.mount(informer_app, "example.com")

    response = Net::HTTP.get_response(URI.parse("http://example.com/"))
    assert_equal "<!-- HOPTOAD ERROR -->", response.body
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hoptoad_notifier-2.4.5 test/user_informer_test.rb
hoptoad_notifier-2.4.4 test/user_informer_test.rb