Skip to content

Commit

Permalink
Adds pry to the gems available in test env
Browse files Browse the repository at this point in the history
Removes unused inclusion of the TestMethods in AirbrakeController
Refactor the setup_http_connection tests for sanity
  • Loading branch information
dvdplm committed Jan 25, 2012
1 parent efdb2bd commit 5d645ed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -4,6 +4,7 @@ gemspec

if true
group :test do
gem 'pry'
gem 'guard'
gem 'guard-test'
end
Expand Down
4 changes: 0 additions & 4 deletions test/helper.rb
Expand Up @@ -55,10 +55,6 @@ def manual_notify_ignored
end
end

class AirbrakeController < ActionController::Base
include TestMethods
end

class Test::Unit::TestCase
def request(action = nil, method = :get, user_agent = nil, params = {})
@request = ActionController::TestRequest.new
Expand Down
2 changes: 1 addition & 1 deletion test/notifier_test.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/helper'
require File.expand_path( File.join(File.dirname(__FILE__), 'helper') )

class NotifierTest < Test::Unit::TestCase

Expand Down
24 changes: 12 additions & 12 deletions test/sender_test.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/helper'
require File.expand_path( File.join(File.dirname(__FILE__), 'helper') )

class SenderTest < Test::Unit::TestCase

Expand Down Expand Up @@ -64,30 +64,30 @@ def stub_http(options = {})
assert_equal "3799307", send_exception(:secure => false)
end

context "exceptions" do
context "when encountering exceptions: " do
context "HTTP connection setup problems" do
should "not be rescued" do
http = stub(:new => NoMemoryError.new)
proxy = stub(:new => http)
proxy = stub()
proxy.stubs(:new).raises(NoMemoryError)
Net::HTTP.stubs(:Proxy => proxy)

assert_raise do
assert_raise NoMemoryError do
build_sender.send(:setup_http_connection)
end
end

should "be logged" do
http = stub(:new => NoMemoryError.new)
proxy = stub(:new => http)
proxy = stub()
proxy.stubs(:new).raises(RuntimeError)
Net::HTTP.stubs(:Proxy => proxy)

sender = build_sender

assert_raise do
sender.expects(:log).with(:error, includes('Failure initializing the HTTP connection'))

sender.expects(:log).with(:error, includes('Failure initializing the HTTP connection'))

assert_raise RuntimeError do
sender.send(:setup_http_connection)
end

end
end

Expand All @@ -102,7 +102,7 @@ def stub_http(options = {})

should "return nil no matter what" do
sender = build_sender
sender.stubs(:setup_http_connection).raises(SystemExit.new)
sender.stubs(:setup_http_connection).raises(LocalJumpError)

assert_nothing_thrown do
assert_nil sender.send_to_airbrake("stuff")
Expand Down

0 comments on commit 5d645ed

Please sign in to comment.