Skip to content
Browse files

Added integration/readme coverage of Sinatra apps

  • Loading branch information...
1 parent 3496c0f commit d071193404cc03fdebfe34542780a4fe12f041c3 @jferris jferris committed Jan 27, 2010
Showing with 55 additions and 1 deletion.
  1. +21 −0 README.rdoc
  2. +1 −1 Rakefile
  3. +33 −0 features/sinatra.feature
View
21 README.rdoc
@@ -86,6 +86,27 @@ middleware:
run lambda { |env| raise "Rack down" }
end
+== Sinatra
+
+Using hoptoad_notifier in a Sinatra app is just like a Rack app, but you have
+to disable Sinatra's error rescuing functionality:
+
+ require 'sinatra/base'
+ require 'hoptoad_notifier'
+
+ HoptoadNotifier.configure do |config|
+ config.api_key = 'my_api_key'
+ end
+
+ class MyApp < Sinatra::Default
+ use HoptoadNotifier::Rack
+ enable :raise_errors
+
+ get "/" do
+ raise "Sinatra has left the building"
+ end
+ end
+
== Usage
For the most part, Hoptoad works for itself. Once you've included the notifier
View
2 Rakefile
@@ -81,7 +81,7 @@ end
LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze
RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n")
-LOCAL_GEMS = [['sham_rack', nil], ['capistrano', nil], ['sqlite3-ruby', nil]] +
+LOCAL_GEMS = [['sham_rack', nil], ['capistrano', nil], ['sqlite3-ruby', nil], ['sinatra', nil]] +
RAILS_VERSIONS.collect { |version| ['rails', version] }
task :vendor_test_gems do
View
33 features/sinatra.feature
@@ -0,0 +1,33 @@
+Feature: Use the notifier in a Sinatra app
+
+ Background:
+ Given I have built and installed the "hoptoad_notifier" gem
+
+ Scenario: Rescue an exception in a Sinatra app
+ Given the following Rack app:
+ """
+ require 'sinatra/base'
+ require 'hoptoad_notifier'
+
+ HoptoadNotifier.configure do |config|
+ config.api_key = 'my_api_key'
+ end
+
+ class FontaneApp < Sinatra::Default
+ use HoptoadNotifier::Rack
+ enable :raise_errors
+
+ get "/test/index" do
+ raise "Sinatra has left the building"
+ end
+ end
+
+ app = FontaneApp
+ """
+ When I perform a Rack request to "http://example.com:123/test/index?param=value"
+ Then I should receive the following Hoptoad notification:
+ | error message | RuntimeError: Sinatra has left the building |
+ | error class | RuntimeError |
+ | parameters | param: value |
+ | url | http://example.com:123/test/index?param=value |
+

0 comments on commit d071193

Please sign in to comment.
Something went wrong with that request. Please try again.