errornot_notifier 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/INSTALL +25 -0
  2. data/MIT-LICENSE +22 -0
  3. data/README.rdoc +289 -0
  4. data/Rakefile +124 -0
  5. data/SUPPORTED_RAILS_VERSIONS +8 -0
  6. data/TESTING.rdoc +8 -0
  7. data/generators/hoptoad/hoptoad_generator.rb +55 -0
  8. data/generators/hoptoad/lib/insert_commands.rb +34 -0
  9. data/generators/hoptoad/lib/rake_commands.rb +24 -0
  10. data/generators/hoptoad/templates/capistrano_hook.rb +6 -0
  11. data/generators/hoptoad/templates/hoptoad_notifier_tasks.rake +5 -0
  12. data/generators/hoptoad/templates/initializer.rb +7 -0
  13. data/lib/hoptoad_notifier/backtrace.rb +99 -0
  14. data/lib/hoptoad_notifier/capistrano.rb +20 -0
  15. data/lib/hoptoad_notifier/configuration.rb +232 -0
  16. data/lib/hoptoad_notifier/notice.rb +287 -0
  17. data/lib/hoptoad_notifier/rack.rb +40 -0
  18. data/lib/hoptoad_notifier/rails/action_controller_catcher.rb +29 -0
  19. data/lib/hoptoad_notifier/rails/controller_methods.rb +59 -0
  20. data/lib/hoptoad_notifier/rails/error_lookup.rb +33 -0
  21. data/lib/hoptoad_notifier/rails.rb +37 -0
  22. data/lib/hoptoad_notifier/sender.rb +85 -0
  23. data/lib/hoptoad_notifier/tasks.rb +97 -0
  24. data/lib/hoptoad_notifier/version.rb +3 -0
  25. data/lib/hoptoad_notifier.rb +146 -0
  26. data/lib/hoptoad_tasks.rb +37 -0
  27. data/lib/templates/rescue.erb +91 -0
  28. data/rails/init.rb +1 -0
  29. data/script/integration_test.rb +38 -0
  30. data/test/backtrace_test.rb +118 -0
  31. data/test/catcher_test.rb +300 -0
  32. data/test/configuration_test.rb +208 -0
  33. data/test/helper.rb +232 -0
  34. data/test/hoptoad_tasks_test.rb +138 -0
  35. data/test/logger_test.rb +85 -0
  36. data/test/notice_test.rb +395 -0
  37. data/test/notifier_test.rb +222 -0
  38. data/test/rack_test.rb +58 -0
  39. data/test/rails_initializer_test.rb +36 -0
  40. data/test/sender_test.rb +123 -0
  41. metadata +164 -0
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ require 'hoptoad_notifier/rails'
4
+
5
+ class RailsInitializerTest < Test::Unit::TestCase
6
+ include DefinesConstants
7
+
8
+ should "trigger use of Rails' logger if logger isn't set and Rails' logger exists" do
9
+ rails = Module.new do
10
+ def self.logger
11
+ "RAILS LOGGER"
12
+ end
13
+ end
14
+ define_constant("Rails", rails)
15
+ HoptoadNotifier::Rails.initialize
16
+ assert_equal "RAILS LOGGER", HoptoadNotifier.logger
17
+ end
18
+
19
+ should "trigger use of Rails' default logger if logger isn't set and Rails.logger doesn't exist" do
20
+ define_constant("RAILS_DEFAULT_LOGGER", "RAILS DEFAULT LOGGER")
21
+
22
+ HoptoadNotifier::Rails.initialize
23
+ assert_equal "RAILS DEFAULT LOGGER", HoptoadNotifier.logger
24
+ end
25
+
26
+ should "allow overriding of the logger if already assigned" do
27
+ define_constant("RAILS_DEFAULT_LOGGER", "RAILS DEFAULT LOGGER")
28
+ HoptoadNotifier::Rails.initialize
29
+
30
+ HoptoadNotifier.configure(true) do |config|
31
+ config.logger = "OVERRIDDEN LOGGER"
32
+ end
33
+
34
+ assert_equal "OVERRIDDEN LOGGER", HoptoadNotifier.logger
35
+ end
36
+ end
@@ -0,0 +1,123 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class SenderTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ reset_config
7
+ end
8
+
9
+ def build_sender(opts = {})
10
+ config = HoptoadNotifier::Configuration.new
11
+ opts.each {|opt, value| config.send(:"#{opt}=", value) }
12
+ HoptoadNotifier::Sender.new(config)
13
+ end
14
+
15
+ def send_exception(args = {})
16
+ notice = args.delete(:notice) || build_notice_data
17
+ sender = args.delete(:sender) || build_sender(args)
18
+ sender.send_to_hoptoad(notice)
19
+ sender
20
+ end
21
+
22
+ def stub_http
23
+ response = stub(:body => 'body')
24
+ http = stub(:post => response,
25
+ :read_timeout= => nil,
26
+ :open_timeout= => nil,
27
+ :use_ssl= => nil)
28
+ Net::HTTP.stubs(:new => http)
29
+ http
30
+ end
31
+
32
+ should "post to Hoptoad when using an HTTP proxy" do
33
+ response = stub(:body => 'body')
34
+ http = stub(:post => response,
35
+ :read_timeout= => nil,
36
+ :open_timeout= => nil,
37
+ :use_ssl= => nil)
38
+ proxy = stub(:new => http)
39
+ Net::HTTP.stubs(:Proxy => proxy)
40
+
41
+ url = "http://hoptoadapp.com:80#{HoptoadNotifier::Sender::NOTICES_URI}"
42
+ uri = URI.parse(url)
43
+
44
+ proxy_host = 'some.host'
45
+ proxy_port = 88
46
+ proxy_user = 'login'
47
+ proxy_pass = 'passwd'
48
+
49
+ send_exception(:proxy_host => proxy_host,
50
+ :proxy_port => proxy_port,
51
+ :proxy_user => proxy_user,
52
+ :proxy_pass => proxy_pass)
53
+ assert_received(http, :post) do |expect|
54
+ expect.with(uri.path, anything, HoptoadNotifier::HEADERS)
55
+ end
56
+ assert_received(Net::HTTP, :Proxy) do |expect|
57
+ expect.with(proxy_host, proxy_port, proxy_user, proxy_pass)
58
+ end
59
+ end
60
+
61
+ should "post to the right url for non-ssl" do
62
+ http = stub_http
63
+ url = "http://hoptoadapp.com:80#{HoptoadNotifier::Sender::NOTICES_URI}"
64
+ uri = URI.parse(url)
65
+ send_exception(:secure => false)
66
+ assert_received(http, :post) {|expect| expect.with(uri.path, anything, HoptoadNotifier::HEADERS) }
67
+ end
68
+
69
+ should "post to the right path for ssl" do
70
+ http = stub_http
71
+ send_exception(:secure => true)
72
+ assert_received(http, :post) {|expect| expect.with(HoptoadNotifier::Sender::NOTICES_URI, anything, HoptoadNotifier::HEADERS) }
73
+ end
74
+
75
+ should "default the open timeout to 2 seconds" do
76
+ http = stub_http
77
+ send_exception
78
+ assert_received(http, :open_timeout=) {|expect| expect.with(2) }
79
+ end
80
+
81
+ should "default the read timeout to 5 seconds" do
82
+ http = stub_http
83
+ send_exception
84
+ assert_received(http, :read_timeout=) {|expect| expect.with(5) }
85
+ end
86
+
87
+ should "allow override of the open timeout" do
88
+ http = stub_http
89
+ send_exception(:http_open_timeout => 4)
90
+ assert_received(http, :open_timeout=) {|expect| expect.with(4) }
91
+ end
92
+
93
+ should "allow override of the read timeout" do
94
+ http = stub_http
95
+ send_exception(:http_read_timeout => 10)
96
+ assert_received(http, :read_timeout=) {|expect| expect.with(10) }
97
+ end
98
+
99
+ should "connect to the right port for ssl" do
100
+ stub_http
101
+ send_exception(:secure => true)
102
+ assert_received(Net::HTTP, :new) {|expect| expect.with("hoptoadapp.com", 443) }
103
+ end
104
+
105
+ should "connect to the right port for non-ssl" do
106
+ stub_http
107
+ send_exception(:secure => false)
108
+ assert_received(Net::HTTP, :new) {|expect| expect.with("hoptoadapp.com", 80) }
109
+ end
110
+
111
+ should "use ssl if secure" do
112
+ stub_http
113
+ send_exception(:secure => true, :host => 'example.org')
114
+ assert_received(Net::HTTP, :new) {|expect| expect.with('example.org', 443) }
115
+ end
116
+
117
+ should "not use ssl if not secure" do
118
+ stub_http
119
+ send_exception(:secure => false, :host => 'example.org')
120
+ assert_received(Net::HTTP, :new) {|expect| expect.with('example.org', 80) }
121
+ end
122
+
123
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: errornot_notifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - thoughtbot, inc, Cyril Mougel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-20 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: activerecord
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: actionpack
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: jferris-mocha
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: shoulda
67
+ type: :development
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ description:
76
+ email: support@hoptoadapp.com
77
+ executables: []
78
+
79
+ extensions: []
80
+
81
+ extra_rdoc_files:
82
+ - README.rdoc
83
+ files:
84
+ - INSTALL
85
+ - MIT-LICENSE
86
+ - Rakefile
87
+ - README.rdoc
88
+ - SUPPORTED_RAILS_VERSIONS
89
+ - TESTING.rdoc
90
+ - generators/hoptoad/hoptoad_generator.rb
91
+ - generators/hoptoad/lib/insert_commands.rb
92
+ - generators/hoptoad/lib/rake_commands.rb
93
+ - generators/hoptoad/templates/capistrano_hook.rb
94
+ - generators/hoptoad/templates/hoptoad_notifier_tasks.rake
95
+ - generators/hoptoad/templates/initializer.rb
96
+ - lib/hoptoad_notifier/backtrace.rb
97
+ - lib/hoptoad_notifier/capistrano.rb
98
+ - lib/hoptoad_notifier/configuration.rb
99
+ - lib/hoptoad_notifier/notice.rb
100
+ - lib/hoptoad_notifier/rack.rb
101
+ - lib/hoptoad_notifier/rails/action_controller_catcher.rb
102
+ - lib/hoptoad_notifier/rails/controller_methods.rb
103
+ - lib/hoptoad_notifier/rails/error_lookup.rb
104
+ - lib/hoptoad_notifier/rails.rb
105
+ - lib/hoptoad_notifier/sender.rb
106
+ - lib/hoptoad_notifier/tasks.rb
107
+ - lib/hoptoad_notifier/version.rb
108
+ - lib/hoptoad_notifier.rb
109
+ - lib/hoptoad_tasks.rb
110
+ - test/backtrace_test.rb
111
+ - test/catcher_test.rb
112
+ - test/configuration_test.rb
113
+ - test/helper.rb
114
+ - test/hoptoad_tasks_test.rb
115
+ - test/logger_test.rb
116
+ - test/notice_test.rb
117
+ - test/notifier_test.rb
118
+ - test/rack_test.rb
119
+ - test/rails_initializer_test.rb
120
+ - test/sender_test.rb
121
+ - rails/init.rb
122
+ - script/integration_test.rb
123
+ - lib/templates/rescue.erb
124
+ has_rdoc: true
125
+ homepage: http://www.hoptoadapp.com
126
+ licenses: []
127
+
128
+ post_install_message:
129
+ rdoc_options:
130
+ - --line-numbers
131
+ - --main
132
+ - README.rdoc
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: "0"
140
+ version:
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: "0"
146
+ version:
147
+ requirements: []
148
+
149
+ rubyforge_project:
150
+ rubygems_version: 1.3.5
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: Send your application errors to a hosted service and reclaim your inbox.
154
+ test_files:
155
+ - test/backtrace_test.rb
156
+ - test/catcher_test.rb
157
+ - test/configuration_test.rb
158
+ - test/hoptoad_tasks_test.rb
159
+ - test/logger_test.rb
160
+ - test/notice_test.rb
161
+ - test/notifier_test.rb
162
+ - test/rack_test.rb
163
+ - test/rails_initializer_test.rb
164
+ - test/sender_test.rb