Skip to content

Commit

Permalink
Added integration/readme coverage of Sinatra apps
Browse files Browse the repository at this point in the history
  • Loading branch information
jferris committed Jan 28, 2010
1 parent 3496c0f commit d071193
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
21 changes: 21 additions & 0 deletions README.rdoc
Expand Up @@ -86,6 +86,27 @@ middleware:
run lambda { |env| raise "Rack down" } run lambda { |env| raise "Rack down" }
end 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 == Usage


For the most part, Hoptoad works for itself. Once you've included the notifier For the most part, Hoptoad works for itself. Once you've included the notifier
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -81,7 +81,7 @@ end


LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze
RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n") 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] } RAILS_VERSIONS.collect { |version| ['rails', version] }


task :vendor_test_gems do task :vendor_test_gems do
Expand Down
33 changes: 33 additions & 0 deletions 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.