toadhopper-sinatra 0.6 → 0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/sinatra/toadhopper.rb +2 -5
- data/test/test_report_error_to_hoptoad.rb +8 -12
- metadata +1 -1
data/lib/sinatra/toadhopper.rb
CHANGED
@@ -6,7 +6,7 @@ module Sinatra
|
|
6
6
|
module Toadhopper
|
7
7
|
# Reports the current sinatra error to Hoptoad
|
8
8
|
def post_error_to_hoptoad!
|
9
|
-
options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)}
|
9
|
+
options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)} if options.respond_to?(:toadhopper)
|
10
10
|
unless ::Toadhopper.api_key
|
11
11
|
STDERR.puts "WARNING: Ignoring hoptoad notification - :api_key not set"
|
12
12
|
return
|
@@ -29,8 +29,5 @@ module Sinatra
|
|
29
29
|
)
|
30
30
|
end
|
31
31
|
end
|
32
|
-
def self.registered(app)
|
33
|
-
app.set :hoptoad, {}
|
34
|
-
end
|
35
32
|
helpers Toadhopper
|
36
|
-
end
|
33
|
+
end
|
@@ -1,22 +1,18 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
|
+
|
5
|
+
require 'rr'
|
6
|
+
class Test::Unit::TestCase
|
7
|
+
include RR::Adapters::TestUnit
|
8
|
+
end
|
9
|
+
|
4
10
|
require 'sinatra/base'
|
5
11
|
require 'rack/test'
|
6
12
|
|
7
13
|
$:.unshift File.dirname(__FILE__) + "/../lib"
|
8
14
|
require 'sinatra/toadhopper'
|
9
15
|
|
10
|
-
# Stub the Toadhopper posting
|
11
|
-
|
12
|
-
def Toadhopper.post!(*args)
|
13
|
-
instance_variable_set(:@last_post_arguments, args)
|
14
|
-
end
|
15
|
-
|
16
|
-
def Toadhopper.last_post_arguments
|
17
|
-
instance_variable_get(:@last_post_arguments)
|
18
|
-
end
|
19
|
-
|
20
16
|
class TestReportErrorToHoptoad < Test::Unit::TestCase
|
21
17
|
|
22
18
|
class AppThatGoesBoom < Sinatra::Base
|
@@ -44,8 +40,8 @@ class TestReportErrorToHoptoad < Test::Unit::TestCase
|
|
44
40
|
def app; AppThatGoesBoom end
|
45
41
|
|
46
42
|
def setup
|
43
|
+
stub(Toadhopper).post! {|*args| @error, @options, @header_options = *args }
|
47
44
|
get "/theid"
|
48
|
-
@error, @options, @header_options = Toadhopper.last_post_arguments
|
49
45
|
end
|
50
46
|
|
51
47
|
def test_api_key_set
|
@@ -59,7 +55,7 @@ class TestReportErrorToHoptoad < Test::Unit::TestCase
|
|
59
55
|
assert_equal RuntimeError, @error.class
|
60
56
|
assert_equal "Kaboom!", @error.message
|
61
57
|
end
|
62
|
-
|
58
|
+
|
63
59
|
def test_options
|
64
60
|
assert_equal ENV, @options[:environment]
|
65
61
|
assert_equal "http://example.org/theid", @options[:request][:url]
|