resque-exceptional 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48421f431f10aec6b365354e1d44dd0c66272050
4
- data.tar.gz: 7dee6f702e31f801708c436121ed8de4460aae9f
3
+ metadata.gz: 8ffbc88a8025ed460a763e49c28497a9906edb85
4
+ data.tar.gz: a1bd338c3a4811726d677bc2f9ec85ef1c47ae2f
5
5
  SHA512:
6
- metadata.gz: 8536ba180441cd4e048fbddb1d6c422cbda6b32439e3c6a737e19d5f9bdc01d25c107f0b2b8b7334f95e1d27880cae70d2e83ce23e200a556c084d95f6189465
7
- data.tar.gz: 2ad61434db9e6ab41a623d2cf93ca44fced897310d81ecc4dd84f3a6b87cd36597ff6c7414ec1e6ccc6798f7b2d19580c85ad8904c8eb1488f75cf37e05f5a50
6
+ metadata.gz: 1156a381b68ea151adc95fdc8c5a74a4191f5c059bad76254cde8d40b84e0e23a891cf9d89c05b4406cb67c7e270e2403d97cb085f9cd183ed7eea77dc97a3f0
7
+ data.tar.gz: 1e9d27a6030d5d6864aec7114ec95ef94d0d390e708b690b571593bd5f944b99358b3e16d62ab199a235dad4ba828204faadf6280a563104e2c30db7e340e58c
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.2 (2014-02-21)
2
+
3
+ * Add `deliver?` helper method.
4
+ * Improve tests and ensure they are not order order.
5
+
1
6
  ## 0.2.1 (2014-02-21)
2
7
 
3
8
  * Add `deliver` config option; `false` will disable delivery, good for tests.
data/README.md CHANGED
@@ -53,6 +53,10 @@ Configuration Options
53
53
 
54
54
  * `api_key` - your getexceptional.com api key.
55
55
 
56
+ **General Options** *(optional)*
57
+
58
+ * `deliver` - set `false` to disable delivery of errors to exceptional API, handy for testing (default: `true`)
59
+
56
60
  **HTTP Proxy Options** *(optional)*
57
61
 
58
62
  * `proxy_host` - proxy server ip / hostname.
@@ -66,18 +70,6 @@ Configuration Options
66
70
  * `http_open_timeout` - timeout in seconds to establish the connection. (default: `2`)
67
71
  * `http_read_timeout` - timeout in seconds to wait for a reply. (default: `5`)
68
72
 
69
- Screenshots
70
- -----------
71
-
72
- Below are some screenshots of the getexceptional.com web interface, showing
73
- Resque exceptions.
74
-
75
- **App Overview**
76
- ![Get Exceptional - Overview](http://img.skitch.com/20101013-k7hgurmaqew6sn8cik5gywbt2.png)
77
-
78
- **Detailed Information**
79
- ![Get Exceptional - Details](http://img.skitch.com/20101013-ftjrjhh3fegcqr9mig9kttmwi4.png)
80
-
81
73
  Note on Patches/Pull Requests
82
74
  -----------------------------
83
75
 
@@ -2,7 +2,7 @@ module Resque
2
2
  module Failure
3
3
  # A Resque failure backend that sends exception data to getexceptional.com
4
4
  class Exceptional < Base
5
- Version = '0.2.1' # Failure backend version number.
5
+ Version = '0.2.2' # Failure backend version number.
6
6
 
7
7
  # Raised if the api_key is not set.
8
8
  class APIKeyError < StandardError
@@ -34,7 +34,7 @@ module Resque
34
34
  #
35
35
  # When a job fails, a new instance is created and #save is called.
36
36
  def save
37
- return nil if self.class.deliver === false
37
+ return unless deliver?
38
38
  return unless response = http_post_request
39
39
 
40
40
  if response.code == '200'
@@ -132,6 +132,13 @@ module Resque
132
132
  self.class.use_ssl || false
133
133
  end
134
134
 
135
+ # Helper method to check if errors should be submitted to exceptional API.
136
+ #
137
+ # @return [Boolean] true if deliver is enabled.
138
+ def deliver?
139
+ self.class.deliver.nil? || self.class.deliver
140
+ end
141
+
135
142
  # Adds a prefix to log messages.
136
143
  #
137
144
  # @param [String] msg your log message.
@@ -69,6 +69,7 @@ class ExceptionalTest < Minitest::Test
69
69
  def test_configure
70
70
  Resque::Failure::Exceptional.configure do |config|
71
71
  config.api_key = 'my api key.'
72
+ config.deliver = false
72
73
  # everything below are http client options.
73
74
  config.proxy_host = 'host.name.com'
74
75
  config.proxy_port = 8080
@@ -81,8 +82,8 @@ class ExceptionalTest < Minitest::Test
81
82
 
82
83
  # reset everything to nil...
83
84
  Resque::Failure::Exceptional.configure do |config|
84
- options = %w{api_key proxy_host proxy_port proxy_user proxy_pass use_ssl
85
- http_open_timeout http_read_timeout}
85
+ options = %w{api_key deliver proxy_host proxy_port proxy_user proxy_pass
86
+ use_ssl http_open_timeout http_read_timeout}
86
87
  options.each { |opt| config.send("#{opt}=", nil) }
87
88
  end
88
89
  end
@@ -117,9 +118,8 @@ class ExceptionalTest < Minitest::Test
117
118
  with_api_key '27810b263f0e11eef2f1d29be75d2f39' do
118
119
  # turn off delivery.
119
120
  Resque::Failure::Exceptional.configure { |c| c.deliver = false }
120
- stub_request(:post, /.*api.exceptional.io.*/)
121
121
  @failure.save
122
- assert_equal(0, @worker.log_history.length)
122
+ assert_equal 0, @worker.log_history.length, 'should not send any requests'
123
123
 
124
124
  # Put default setting back in place.
125
125
  Resque::Failure::Exceptional.configure { |c| c.deliver = nil }
@@ -148,19 +148,25 @@ class ExceptionalTest < Minitest::Test
148
148
  assert_match /^resque-exception - .*/, @worker.log_history.last
149
149
  end
150
150
 
151
- # test our `#use_ssl?` and `#http_port` helper methods.
151
+ # test our `#use_ssl?`, `deliver?` and `#http_port` helper methods.
152
152
  def test_helper_methods
153
- # check defaults
154
- assert_equal false, @failure.use_ssl?, 'use_ssl? should default to false.'
155
- assert_equal 80, @failure.http_port, 'http_port should default to 80.'
156
-
157
153
  # enable ssl.
158
154
  Resque::Failure::Exceptional.configure { |c| c.use_ssl = true }
159
155
  assert_equal true, @failure.use_ssl?, 'use_ssl? should now be true'
160
156
  assert_equal 443, @failure.http_port, 'http_port should now be 443.'
161
157
 
162
- # put the config back.
163
- Resque::Failure::Exceptional.configure { |c| c.use_ssl = false }
158
+ # disable ssl.
159
+ Resque::Failure::Exceptional.configure { |c| c.use_ssl = nil }
160
+ assert_equal false, @failure.use_ssl?, 'use_ssl? should default to false.'
161
+ assert_equal 80, @failure.http_port, 'http_port should default to 80.'
162
+
163
+ # disable delivery.
164
+ Resque::Failure::Exceptional.configure { |c| c.deliver = false }
165
+ assert_equal false, @failure.deliver?, 'deliver should now be false'
166
+
167
+ # enable delivery.
168
+ Resque::Failure::Exceptional.configure { |c| c.deliver = nil }
169
+ assert_equal true, @failure.deliver?, 'deliver should now be true'
164
170
  end
165
171
 
166
172
  # returns nil if the backtrace is empty.
@@ -212,8 +218,10 @@ class ExceptionalTest < Minitest::Test
212
218
 
213
219
  # raise exception if api key is not set.
214
220
  def test_http_path_query_without_api_key_raises_exception
215
- assert_raises Resque::Failure::Exceptional::APIKeyError, 'should raise APIKeyError if api key is not set' do
216
- @failure.http_path_query
221
+ with_api_key nil do
222
+ assert_raises Resque::Failure::Exceptional::APIKeyError, 'should raise APIKeyError if api key is not set' do
223
+ @failure.http_path_query
224
+ end
217
225
  end
218
226
  end
219
227
 
@@ -263,4 +271,4 @@ class ExceptionalTest < Minitest::Test
263
271
  end
264
272
  end
265
273
 
266
- end
274
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-exceptional
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Antins