airbrake 3.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/.gitignore +18 -0
  2. data/.yardopts +3 -0
  3. data/CHANGELOG +441 -0
  4. data/Gemfile +3 -0
  5. data/INSTALL +25 -0
  6. data/MIT-LICENSE +22 -0
  7. data/README.md +431 -0
  8. data/README_FOR_HEROKU_ADDON.md +93 -0
  9. data/Rakefile +188 -0
  10. data/SUPPORTED_RAILS_VERSIONS +14 -0
  11. data/TESTING.md +26 -0
  12. data/airbrake.gemspec +33 -0
  13. data/features/metal.feature +23 -0
  14. data/features/rack.feature +27 -0
  15. data/features/rails.feature +254 -0
  16. data/features/rails_with_js_notifier.feature +78 -0
  17. data/features/rake.feature +23 -0
  18. data/features/sinatra.feature +33 -0
  19. data/features/step_definitions/airbrake_shim.rb.template +15 -0
  20. data/features/step_definitions/file_steps.rb +10 -0
  21. data/features/step_definitions/metal_steps.rb +23 -0
  22. data/features/step_definitions/rack_steps.rb +20 -0
  23. data/features/step_definitions/rails_application_steps.rb +401 -0
  24. data/features/step_definitions/rake_steps.rb +17 -0
  25. data/features/support/airbrake_shim.rb.template +15 -0
  26. data/features/support/env.rb +18 -0
  27. data/features/support/matchers.rb +35 -0
  28. data/features/support/rails.rb +181 -0
  29. data/features/support/rake/Rakefile +57 -0
  30. data/features/support/terminal.rb +103 -0
  31. data/features/user_informer.feature +63 -0
  32. data/generators/airbrake/airbrake_generator.rb +90 -0
  33. data/generators/airbrake/lib/insert_commands.rb +34 -0
  34. data/generators/airbrake/lib/rake_commands.rb +24 -0
  35. data/generators/airbrake/templates/airbrake_tasks.rake +25 -0
  36. data/generators/airbrake/templates/capistrano_hook.rb +6 -0
  37. data/generators/airbrake/templates/initializer.rb +6 -0
  38. data/install.rb +1 -0
  39. data/lib/airbrake.rb +150 -0
  40. data/lib/airbrake/backtrace.rb +100 -0
  41. data/lib/airbrake/capistrano.rb +21 -0
  42. data/lib/airbrake/configuration.rb +247 -0
  43. data/lib/airbrake/notice.rb +348 -0
  44. data/lib/airbrake/rack.rb +42 -0
  45. data/lib/airbrake/rails.rb +41 -0
  46. data/lib/airbrake/rails/action_controller_catcher.rb +30 -0
  47. data/lib/airbrake/rails/controller_methods.rb +68 -0
  48. data/lib/airbrake/rails/error_lookup.rb +33 -0
  49. data/lib/airbrake/rails/javascript_notifier.rb +42 -0
  50. data/lib/airbrake/rails3_tasks.rb +82 -0
  51. data/lib/airbrake/railtie.rb +33 -0
  52. data/lib/airbrake/rake_handler.rb +65 -0
  53. data/lib/airbrake/sender.rb +83 -0
  54. data/lib/airbrake/shared_tasks.rb +30 -0
  55. data/lib/airbrake/tasks.rb +83 -0
  56. data/lib/airbrake/user_informer.rb +25 -0
  57. data/lib/airbrake/version.rb +3 -0
  58. data/lib/airbrake_tasks.rb +50 -0
  59. data/lib/rails/generators/airbrake/airbrake_generator.rb +96 -0
  60. data/lib/templates/javascript_notifier.erb +13 -0
  61. data/lib/templates/rescue.erb +91 -0
  62. data/rails/init.rb +1 -0
  63. data/script/integration_test.rb +38 -0
  64. data/test/airbrake_2_2.xsd +78 -0
  65. data/test/airbrake_tasks_test.rb +163 -0
  66. data/test/backtrace_test.rb +163 -0
  67. data/test/catcher_test.rb +333 -0
  68. data/test/configuration_test.rb +216 -0
  69. data/test/helper.rb +251 -0
  70. data/test/javascript_notifier_test.rb +52 -0
  71. data/test/logger_test.rb +85 -0
  72. data/test/notice_test.rb +459 -0
  73. data/test/notifier_test.rb +235 -0
  74. data/test/rack_test.rb +58 -0
  75. data/test/rails_initializer_test.rb +36 -0
  76. data/test/recursion_test.rb +10 -0
  77. data/test/sender_test.rb +193 -0
  78. data/test/user_informer_test.rb +29 -0
  79. metadata +365 -0
@@ -0,0 +1,93 @@
1
+ Hoptoad
2
+ ===========
3
+ Send your application errors to our hosted service and reclaim your inbox.
4
+
5
+ 1. Installing the Heroku add-on
6
+ ----------------------------
7
+ To use Hoptoad on Heroku, install the Hoptoad add-on:
8
+
9
+ $ heroku addons:add hoptoad:basic # This adds the the basic plan.
10
+ # If you'd like another plan, specify that instead.
11
+
12
+ 2. Including the Hoptoad notifier in your application
13
+ --------------------------------------------------
14
+ After adding the Hoptoad add-on, you will need to install and configure the Hoptoad notifier.
15
+
16
+ Your application connects to Hoptoad with an API key. On Heroku, this is automatically provided to your
17
+ application in `ENV['HOPTOAD_API_KEY']`, so installation should be a snap!
18
+
19
+ ### Rails 3.x
20
+
21
+ Add the hoptoad_notifier and heroku gems to your Gemfile. In Gemfile:
22
+
23
+ gem 'hoptoad_notifier'
24
+ gem 'heroku'
25
+
26
+ Then from your project's RAILS_ROOT, run:
27
+
28
+ $ bundle install
29
+ $ script/rails generate hoptoad --heroku
30
+
31
+ ### Rails 2.x
32
+
33
+ Install the heroku gem if you haven't already:
34
+
35
+ gem install heroku
36
+
37
+ Add the hoptoad_notifier gem to your app. In config/environment.rb:
38
+
39
+ config.gem 'hoptoad_notifier'
40
+
41
+ Then from your project's RAILS_ROOT, run:
42
+
43
+ $ rake gems:install
44
+ $ rake gems:unpack GEM=hoptoad_notifier
45
+ $ script/generate hoptoad --heroku
46
+
47
+ As always, if you choose not to vendor the hoptoad_notifier gem, make sure
48
+ every server you deploy to has the gem installed or your application won't start.
49
+
50
+ ### Rack applications
51
+
52
+ In order to use hoptoad_notifier in a non-Rails rack app, just load the hoptoad_notifier, configure your API key, and use the HoptoadNotifier::Rack middleware:
53
+
54
+ require 'rubygems'
55
+ require 'rack'
56
+ require 'hoptoad_notifier'
57
+
58
+ HoptoadNotifier.configure do |config|
59
+ config.api_key = `ENV['HOPTOAD_API_KEY']`
60
+ end
61
+
62
+ app = Rack::Builder.app do
63
+ use HoptoadNotifier::Rack
64
+ run lambda { |env| raise "Rack down" }
65
+ end
66
+
67
+ ### Rails 1.x
68
+
69
+ For Rails 1.x, visit the [Hoptoad notifier's README on GitHub](http://github.com/thoughtbot/hoptoad_notifier),
70
+ and be sure to use `ENV['HOPTOAD_API_KEY']` where your API key is required in configuration code.
71
+
72
+ 3. Configure your notification settings (important!)
73
+ ---------------------------------------------------
74
+
75
+ Once you have included and configured the notifier in your application,
76
+ you will want to configure your notification settings.
77
+
78
+ This is important - without setting your email address, you won't receive notification emails.
79
+
80
+ Hoptoad can deliver exception notifications to your email inbox. To configure these delivery settings:
81
+
82
+ 1. Visit your application's Hoptoad Add-on page, like [ http://api.heroku.com/myapps/my-great-app/addons/hoptoad:basic ](http://api.heroku.com/myapps/my-great-app/addons/hoptoad:basic)
83
+ 2. Click "Go to Hoptoad admin" to configure the Hoptoad Add-on on the Hoptoadapp.com website
84
+ 3. Click the "Profile" button in the header to edit your email address and notification settings.
85
+
86
+ 4. Optionally: Set up deploy notification
87
+ -----------------------------------------
88
+
89
+ If your Hoptoad plan supports deploy notification, set it up for your Heroku application like this:
90
+
91
+ rake hoptoad:heroku:add_deploy_notification
92
+
93
+ This will install a Heroku [HTTP Deploy Hook](http://docs.heroku.com/deploy-hooks) to notify Hoptoad of the deploy.
data/Rakefile ADDED
@@ -0,0 +1,188 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rubygems/package_task'
4
+ begin
5
+ require 'cucumber/rake/task'
6
+ rescue LoadError
7
+ $stderr.puts "Please install cucumber: `gem install cucumber`"
8
+ exit 1
9
+ end
10
+
11
+ desc 'Default: run unit tests.'
12
+ task :default => [:test, "cucumber:rails:all"]
13
+
14
+ desc "Clean out the tmp directory"
15
+ task :clean do
16
+ exec "rm -rf tmp"
17
+ end
18
+
19
+ desc 'Test the airbrake gem.'
20
+ Rake::TestTask.new(:test) do |t|
21
+ t.libs << 'lib'
22
+ t.pattern = 'test/**/*_test.rb'
23
+ t.verbose = true
24
+ end
25
+
26
+ namespace :changeling do
27
+ desc "Bumps the version by a minor or patch version, depending on what was passed in."
28
+ task :bump, :part do |t, args|
29
+ # Thanks, Jeweler!
30
+ if Airbrake::VERSION =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
31
+ major = $1.to_i
32
+ minor = $2.to_i
33
+ patch = $3.to_i
34
+ build = $4
35
+ else
36
+ abort
37
+ end
38
+
39
+ case args[:part]
40
+ when /minor/
41
+ minor += 1
42
+ patch = 0
43
+ when /patch/
44
+ patch += 1
45
+ else
46
+ abort
47
+ end
48
+
49
+ version = [major, minor, patch, build].compact.join('.')
50
+
51
+ File.open(File.join("lib", "airbrake", "notifier", "version.rb"), "w") do |f|
52
+ f.write <<EOF
53
+ module Airbrake
54
+ VERSION = "#{version}".freeze
55
+ end
56
+ EOF
57
+ end
58
+ end
59
+
60
+ desc "Writes out the new CHANGELOG and prepares the release"
61
+ task :change do
62
+ load 'lib/airbrake/version.rb'
63
+ file = "CHANGELOG"
64
+ old = File.read(file)
65
+ version = Airbrake::VERSION
66
+ message = "Bumping to version #{version}"
67
+
68
+ File.open(file, "w") do |f|
69
+ f.write <<EOF
70
+ Version #{version} - #{Time.now}
71
+ ===============================================================================
72
+
73
+ #{`git log $(git tag | tail -1)..HEAD | git shortlog`}
74
+ #{old}
75
+ EOF
76
+ end
77
+
78
+ exec ["#{ENV["EDITOR"]} #{file}",
79
+ "git commit -aqm '#{message}'",
80
+ "git tag -a -m '#{message}' v#{version}",
81
+ "echo '\n\n\033[32mMarked v#{version} /' `git show-ref -s refs/heads/master` 'for release. Run: rake changeling:push\033[0m\n\n'"].join(' && ')
82
+ end
83
+
84
+ desc "Bump by a minor version (1.2.3 => 1.3.0)"
85
+ task :minor do |t|
86
+ Rake::Task['changeling:bump'].invoke(t.name)
87
+ Rake::Task['changeling:change'].invoke
88
+ end
89
+
90
+ desc "Bump by a patch version, (1.2.3 => 1.2.4)"
91
+ task :patch do |t|
92
+ Rake::Task['changeling:bump'].invoke(t.name)
93
+ Rake::Task['changeling:change'].invoke
94
+ end
95
+
96
+ desc "Push the latest version and tags"
97
+ task :push do |t|
98
+ system("git push origin master")
99
+ system("git push origin $(git tag | tail -1)")
100
+ end
101
+ end
102
+
103
+ begin
104
+ require 'yard'
105
+ YARD::Rake::YardocTask.new do |t|
106
+ t.files = ['lib/**/*.rb', 'TESTING.rdoc']
107
+ end
108
+ rescue LoadError
109
+ end
110
+
111
+ GEM_ROOT = File.dirname(__FILE__).freeze
112
+
113
+ desc "Clean files generated by rake tasks"
114
+ task :clobber => [:clobber_rdoc, :clobber_package]
115
+
116
+ LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze
117
+ RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n")
118
+ LOCAL_GEMS = [['sham_rack', nil], ['capistrano', nil], ['sqlite3-ruby', nil], ['sinatra', nil], ['rake', '0.8.7']] +
119
+ RAILS_VERSIONS.collect { |version| ['rails', version] }
120
+
121
+ desc "Vendor test gems: Run this once to prepare your test environment"
122
+ task :vendor_test_gems do
123
+ old_gem_path = ENV['GEM_PATH']
124
+ old_gem_home = ENV['GEM_HOME']
125
+ ENV['GEM_PATH'] = LOCAL_GEM_ROOT
126
+ ENV['GEM_HOME'] = LOCAL_GEM_ROOT
127
+ LOCAL_GEMS.each do |gem_name, version|
128
+ gem_file_pattern = [gem_name, version || '*'].compact.join('-')
129
+ version_option = version ? "-v #{version}" : ''
130
+ pattern = File.join(LOCAL_GEM_ROOT, 'gems', "#{gem_file_pattern}")
131
+ existing = Dir.glob(pattern).first
132
+ unless existing
133
+ command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc --backtrace #{version_option} #{gem_name}"
134
+ puts "Vendoring #{gem_file_pattern}..."
135
+ unless system("#{command} 2>&1")
136
+ puts "Command failed: #{command}"
137
+ exit(1)
138
+ end
139
+ end
140
+ end
141
+ ENV['GEM_PATH'] = old_gem_path
142
+ ENV['GEM_HOME'] = old_gem_home
143
+ end
144
+
145
+ Cucumber::Rake::Task.new(:cucumber) do |t|
146
+ t.fork = true
147
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
148
+ end
149
+
150
+ task :cucumber => [:vendor_test_gems]
151
+
152
+ def run_rails_cucumbr_task(version, additional_cucumber_args)
153
+ puts "Testing Rails #{version}"
154
+ if version.empty?
155
+ raise "No Rails version specified - make sure ENV['RAILS_VERSION'] is set, e.g. with `rake cucumber:rails:all`"
156
+ end
157
+ ENV['RAILS_VERSION'] = version
158
+ system("cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} #{additional_cucumber_args} features/rails.feature features/rails_with_js_notifier.feature")
159
+ end
160
+
161
+ def define_rails_cucumber_tasks(additional_cucumber_args = '')
162
+ namespace :rails do
163
+ RAILS_VERSIONS.each do |version|
164
+ desc "Test integration of the gem with Rails #{version}"
165
+ task version => [:vendor_test_gems] do
166
+ exit 1 unless run_rails_cucumbr_task(version, additional_cucumber_args)
167
+ end
168
+ end
169
+
170
+ desc "Test integration of the gem with all Rails versions"
171
+ task :all do
172
+ results = RAILS_VERSIONS.map do |version|
173
+ run_rails_cucumbr_task(version, additional_cucumber_args)
174
+ end
175
+
176
+ exit 1 unless results.all?
177
+ end
178
+ end
179
+ end
180
+
181
+ namespace :cucumber do
182
+ namespace :wip do
183
+ define_rails_cucumber_tasks('--tags @wip')
184
+ end
185
+
186
+ define_rails_cucumber_tasks
187
+ end
188
+
@@ -0,0 +1,14 @@
1
+ 2.3.2
2
+ 2.3.4
3
+ 2.3.5
4
+ 2.3.8
5
+ 2.3.9
6
+ 2.3.10
7
+ 3.0.0
8
+ 3.0.1
9
+ 3.0.2
10
+ 3.0.3
11
+ 3.0.4
12
+ 3.0.5
13
+ 3.0.6
14
+ 3.0.7
data/TESTING.md ADDED
@@ -0,0 +1,26 @@
1
+ Running the suite
2
+ =================
3
+
4
+ Since the notifier must run on many versions of Rails, running its test suite is slightly different than you may be used to.
5
+
6
+ First execute the following command:
7
+
8
+ rake vendor_test_gems
9
+ # NOT: bundle exec rake vendor_test_gems
10
+
11
+ This command will download the various versions of Rails that the notifier must be tested against.
12
+
13
+ Then, to start the suite, run
14
+
15
+ rake
16
+
17
+ Note: do NOT use 'bundle exec rake'.
18
+
19
+ For Maintainers
20
+ ================
21
+
22
+ When developing the Hoptoad Notifier, be sure to use the integration test against an existing project on staging before pushing to master.
23
+
24
+ ./script/integration_test.rb <test project's api key> <staging server hostname>
25
+
26
+ ./script/integration_test.rb <test project's api key> <staging server hostname> secure
data/airbrake.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "airbrake/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{airbrake}
7
+ s.version = Airbrake::VERSION.dup
8
+ s.summary = %q{Send your application errors to our hosted service and reclaim your inbox.}
9
+
10
+ s.require_paths = ["lib"]
11
+ s.files = `git ls-files`.split("\n")
12
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+
14
+ s.add_runtime_dependency("builder")
15
+ s.add_runtime_dependency("activesupport")
16
+
17
+ s.add_development_dependency("actionpack", "~> 2.3.8")
18
+ s.add_development_dependency("activerecord", "~> 2.3.8")
19
+ s.add_development_dependency("activesupport", "~> 2.3.8")
20
+ s.add_development_dependency("bourne", ">= 1.0")
21
+ s.add_development_dependency("cucumber", "~> 0.10.6")
22
+ s.add_development_dependency("fakeweb", "~> 1.3.0")
23
+ s.add_development_dependency("nokogiri", "~> 1.4.3.1")
24
+ s.add_development_dependency("rspec", "~> 2.6.0")
25
+ s.add_development_dependency("sham_rack", "~> 1.3.0")
26
+ s.add_development_dependency("shoulda", "~> 2.11.3")
27
+
28
+ s.authors = ["thoughtbot, inc"]
29
+ s.email = %q{support@airbrakeapp.com}
30
+ s.homepage = "http://www.airbrakeapp.com"
31
+
32
+ s.platform = Gem::Platform::RUBY
33
+ end
@@ -0,0 +1,23 @@
1
+ Feature: Rescue errors in Rails middleware
2
+
3
+ Background:
4
+ Given I have built and installed the "airbrake" gem
5
+ And I generate a new Rails application
6
+ And I configure the Airbrake shim
7
+ And I configure my application to require the "airbrake" gem
8
+ And I run "script/generate airbrake -k myapikey"
9
+
10
+ Scenario: Rescue an exception in the dispatcher
11
+ When I define a Metal endpoint called "Exploder":
12
+ """
13
+ def self.call(env)
14
+ raise "Explode"
15
+ end
16
+ """
17
+ When I perform a request to "http://example.com:123/metal/index?param=value"
18
+ Then I should receive the following Airbrake notification:
19
+ | error message | RuntimeError: Explode |
20
+ | error class | RuntimeError |
21
+ | parameters | param: value |
22
+ | url | http://example.com:123/metal/index?param=value |
23
+
@@ -0,0 +1,27 @@
1
+ Feature: Use the notifier in a plain Rack app
2
+
3
+ Background:
4
+ Given I have built and installed the "airbrake" gem
5
+
6
+ Scenario: Rescue and exception in a Rack app
7
+ Given the following Rack app:
8
+ """
9
+ require 'rack'
10
+ require 'airbrake'
11
+
12
+ Airbrake.configure do |config|
13
+ config.api_key = 'my_api_key'
14
+ end
15
+
16
+ app = Rack::Builder.app do
17
+ use Airbrake::Rack
18
+ run lambda { |env| raise "Rack down" }
19
+ end
20
+ """
21
+ When I perform a Rack request to "http://example.com:123/test/index?param=value"
22
+ Then I should receive the following Airbrake notification:
23
+ | error message | RuntimeError: Rack down |
24
+ | error class | RuntimeError |
25
+ | parameters | param: value |
26
+ | url | http://example.com:123/test/index?param=value |
27
+
@@ -0,0 +1,254 @@
1
+ Feature: Install the Gem in a Rails application
2
+
3
+ Background:
4
+ Given I have built and installed the "airbrake" gem
5
+
6
+ Scenario: Use the gem without vendoring the gem in a Rails application
7
+ When I generate a new Rails application
8
+ And I configure the Airbrake shim
9
+ And I configure my application to require the "airbrake" gem
10
+ And I run the airbrake generator with "-k myapikey"
11
+ Then the command should have run successfully
12
+ And I should receive a Airbrake notification
13
+ And I should see the Rails version
14
+
15
+ Scenario: vendor the gem and uninstall
16
+ When I generate a new Rails application
17
+ And I configure the Airbrake shim
18
+ And I configure my application to require the "airbrake" gem
19
+ And I unpack the "airbrake" gem
20
+ And I run the airbrake generator with "-k myapikey"
21
+ Then the command should have run successfully
22
+ When I uninstall the "airbrake" gem
23
+ And I install cached gems
24
+ And I run "rake airbrake:test"
25
+ Then I should see "** [Airbrake] Success: Net::HTTPOK"
26
+ And I should receive two Airbrake notifications
27
+
28
+ Scenario: Configure the notifier by hand
29
+ When I generate a new Rails application
30
+ And I configure the Airbrake shim
31
+ And I configure the notifier to use "myapikey" as an API key
32
+ And I configure my application to require the "airbrake" gem
33
+ And I run the airbrake generator with ""
34
+ Then I should receive a Airbrake notification
35
+
36
+ Scenario: Configuration within initializer isn't overridden by Railtie
37
+ When I generate a new Rails application
38
+ And I configure the Airbrake shim
39
+ And I configure my application to require the "airbrake" gem
40
+ And I run the airbrake generator with "-k myapikey"
41
+ Then the command should have run successfully
42
+ When I configure the notifier to use the following configuration lines:
43
+ """
44
+ config.api_key = "myapikey"
45
+ config.project_root = "argle/bargle"
46
+ """
47
+ And I define a response for "TestController#index":
48
+ """
49
+ session[:value] = "test"
50
+ raise RuntimeError, "some message"
51
+ """
52
+ And I route "/test/index" to "test#index"
53
+ And I perform a request to "http://example.com:123/test/index?param=value"
54
+ Then I should receive the following Airbrake notification:
55
+ | project-root | argle/bargle |
56
+
57
+ Scenario: Try to install without an api key
58
+ When I generate a new Rails application
59
+ And I configure my application to require the "airbrake" gem
60
+ And I run the airbrake generator with ""
61
+ Then I should see "Must pass --api-key or --heroku or create config/initializers/airbrake.rb"
62
+
63
+ Scenario: Configure and deploy using only installed gem
64
+ When I generate a new Rails application
65
+ And I run "capify ."
66
+ And I configure the Airbrake shim
67
+ And I configure my application to require the "airbrake" gem
68
+ And I run the airbrake generator with "-k myapikey"
69
+ And I run "cap -T"
70
+ Then I should see "deploy:notify_airbrake"
71
+
72
+ Scenario: Configure and deploy using only vendored gem
73
+ When I generate a new Rails application
74
+ And I run "capify ."
75
+ And I configure the Airbrake shim
76
+ And I configure my application to require the "airbrake" gem
77
+ And I unpack the "airbrake" gem
78
+ And I run the airbrake generator with "-k myapikey"
79
+ And I uninstall the "airbrake" gem
80
+ And I install cached gems
81
+ And I run "cap -T"
82
+ Then I should see "deploy:notify_airbrake"
83
+
84
+ Scenario: Try to install when the airbrake plugin still exists
85
+ When I generate a new Rails application
86
+ And I install the "airbrake" plugin
87
+ And I configure the Airbrake shim
88
+ And I configure the notifier to use "myapikey" as an API key
89
+ And I configure my application to require the "airbrake" gem
90
+ And I run the airbrake generator with ""
91
+ Then I should see "You must first remove the airbrake plugin. Please run: script/plugin remove airbrake"
92
+
93
+ Scenario: Rescue an exception in a controller
94
+ When I generate a new Rails application
95
+ And I configure the Airbrake shim
96
+ And I configure my application to require the "airbrake" gem
97
+ And I run the airbrake generator with "-k myapikey"
98
+ And I define a response for "TestController#index":
99
+ """
100
+ session[:value] = "test"
101
+ raise RuntimeError, "some message"
102
+ """
103
+ And I route "/test/index" to "test#index"
104
+ And I perform a request to "http://example.com:123/test/index?param=value"
105
+ Then I should receive the following Airbrake notification:
106
+ | component | test |
107
+ | action | index |
108
+ | error message | RuntimeError: some message |
109
+ | error class | RuntimeError |
110
+ | session | value: test |
111
+ | parameters | param: value |
112
+ | url | http://example.com:123/test/index?param=value |
113
+
114
+ Scenario: The gem should not be considered a framework gem
115
+ When I generate a new Rails application
116
+ And I configure the Airbrake shim
117
+ And I configure my application to require the "airbrake" gem
118
+ And I run the airbrake generator with "-k myapikey"
119
+ And I run "rake gems"
120
+ Then I should see that "airbrake" is not considered a framework gem
121
+
122
+ Scenario: The app uses Vlad instead of Capistrano
123
+ When I generate a new Rails application
124
+ And I configure the Airbrake shim
125
+ And I configure my application to require the "airbrake" gem
126
+ And I run "touch config/deploy.rb"
127
+ And I run "rm Capfile"
128
+ And I run the airbrake generator with "-k myapikey"
129
+ Then "config/deploy.rb" should not contain "capistrano"
130
+
131
+ Scenario: Support the Heroku addon in the generator
132
+ When I generate a new Rails application
133
+ And I configure the Airbrake shim
134
+ And I configure the Heroku rake shim
135
+ And I configure the Heroku gem shim with "myapikey"
136
+ And I configure my application to require the "airbrake" gem
137
+ And I run the airbrake generator with "--heroku"
138
+ Then the command should have run successfully
139
+ And I should receive a Airbrake notification
140
+ And I should see the Rails version
141
+ And my Airbrake configuration should contain the following line:
142
+ """
143
+ config.api_key = ENV['AIRBRAKE_API_KEY']
144
+ """
145
+
146
+ Scenario: Support the --app option for the Heroku addon in the generator
147
+ When I generate a new Rails application
148
+ And I configure the Airbrake shim
149
+ And I configure the Heroku rake shim
150
+ And I configure the Heroku gem shim with "myapikey" and multiple app support
151
+ And I configure my application to require the "airbrake" gem
152
+ And I run the airbrake generator with "--heroku -a myapp"
153
+ Then the command should have run successfully
154
+ And I should receive a Airbrake notification
155
+ And I should see the Rails version
156
+ And my Airbrake configuration should contain the following line:
157
+ """
158
+ config.api_key = ENV['AIRBRAKE_API_KEY']
159
+ """
160
+
161
+ Scenario: Filtering parameters in a controller
162
+ When I generate a new Rails application
163
+ And I configure the Airbrake shim
164
+ And I configure my application to require the "airbrake" gem
165
+ And I run the airbrake generator with "-k myapikey"
166
+ When I configure the notifier to use the following configuration lines:
167
+ """
168
+ config.api_key = "myapikey"
169
+ config.params_filters << "credit_card_number"
170
+ """
171
+ And I define a response for "TestController#index":
172
+ """
173
+ params[:credit_card_number] = "red23"
174
+ raise RuntimeError, "some message"
175
+ """
176
+ And I route "/test/index" to "test#index"
177
+ And I perform a request to "http://example.com:123/test/index?param=value"
178
+ Then I should receive the following Airbrake notification:
179
+ | component | test |
180
+ | action | index |
181
+ | error message | RuntimeError: some message |
182
+ | error class | RuntimeError |
183
+ | parameters | credit_card_number: [FILTERED] |
184
+ | url | http://example.com:123/test/index?param=value |
185
+
186
+ Scenario: Filtering session in a controller
187
+ When I generate a new Rails application
188
+ And I configure the Airbrake shim
189
+ And I configure my application to require the "airbrake" gem
190
+ And I run the airbrake generator with "-k myapikey"
191
+ When I configure the notifier to use the following configuration lines:
192
+ """
193
+ config.api_key = "myapikey"
194
+ config.params_filters << "secret"
195
+ """
196
+ And I define a response for "TestController#index":
197
+ """
198
+ session["secret"] = "blue42"
199
+ raise RuntimeError, "some message"
200
+ """
201
+ And I route "/test/index" to "test#index"
202
+ And I perform a request to "http://example.com:123/test/index?param=value"
203
+ Then I should receive the following Airbrake notification:
204
+ | component | test |
205
+ | action | index |
206
+ | error message | RuntimeError: some message |
207
+ | error class | RuntimeError |
208
+ | session | secret: [FILTERED] |
209
+ | url | http://example.com:123/test/index?param=value |
210
+
211
+ Scenario: Filtering session and params based on Rails parameter filters
212
+ When I generate a new Rails application
213
+ And I configure the Airbrake shim
214
+ And I configure my application to require the "airbrake" gem
215
+ And I run the airbrake generator with "-k myapikey"
216
+ And I configure the application to filter parameter "secret"
217
+ And I define a response for "TestController#index":
218
+ """
219
+ params["secret"] = "red23"
220
+ session["secret"] = "blue42"
221
+ raise RuntimeError, "some message"
222
+ """
223
+ And I route "/test/index" to "test#index"
224
+ And I perform a request to "http://example.com:123/test/index?param=value"
225
+ Then I should receive the following Airbrake notification:
226
+ | component | test |
227
+ | action | index |
228
+ | error message | RuntimeError: some message |
229
+ | error class | RuntimeError |
230
+ | params | secret: [FILTERED] |
231
+ | session | secret: [FILTERED] |
232
+ | url | http://example.com:123/test/index?param=value |
233
+
234
+ Scenario: Notify airbrake within the controller
235
+ When I generate a new Rails application
236
+ And I configure the Airbrake shim
237
+ And I configure my application to require the "airbrake" gem
238
+ And I run the airbrake generator with "-k myapikey"
239
+ And I define a response for "TestController#index":
240
+ """
241
+ session[:value] = "test"
242
+ notify_airbrake(RuntimeError.new("some message"))
243
+ render :nothing => true
244
+ """
245
+ And I route "/test/index" to "test#index"
246
+ And I perform a request to "http://example.com:123/test/index?param=value"
247
+ Then I should receive the following Airbrake notification:
248
+ | component | test |
249
+ | action | index |
250
+ | error message | RuntimeError: some message |
251
+ | error class | RuntimeError |
252
+ | session | value: test |
253
+ | parameters | param: value |
254
+ | url | http://example.com:123/test/index?param=value |