diff --git a/.gitignore b/.gitignore index 8f225ce4a..8ce7ada9c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ tags doc pkg -*emfile.lock .bundle *.rbc diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..211e0e634 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,126 @@ +PATH + remote: . + specs: + airbrake (3.1.6) + builder + girl_friday + +GEM + remote: http://rubygems.org/ + specs: + addressable (2.3.2) + appraisal (0.5.1) + bundler + rake + aruba (0.4.6) + bcat (>= 0.6.1) + childprocess (>= 0.2.0) + cucumber (>= 1.0.2) + rdiscount (>= 1.6.8) + rspec (>= 2.6.0) + bcat (0.6.2) + rack (~> 1.0) + bourne (1.2.0) + mocha (= 0.12.3) + builder (3.1.4) + capistrano (2.13.5) + highline + net-scp (>= 1.0.0) + net-sftp (>= 2.0.0) + net-ssh (>= 2.0.14) + net-ssh-gateway (>= 1.1.0) + capybara (1.1.3) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + selenium-webdriver (~> 2.0) + xpath (~> 0.1.4) + childprocess (0.3.6) + ffi (~> 1.0, >= 1.0.6) + connection_pool (0.9.2) + cucumber (1.2.1) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.0) + json (>= 1.4.6) + cucumber-rails (1.1.1) + capybara (>= 1.1.1) + cucumber (>= 1.1.0) + nokogiri (>= 1.5.0) + diff-lcs (1.1.3) + fakeweb (1.3.0) + ffi (1.1.5) + gherkin (2.11.5) + json (>= 1.4.6) + girl_friday (0.10.0) + connection_pool (~> 0.9.0) + highline (1.6.15) + json (1.7.5) + libwebsocket (0.1.5) + addressable + metaclass (0.0.1) + mime-types (1.19) + mocha (0.12.3) + metaclass (~> 0.0.1) + multi_json (1.3.7) + net-scp (1.0.4) + net-ssh (>= 1.99.1) + net-sftp (2.0.5) + net-ssh (>= 2.0.9) + net-ssh (2.6.1) + net-ssh-gateway (1.1.0) + net-ssh (>= 1.99.1) + nokogiri (1.5.5) + rack (1.4.1) + rack-protection (1.2.0) + rack + rack-test (0.6.2) + rack (>= 1.0) + rake (0.9.2.2) + rdiscount (1.6.8) + rspec (2.6.0) + rspec-core (~> 2.6.0) + rspec-expectations (~> 2.6.0) + rspec-mocks (~> 2.6.0) + rspec-core (2.6.4) + rspec-expectations (2.6.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.6.0) + rspec-rails (1.3.2) + rack (>= 1.0.0) + rspec (>= 1.3.0) + rubyzip (0.9.9) + selenium-webdriver (2.26.0) + childprocess (>= 0.2.5) + libwebsocket (~> 0.1.3) + multi_json (~> 1.0) + rubyzip + sham_rack (1.3.4) + rack + shoulda (2.11.3) + sinatra (1.3.3) + rack (~> 1.3, >= 1.3.6) + rack-protection (~> 1.2) + tilt (~> 1.3, >= 1.3.3) + tilt (1.3.3) + xpath (0.1.4) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + airbrake! + appraisal + aruba + bourne (>= 1.0) + capistrano + cucumber-rails (~> 1.1.1) + fakeweb (~> 1.3.0) + nokogiri (~> 1.5.0) + rspec (~> 2.6.0) + rspec-rails + sham_rack (~> 1.3.0) + shoulda (~> 2.11.3) + sinatra diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..f6f110757 --- /dev/null +++ b/LICENSE @@ -0,0 +1,61 @@ +This product includes jquery written by John Resig +and distributed under an MIT license. +See https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt + + Copyright (c) 2011 John Resig, http://jquery.com/ + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +All other components of this product are +Copyright (c) 2007-2012 Exceptional Software Inc DBA Airbrake.io. All rights reserved. + +Subject to the terms of this notice, Exceptional Software Inc grants you a +nonexclusive, nontransferable license, without the right to +sublicense, to (a) install and execute one copy of these files on any +number of workstations owned or controlled by you and (b) distribute +verbatim copies of these files to third parties. As a condition to the +foregoing grant, you must provide this notice along with each copy you +distribute and you must not remove, alter, or obscure this notice. All +other use, reproduction, modification, distribution, or other +exploitation of these files is strictly prohibited, except as may be set +forth in a separate written license agreement between you and Exceptional +Software Inc. The terms of any such license agreement will control over this +notice. The license stated above will be automatically terminated and +revoked if you exceed its scope or violate any of the terms of this +notice. + +This License does not grant permission to use the trade names, +trademarks, service marks, or product names of Exceptional Software Inc, +DBA Airbrake, Exceptional, Airbrake.io, Exceptional.io except as +required for reasonable and customary use in describing the origin +of this file and reproducing the content of this notice. You may +not mark or brand this file with any trade name, trademarks, +servicemarks, or product names other than the original brand +(if any)provided by Exceptional. + +Unless otherwise expressly agreed by Exceptional Software Inc, in a +separate written license agreement, these files are provided AS IS, +WITHOUT WARRANTY OF ANY KIND, including without any implied warranties +of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT. +As a condition to your use of these files, you are solely responsible for +such use. Exceptional Software Inc will have no liability to you for direct, +indirect, consequential, incidental, special, or punitive damages or +for lost profits or data. diff --git a/MIT-LICENSE b/MIT-LICENSE deleted file mode 100644 index 6b5315b08..000000000 --- a/MIT-LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2007 - 2012, Exceptional DBA Airbrake.io - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/Rakefile b/Rakefile index dd50b0ebc..3a6cf0c10 100644 --- a/Rakefile +++ b/Rakefile @@ -12,9 +12,6 @@ rescue LoadError end require './lib/airbrake/version' -FEATURES = ["sinatra","rack","metal","user_informer","rake"] - -desc 'Default: run unit tests.' task :default do if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/ exec 'rake cucumber' @@ -23,23 +20,10 @@ task :default do end end - -task :appraise do - Rake::Task["bundle:bundler"].execute +task :appraise => ["appraisal:install"] do exec 'rake appraisal cucumber' - Rake::Task['appraisal:install'].execute -end - -namespace :bundle do - task :bundler do - path = `bundle show rake`.split("gems").first - command = "gem install -i #{path} bundler" - system command - end end - - desc "Clean out the tmp directory" task :clean do exec "rm -rf tmp" @@ -144,105 +128,8 @@ desc "Clean files generated by rake tasks" task :clobber => [:clobber_rdoc, :clobber_package] LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze -RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n") -LOCAL_GEMS = - [ - ["rack","1.3.2"], - ] + - RAILS_VERSIONS.collect { |version| ['rails', version] } + - [ - ['sham_rack', nil], - ['capistrano', nil], - ['sqlite3-ruby', nil], - ["therubyracer",nil], - ["sinatra",nil] - ] - - -desc "Vendor test gems: Run this once to prepare your test environment" -task :vendor_test_gems do - old_gem_path = ENV['GEM_PATH'] - old_gem_home = ENV['GEM_HOME'] - ENV['GEM_PATH'] = LOCAL_GEM_ROOT - ENV['GEM_HOME'] = LOCAL_GEM_ROOT - - LOCAL_GEMS.each do |gem_name, version| - gem_file_pattern = [gem_name, version || '*'].compact.join('-') - version_option = version ? "-v #{version}" : '' - pattern = File.join(LOCAL_GEM_ROOT, 'gems', "#{gem_file_pattern}") - existing = Dir.glob(pattern).first - if existing - puts "\nskipping #{gem_name} since it's already vendored," + - "remove it from the tmp directory first." - next - end - - command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc --backtrace #{version_option} #{gem_name}" - puts "Vendoring #{gem_file_pattern}..." - unless system("#{command} 2>&1") - puts "Command failed: #{command}" - exit(1) - end - end - - ENV['GEM_PATH'] = old_gem_path - ENV['GEM_HOME'] = old_gem_home -end Cucumber::Rake::Task.new(:cucumber) do |t| t.fork = true -end - - - - -def run_rails_cucumber_task(version, additional_cucumber_args) - puts "Testing Rails #{version}" - if version.empty? - raise "No Rails version specified - make sure ENV['RAILS_VERSION'] is set, e.g. with `rake cucumber:rails:all`" - end - ENV['RAILS_VERSION'] = version - cmd = "cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} #{additional_cucumber_args} features/rails.feature features/rails_with_js_notifier.feature" - puts "Running command: #{cmd}" - system(cmd) -end - -def define_rails_cucumber_tasks(additional_cucumber_args = '') - namespace :rails do - RAILS_VERSIONS.each do |version| - desc "Test integration of the gem with Rails #{version}" - task version => [:vendor_test_gems] do - exit 1 unless run_rails_cucumber_task(version, additional_cucumber_args) - end - end - - desc "Test integration of the gem with all Rails versions" - task :all do - results = RAILS_VERSIONS.map do |version| - run_rails_cucumber_task(version, additional_cucumber_args) - end - - exit 1 unless results.all? - end - end -end - -namespace :cucumber do - namespace :wip do - define_rails_cucumber_tasks('--tags @wip') - end - - define_rails_cucumber_tasks - - rule /#{"(" + FEATURES.join("|") + ")"}/ do |t| - framework = t.name - desc "Test integration of the gem with #{framework}" - task framework.to_sym do - puts "Testing #{framework.split(":").last}..." - cmd = "cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features/#{framework.split(":").last}.feature" - puts "Running command: #{cmd}" - system(cmd) - end - end - + t.cucumber_opts = "--tags ~@wip --format progress" end diff --git a/airbrake.gemspec b/airbrake.gemspec index 419b1ab7e..511652871 100644 --- a/airbrake.gemspec +++ b/airbrake.gemspec @@ -8,7 +8,7 @@ Gem::Specification.new do |s| s.summary = %q{Send your application errors to our hosted service and reclaim your inbox.} s.require_paths = ["lib"] - s.executables << "airbrake" + s.executables << "airbrake" s.files = Dir["{generators/**/*,lib/**/*,rails/**/*,resources/*,script/*}"] + %w(airbrake.gemspec CHANGELOG Gemfile Guardfile INSTALL MIT-LICENSE Rakefile README_FOR_HEROKU_ADDON.md README.md TESTING.md SUPPORTED_RAILS_VERSIONS install.rb) s.test_files = Dir.glob("{test,spec,features}/**/*") @@ -16,7 +16,6 @@ Gem::Specification.new do |s| s.add_runtime_dependency("builder") s.add_runtime_dependency("girl_friday") - s.add_development_dependency("bundler") s.add_development_dependency("bourne", ">= 1.0") s.add_development_dependency("cucumber-rails","~> 1.1.1") s.add_development_dependency("fakeweb", "~> 1.3.0") @@ -24,11 +23,11 @@ Gem::Specification.new do |s| s.add_development_dependency("rspec", "~> 2.6.0") s.add_development_dependency("sham_rack", "~> 1.3.0") s.add_development_dependency("shoulda", "~> 2.11.3") - s.add_development_dependency("capistrano", "~> 2.8.0") + s.add_development_dependency("capistrano") s.add_development_dependency("aruba") s.add_development_dependency("appraisal") - s.add_development_dependency("simplecov") s.add_development_dependency("rspec-rails") + s.add_development_dependency("sinatra") s.authors = ["Airbrake"] s.email = %q{support@airbrake.io} diff --git a/features/metal.feature b/features/metal.feature index 09f724951..01fee6b0d 100644 --- a/features/metal.feature +++ b/features/metal.feature @@ -1,15 +1,25 @@ -@no-clobber Feature: Rescue errors in Rails middleware Background: - Given I successfully run `bundle exec rails new rails_root --without-bundler` + Given I successfully run `rails new rails_root -O --without-gemfile` And I cd to "rails_root" - And I append "gem 'airbrake', :path => '../../'" to Gemfile - And I successfully run `bundle install` + And I configure the notifier to use the following configuration lines: + """ + config.logger = Logger.new STDOUT + """ And I configure the Airbrake shim - And I define a Metal endpoint called "Exploder": + And I append to "app/metal/exploder.rb" with: + """ + class Exploder + def call(env) + raise "Explode!" + end + end + """ + And I remove the file "config/routes.rb" + And I append to "config/routes.rb" with: """ - def self.call(env) - raise "Explode" + RailsRoot::Application.routes.draw do + mount Exploder.new => "/" end """ diff --git a/features/rack.feature b/features/rack.feature index 6e435f466..aed170744 100644 --- a/features/rack.feature +++ b/features/rack.feature @@ -1,57 +1,60 @@ Feature: Use the notifier in a plain Rack app - - Scenario: Rescue and exception in a Rack app - Given the following Rack app: - """ - require 'logger' - require 'rack' - require 'airbrake' - - Airbrake.configure do |config| - config.api_key = 'my_api_key' - config.logger = Logger.new STDOUT - end - - app = Rack::Builder.app do - use Airbrake::Rack - run lambda { |env| raise "Rack down" } - end - """ - When I perform a Rack request to "http://example.com:123/test/index?param=value" - Then I should receive a Airbrake notification - - Scenario: Ignore user agents - Given the following Rack app: - """ - require 'logger' - require 'rack' - require 'airbrake' - - Airbrake.configure do |config| - config.api_key = 'my_api_key' - config.ignore_user_agent << /ignore/ - config.logger = Logger.new STDOUT - end - - class Mock - class AppendUserAgent - def initialize(app) - @app = app - end - - def call(env) - env["HTTP_USER_AGENT"] = "ignore" - @app.call(env) - end - end - end - - app = Rack::Builder.app do - use Airbrake::Rack - use Mock::AppendUserAgent - run lambda { |env| raise "Rack down" } - end - """ - When I perform a Rack request to "http://example.com:123/test/index?param=value" - Then I should not receive a Airbrake notification - + + Scenario: Rescue and exception in a Rack app + + Given the following Rack app: + """ + require 'logger' + require 'rack' + require 'airbrake' + + Airbrake.configure do |config| + config.api_key = 'my_api_key' + config.logger = Logger.new STDOUT + end + + app = Rack::Builder.app do + use Airbrake::Rack + run lambda { |env| raise "Rack down" } + end + + """ + When I perform a Rack request to "http://example.com:123/test/index?param=value" + Then I should receive a Airbrake notification + + Scenario: Ignore user agents + + Given the following Rack app: + """ + require 'logger' + require 'rack' + require 'airbrake' + + Airbrake.configure do |config| + config.api_key = 'my_api_key' + config.ignore_user_agent << /ignore/ + config.logger = Logger.new STDOUT + end + + class Mock + class AppendUserAgent + def initialize(app) + @app = app + end + + def call(env) + env["HTTP_USER_AGENT"] = "ignore" + @app.call(env) + end + end + end + + app = Rack::Builder.app do + use Airbrake::Rack + use Mock::AppendUserAgent + run lambda { |env| raise "Rack down" } + end + + """ + When I perform a Rack request to "http://example.com:123/test/index?param=value" + Then I should not receive a Airbrake notification diff --git a/features/rails.feature b/features/rails.feature index 9313cb36d..4e2201362 100644 --- a/features/rails.feature +++ b/features/rails.feature @@ -1,35 +1,24 @@ Feature: Install the Gem in a Rails application Background: - Given I successfully run `bundle exec rails new rails_root` + Given I successfully run `rails new rails_root -O --skip-gemfile` And I cd to "rails_root" - And I configure the application to use Airbrake Scenario: Use the gem without vendoring the gem in a Rails application When I configure the Airbrake shim - And I run the airbrake generator with "-k myapikey" + And I run `rails generate airbrake -k myapikey` Then I should receive a Airbrake notification And I should see the Rails version - Scenario: vendor the gem and uninstall - When I configure the Airbrake shim - And I unpack the "airbrake" gem - And I run the airbrake generator with "-k myapikey" - And I uninstall the "airbrake" gem - And I install cached gems - And I run `rake airbrake:test` - Then the output should match /\[Airbrake\] Response from Airbrake:/ - # this should be matched for times, not once - Scenario: Configure the notifier by hand When I configure the Airbrake shim And I configure the notifier to use "myapikey" as an API key - And I run the airbrake generator with "" + And I run `rails generate airbrake` Then I should receive a Airbrake notification Scenario: Configuration within initializer isn't overridden by Railtie When I configure the Airbrake shim - And I run the airbrake generator with "-k myapikey" + And I run `rails generate airbrake -k myapikey` And I configure the notifier to use the following configuration lines: """ config.api_key = "myapikey" @@ -45,25 +34,13 @@ Feature: Install the Gem in a Rails application Then I should receive a Airbrake notification Scenario: Try to install without an api key - When I run the airbrake generator with "" + And I run `rails generate airbrake` Then I should see "Must pass --api-key or --heroku or create config/initializers/airbrake.rb" Scenario: Configure and deploy using only installed gem When I run `capify .` And I configure the Airbrake shim - And I run the airbrake generator with "-k myapikey" - And I configure my application to require the "capistrano" gem if necessary - And I run `cap -T` - Then I should see "airbrake:deploy" - - Scenario: Configure and deploy using only vendored gem - When I run `capify .` - And I configure the Airbrake shim - And I unpack the "airbrake" gem - And I run the airbrake generator with "-k myapikey" - And I uninstall the "airbrake" gem - And I install cached gems - And I configure my application to require the "capistrano" gem if necessary + And I run `rails generate airbrake -k myapikey` And I run `cap -T` Then I should see "airbrake:deploy" @@ -71,12 +48,12 @@ Feature: Install the Gem in a Rails application When I install the "airbrake" plugin And I configure the Airbrake shim And I configure the notifier to use "myapikey" as an API key - And I run the airbrake generator with "" + And I run `rails generate airbrake` Then I should see "You must first remove the airbrake plugin. Please run: script/plugin remove airbrake" Scenario: Rescue an exception in a controller When I configure the Airbrake shim - And I run the airbrake generator with "-k myapikey" + And I run `rails generate airbrake -k myapikey` And I define a response for "TestController#index": """ session[:value] = "test" @@ -89,7 +66,7 @@ Feature: Install the Gem in a Rails application Scenario: The gem should not be considered a framework gem When I configure the Airbrake shim - And I run the airbrake generator with "-k myapikey" + And I run `rails generate airbrake -k myapikey` And I run `rake gems` Then I should see that "airbrake" is not considered a framework gem @@ -97,14 +74,15 @@ Feature: Install the Gem in a Rails application When I configure the Airbrake shim And I run `touch config/deploy.rb` And I run `rm Capfile` - And I run the airbrake generator with "-k myapikey" + And I run `rails generate airbrake -k myapikey` Then "config/deploy.rb" should not contain "capistrano" + @wip Scenario: Support the Heroku addon in the generator When I configure the Airbrake shim - And I configure the Heroku rake shim - And I configure the Heroku gem shim with "myapikey" - And I run the airbrake generator with "--heroku" + And I run `rails generate airbrake -k myapikey` + And I configure the Heroku shim with "myapikey" + And I successfully run `rails generate airbrake --heroku` Then I should receive a Airbrake notification And I should see the Rails version And my Airbrake configuration should contain the following line: @@ -114,9 +92,8 @@ Feature: Install the Gem in a Rails application Scenario: Support the --app option for the Heroku addon in the generator When I configure the Airbrake shim - And I configure the Heroku rake shim - And I configure the Heroku gem shim with "myapikey" and multiple app support - And I run the airbrake generator with "--heroku -a myapp" + And I configure the Heroku shim with "myapikey" and multiple app support + And I run `rails generate airbrake --heroku -a myapp` Then I should receive a Airbrake notification And I should see the Rails version And my Airbrake configuration should contain the following line: @@ -126,54 +103,43 @@ Feature: Install the Gem in a Rails application Scenario: Filtering parameters in a controller When I configure the Airbrake shim - And I run the airbrake generator with "-k myapikey" + And I run `rails generate airbrake -k myapikey` When I configure the notifier to use the following configuration lines: """ config.api_key = "myapikey" config.params_filters << "credit_card_number" + config.params_filters << "secret" + config.logger = Logger.new STDOUT """ And I define a response for "TestController#index": """ + session["secret"] = "blue42" params[:credit_card_number] = "red23" raise RuntimeError, "some message" """ And I route "/test/index" to "test#index" - And I perform a request to "http://example.com:123/test/index?param=value" + And I perform a request to "http://example.com:123/test/index?param=value" in the "production" environment Then I should receive a Airbrake notification Then I should not see "red23" + Then I should not see "blue42" And I should see "FILTERED" - Scenario: Filtering session in a controller + Scenario: Filtering session and params based on Rails parameter filters When I configure the Airbrake shim - And I run the airbrake generator with "-k myapikey" + And I run `rails generate airbrake -k myapikey` When I configure the notifier to use the following configuration lines: """ - config.api_key = "myapikey" - config.params_filters << "secret" - """ - And I define a response for "TestController#index": - """ - session["secret"] = "blue42" - raise RuntimeError, "some message" + config.logger = Logger.new STDOUT """ - And I route "/test/index" to "test#index" - And I perform a request to "http://example.com:123/test/index?param=value" - Then I should receive a Airbrake notification - Then I should not see "blue42" - And I should see "FILTERED" - - Scenario: Filtering session and params based on Rails parameter filters - When I configure the Airbrake shim - And I run the airbrake generator with "-k myapikey" And I configure the application to filter parameter "secret" And I define a response for "TestController#index": """ - params["secret"] = "red23" + params["secret"] = "red23" session["secret"] = "blue42" raise RuntimeError, "some message" """ And I route "/test/index" to "test#index" - And I perform a request to "http://example.com:123/test/index?param=value" + And I perform a request to "http://example.com:123/test/index" in the "production" environment Then I should receive a Airbrake notification And I should not see "red23" And I should not see "blue42" @@ -181,7 +147,7 @@ Feature: Install the Gem in a Rails application Scenario: Notify airbrake within the controller When I configure the Airbrake shim - And I run the airbrake generator with "-k myapikey" + And I run `rails generate airbrake -k myapikey` And I define a response for "TestController#index": """ session[:value] = "test" @@ -189,38 +155,35 @@ Feature: Install the Gem in a Rails application render :nothing => true """ And I route "/test/index" to "test#index" - And I perform a request to "http://example.com:123/test/index?param=value" + And I perform a request to "http://example.com:123/test/index?param=value" in the "production" environment Then I should receive a Airbrake notification And I should see "test" Scenario: Reporting 404s should be disabled by default When I configure the Airbrake shim - And I run the airbrake generator with "-k myapikey" And I configure the notifier to use the following configuration lines: - """ - config.ignore_only = [] - """ - And I configure usage of Airbrake - And I perform a request to "http://example.com:123/this/route/does/not/exist" + """ + config.api_key = "myapikey" + """ + And I perform a request to "http://example.com:123/this/route/does/not/exist" in the "production" environment Then I should see "The page you were looking for doesn't exist." And I should not receive a Airbrake notification Scenario: Reporting 404s should work when configured properly When I configure the Airbrake shim - And I configure usage of Airbrake + And I run `rails generate airbrake -k myapikey` When I configure the notifier to use the following configuration lines: """ config.ignore_only = [] """ - And I perform a request to "http://example.com:123/this/route/does/not/exist" - Then I should see "404" - And I should see "Not Found" + And I perform a request to "http://example.com:123/this/route/does/not/exist" in the "production" environment + Then I should see "The page you were looking for doesn't exist" And I should receive a Airbrake notification + @wip Scenario: reporting over SSL with utf8 check should work - Given PENDING I fix this one When I configure the Airbrake shim - And I configure usage of Airbrake + And I run `rails generate airbrake -k myapikey` When I configure the notifier to use the following configuration lines: """ config.secure = true @@ -235,29 +198,37 @@ Feature: Install the Gem in a Rails application Scenario: It should also send the user details When I configure the Airbrake shim - And I configure usage of Airbrake + And I configure the notifier to use the following configuration lines: + """ + config.api_key = "myapikey" + config.logger = Logger.new STDOUT + """ And I define a response for "TestController#index": """ raise RuntimeError, "some message" """ And I route "/test/index" to "test#index" And I have set up authentication system in my app that uses "current_user" - And I perform a request to "http://example.com:123/test/index" + And I perform a request to "http://example.com:123/test/index" in the "production" environment Then I should receive a Airbrake notification And the Airbrake notification should contain user details When I have set up authentication system in my app that uses "current_member" - And I perform a request to "http://example.com:123/test/index" + And I perform a request to "http://example.com:123/test/index" in the "production" environment Then I should receive a Airbrake notification And the Airbrake notification should contain user details Scenario: It should log the notice when failure happens When Airbrake server is not responding - And I configure usage of Airbrake + And I configure the notifier to use the following configuration lines: + """ + config.api_key = "myapikey" + config.logger = Logger.new STDOUT + """ And I define a response for "TestController#index": """ raise RuntimeError, "some message" """ And I route "/test/index" to "test#index" - And I perform a request to "http://example.com:123/test/index?param=value" + And I perform a request to "http://example.com:123/test/index?param=value" in the "production" environment Then I should see "Notice details:" And I should see "some message" diff --git a/features/rails_with_js_notifier.feature b/features/rails_with_js_notifier.feature index 04958cd5a..17e1ce041 100644 --- a/features/rails_with_js_notifier.feature +++ b/features/rails_with_js_notifier.feature @@ -1,9 +1,8 @@ Feature: Install the Gem in a Rails application and enable the JavaScript notifier Background: - Given I successfully run `bundle exec rails new rails_root` + Given I successfully run `rails new rails_root -O --skip-gemfile` And I cd to "rails_root" - And I configure the application to use Airbrake And I configure the Airbrake shim Scenario: Include the Javascript notifier when enabled diff --git a/features/rake.feature b/features/rake.feature index f3f713be4..d6eb5cd82 100644 --- a/features/rake.feature +++ b/features/rake.feature @@ -1,6 +1,7 @@ Feature: Use the Gem to catch errors in a Rake application + Background: - Given I have fixed this suite + Given I've prepared the Rakefile Scenario: Catching exceptions in Rake When I run rake with airbrake @@ -22,6 +23,6 @@ Feature: Use the Gem to catch errors in a Rake application When I run rake with airbrake autodetect not from terminal Then Airbrake should catch the exception - Scenario: Sending the correct component name - When I run rake with airbrake - Then Airbrake should send the rake command line as the component name + Scenario: Airbrake should also send the command name + When I run `rake airbrake_autodetect_not_from_terminal` + Then command "airbrake_autodetect_not_from_terminal" should be reported diff --git a/features/sinatra.feature b/features/sinatra.feature index 559b53fd3..87ec5ba76 100644 --- a/features/sinatra.feature +++ b/features/sinatra.feature @@ -5,9 +5,11 @@ Feature: Use the notifier in a Sinatra app """ require 'sinatra/base' require 'airbrake' + require 'logger' Airbrake.configure do |config| - config.api_key = 'my_api_key' + config.api_key = 'my_api_key' + config.logger = Logger.new STDOUT end class FontaneApp < Sinatra::Base @@ -21,12 +23,6 @@ Feature: Use the notifier in a Sinatra app app = FontaneApp """ - And I initialize Gemfile - And I add "sinatra" requirement - And I add "sham_rack" requirement - And I add "airbrake" requirement with ":path => '../'" option - And I reset Bundler environment variable - And I successfully run `bundle install` When I perform a Rack request to "http://example.com:123/test/index?param=value" Then I should receive a Airbrake notification diff --git a/features/step_definitions/metal_steps.rb b/features/step_definitions/metal_steps.rb deleted file mode 100644 index 97a214283..000000000 --- a/features/step_definitions/metal_steps.rb +++ /dev/null @@ -1,30 +0,0 @@ -When /^I define a Metal endpoint called "([^\"]*)":$/ do |class_name, definition| - FileUtils.mkdir_p(File.join(rails_root, 'app', 'metal')) - step %{I run `mkdir -p app/metal`} - step %{I cd to "app/metal"} - file_name = "#{class_name.underscore}.rb" - contents = <<-CONTENTS - class #{class_name} - #{definition} - end - CONTENTS - append_to(file_name,contents) - if rails3? - step %{the metal endpoint "#{class_name}" is mounted in the Rails 3 routes.rb} if rails3? - else - puts "this is not rails 3!" - end -end - -When /^the metal endpoint "([^\"]*)" is mounted in the Rails 3 routes.rb$/ do |class_name| - routesrb = File.join(rails_root, "config", "routes.rb") - routes = IO.readlines(routesrb) - rack_route = "match '/metal(/*other)' => #{class_name}" - routes = routes[0..-2] + [rack_route, routes[-1]] - File.open(routesrb, "w") do |f| - f.puts "require Rails.root + 'app/metal/#{class_name.underscore}'" - routes.each do |route_line| - f.puts route_line - end - end -end diff --git a/features/step_definitions/rails_application_steps.rb b/features/step_definitions/rails_application_steps.rb index e64904041..dc26314d2 100644 --- a/features/step_definitions/rails_application_steps.rb +++ b/features/step_definitions/rails_application_steps.rb @@ -2,22 +2,10 @@ require 'active_support/core_ext/string/inflections' - -#Given /^I have built and installed the "([^\"]*)" gem$/ do |gem_name| - #@terminal.build_and_install_gem(File.join(PROJECT_ROOT, "#{gem_name}.gemspec")) -#end - -Given /^PENDING/ do - pending -end - Given /^Airbrake server is not responding$/ do - bundle_gem("sham_rack") content = <<-CONTENT require 'sham_rack' - Airbrake.configuration.logger = Logger.new STDOUT - ShamRack.at("api.airbrake.io") {["500", { "Content-type" => "text/xml" }, ["Internal server error"]]} CONTENT @@ -25,78 +13,13 @@ File.open(target,"w") { |f| f.write content } end -When /^I generate a new Rails application$/ do - - rails3 = version_string =~ /^3/ - - if rails3 - rails_create_command = 'new' - else - rails_create_command = '' - end - - step %{I run `bundle exec rails #{rails_create_command} rails_root --skip-bundle`} - - if rails_root_exists? - step %{I run `echo "Generated a Rails #{version_string} application!`} - else - raise "Unable to generate a Rails application:\n#{@terminal.output}" - end - require_thread - if version_string >= "3.1.0" - step %{I configure my application to require the "therubyracer" gem with version "0.10.1"} - elsif version_string == "2.3.14" - monkeypatch_old_version - end - config_gem_dependencies unless rails3 -end - -When /^I run the airbrake generator with "([^\"]*)"$/ do |generator_args| - if rails3? - step %{I successfully run `./script/rails generate airbrake #{generator_args}`} - else - step %{I successfully run `./script/generate airbrake #{generator_args}`} - end -end +# When /^I configure my application to require the "capistrano" gem if necessary$/ do +# step %{I configure my application to require the "capistrano" gem} +# end -When /^I print the console output$/ do - puts @terminal.output -end - -Given /^I have installed the "([^\"]*)" gem$/ do |gem_name| - @terminal.install_gem(gem_name) -end - -When /^I configure the application to use Airbrake$/ do - append_to_gemfile("gem 'airbrake',:path => '#{PROJECT_ROOT}'") - steps %{ - When I reset Bundler environment variable - And I successfully run `bundle install --local` - } -end - -When /^I configure my application to require the "capistrano" gem if necessary$/ do - step %{I configure my application to require the "capistrano" gem} if version_string >= "3.0.0" -end - -When /^I configure my application to require the "([^\"]*)" gem(?: with version "(.+)")?$/ do |gem_name, version| - if rails_manages_gems? - config_gem(gem_name, version) - elsif bundler_manages_gems? - append_to_gemfile("gem '#{gem_name}'#{version ? ",'#{version}'":""}") - step %{I successfully run `bundle install --local`} - else - File.open(environment_path, 'a') do |file| - file.puts - file.puts("require 'airbrake'") - file.puts("require 'airbrake/rails'") - end - - unless rails_finds_generators_in_gems? - FileUtils.cp_r(File.join(PROJECT_ROOT, 'generators'), File.join(rails_root, 'lib')) - end - end -end +# When /^I configure my application to require the "([^\"]*)" gem(?: with version "(.+)")?$/ do |gem_name, version| +# config_gem(gem_name, version) +# end Then /^I should (?:(not ))?receive a Airbrake notification$/ do |negator| steps %{ @@ -111,19 +34,7 @@ end When /^I configure the Airbrake shim$/ do - if bundler_manages_gems? - append_to_gemfile("gem 'sham_rack'") - end shim_file = File.join(PROJECT_ROOT, 'features', 'support', 'airbrake_shim.rb.template') - if rails_supports_initializers? - target = File.join(rails_root, 'config', 'initializers', 'airbrake_shim.rb') - FileUtils.cp(shim_file, target) - else - File.open(environment_path, 'a') do |file| - file.puts - file.write IO.read(shim_file) - end - end target = File.join(rails_root, 'config', 'initializers', 'airbrake_shim.rb') FileUtils.cp(shim_file, target) end @@ -138,28 +49,13 @@ end When /^I configure the notifier to use the following configuration lines:$/ do |configuration_lines| - if rails_manages_gems? - requires = '' - else - requires = "require 'airbrake'" - end - initializer_code = <<-EOF - #{requires} Airbrake.configure do |config| #{configuration_lines} end EOF - if rails_supports_initializers? - File.open(rails_initializer_file, 'w') { |file| file.write(initializer_code) } - else - File.open(environment_path, 'a') do |file| - file.puts - file.puts initializer_code - end - end - + File.open(rails_initializer_file, 'w') { |file| file.write(initializer_code) } end def rails_initializer_file @@ -174,37 +70,6 @@ def rails_non_initializer_airbrake_config_file step %{the output should #{negator}contain "#{expected_text}"} end -When /^I uninstall the "([^\"]*)" gem$/ do |gem_name| - @terminal.uninstall_gem(gem_name) -end - -When /^I unpack the "([^\"]*)" gem$/ do |gem_name| - if bundler_manages_gems? - @terminal.cd(rails_root) - @terminal.run("bundle pack") - elsif rails_manages_gems? - @terminal.cd(rails_root) - @terminal.run("rake gems:unpack GEM=#{gem_name}") - else - vendor_dir = File.join(rails_root, 'vendor', 'gems') - FileUtils.mkdir_p(vendor_dir) - @terminal.cd(vendor_dir) - @terminal.run("gem unpack #{gem_name}") - gem_path = - Dir.glob(File.join(rails_root, 'vendor', 'gems', "#{gem_name}-*", 'lib')).first - File.open(environment_path, 'a') do |file| - file.puts - file.puts("$: << #{gem_path.inspect}") - end - end -end - -When /^I install cached gems$/ do - if bundler_manages_gems? - step %{I run `bundle install`} - end -end - When /^I install the "([^\"]*)" plugin$/ do |plugin_name| FileUtils.mkdir_p("#{rails_root}/vendor/plugins/#{plugin_name}") end @@ -231,7 +96,6 @@ def rails_non_initializer_airbrake_config_file When /^I perform a request to "([^\"]*)" in the "([^\"]*)" environment$/ do |uri, environment| perform_request(uri,environment) - #step %{I run `bundle exec ./script/rails runner -e #{environment} request.rb`} step %{I run `bundle exec rails runner -e #{environment} request.rb`} end @@ -242,24 +106,15 @@ def rails_non_initializer_airbrake_config_file end Then /^I should see the Rails version$/ do - step %{I should see "[Rails: #{rails_version}]"} + step %{I should see "Rails: #{ENV["RAILS_VERSION"]}"} end Then /^I should see that "([^\"]*)" is not considered a framework gem$/ do |gem_name| step %{I should not see "[R] #{gem_name}"} end -Then /^the command should have run successfully$/ do - @terminal.status.exitstatus.should == 0 -end - When /^I route "([^\"]*)" to "([^\"]*)"$/ do |path, controller_action_pair| - route = if rails3? - %(match "#{path}", :to => "#{controller_action_pair}") - else - controller, action = controller_action_pair.split('#') - %(map.connect "#{path}", :controller => "#{controller}", :action => "#{action}") - end + route = %(match "#{path}", :to => "#{controller_action_pair}") routes_file = File.join(rails_root, "config", "routes.rb") File.open(routes_file, "r+") do |file| content = file.read @@ -277,12 +132,7 @@ def rails_non_initializer_airbrake_config_file end Then /^my Airbrake configuration should contain the following line:$/ do |line| - configuration_file = if rails_supports_initializers? - rails_initializer_file - else - rails_non_initializer_airbrake_config_file - # environment_path - end + configuration_file = rails_initializer_file configuration = File.read(configuration_file) if ! configuration.include?(line.strip) @@ -290,15 +140,7 @@ def rails_non_initializer_airbrake_config_file end end -When /^I set the environment variable "([^\"]*)" to "([^\"]*)"$/ do |environment_variable, value| - @terminal.environment_variables[environment_variable] = value -end - -When /^I configure the Heroku rake shim$/ do - @terminal.invoke_heroku_rake_tasks_locally = true -end - -When /^I configure the Heroku gem shim with "([^\"]*)"( and multiple app support)?$/ do |api_key, multi_app| +When /^I configure the Heroku shim with "([^\"]*)"( and multiple app support)?$/ do |api_key, multi_app| heroku_script_bin = File.join(TEMP_DIR, "bin") FileUtils.mkdir_p(heroku_script_bin) heroku_script = File.join(heroku_script_bin, "heroku") @@ -343,32 +185,17 @@ def rails_non_initializer_airbrake_config_file end When /^I configure the application to filter parameter "([^\"]*)"$/ do |parameter| - if rails3? - application_filename = File.join(rails_root, 'config', 'application.rb') - application_lines = File.open(application_filename).readlines + application_filename = File.join(rails_root, 'config', 'application.rb') + application_lines = File.open(application_filename).readlines - application_definition_line = application_lines.detect { |line| line =~ /Application/ } - application_definition_line_index = application_lines.index(application_definition_line) + application_definition_line = application_lines.detect { |line| line =~ /Application/ } + application_definition_line_index = application_lines.index(application_definition_line) - application_lines.insert(application_definition_line_index + 1, - " config.filter_parameters += [#{parameter.inspect}]") + application_lines.insert(application_definition_line_index + 1, + " config.filter_parameters += [#{parameter.inspect}]") - File.open(application_filename, "w") do |file| - file.puts application_lines.join("\n") - end - else - controller_filename = application_controller_filename - controller_lines = File.open(controller_filename).readlines - - controller_definition_line = controller_lines.detect { |line| line =~ /ApplicationController/ } - controller_definition_line_index = controller_lines.index(controller_definition_line) - - controller_lines.insert(controller_definition_line_index + 1, - " filter_parameter_logging #{parameter.inspect}") - - File.open(controller_filename, "w") do |file| - file.puts controller_lines.join("\n") - end + File.open(application_filename, "w") do |file| + file.puts application_lines.join("\n") end end @@ -398,13 +225,6 @@ def rails_non_initializer_airbrake_config_file step %{the output should not contain "script[type='text/javascript'][src$='/javascripts/notifier.js']"} end - -When /^I configure usage of Airbrake$/ do - step %{I configure my application to require the "airbrake" gem} - step %{I run the airbrake generator with "-k myapikey"} -end - - When /^I have set up authentication system in my app that uses "([^\"]*)"$/ do |current_user| application_controller = File.join(rails_root, 'app', 'controllers', "application_controller.rb") definition = @@ -423,9 +243,9 @@ def #{current_user} end Then /^the Airbrake notification should contain user details$/ do - Then %{I should see "Bender"} - And %{I should see "bender@beer.com"} - And %{I should see "1"} - And %{I should see "b3nd0r"} + step %{I should see "Bender"} + step %{I should see "bender@beer.com"} + step %{I should see "1"} + step %{I should see "b3nd0r"} end diff --git a/features/step_definitions/rake_steps.rb b/features/step_definitions/rake_steps.rb index a4655f184..75748aaca 100644 --- a/features/step_definitions/rake_steps.rb +++ b/features/step_definitions/rake_steps.rb @@ -1,17 +1,22 @@ +Given /I've prepared the Rakefile/ do + rakefile = File.join(PROJECT_ROOT, 'features', 'support', 'rake', 'Rakefile') + target = File.join(TEMP_DIR, 'Rakefile') + FileUtils.cp(rakefile, target) +end + When /I run rake with (.+)/ do |command| - @rake_command = "rake #{command.gsub(' ','_')}" - @rake_result = `cd features/support/rake && GEM_HOME=#{BUILT_GEM_ROOT} #{@rake_command} 2>&1` + command = "rake #{command.gsub(' ','_')}" + step %{I run `#{command}`} +end + +Then "Airbrake should not catch the exception" do + step %{I should not see "[airbrake]"} end -Then /Airbrake should (|not) ?catch the exception/ do |condition| - if condition=='not' - @rake_result.should_not =~ /^airbrake/ - else - @rake_result.should =~ /^airbrake/ - end +Then "Airbrake should catch the exception" do + step %{I should see "[airbrake]"} end -Then /Airbrake should send the rake command line as the component name/ do - component = @rake_result.match(/^airbrake (.*)$/)[1] - component.should == @rake_command +Then /^command "(.*?)" should be reported$/ do |command_name| + step %{the output should contain "[airbrake] rake #{command_name}"} end diff --git a/features/support/airbrake_shim.rb.template b/features/support/airbrake_shim.rb.template index 09d1cb524..61838e731 100644 --- a/features/support/airbrake_shim.rb.template +++ b/features/support/airbrake_shim.rb.template @@ -1,7 +1,5 @@ require 'sham_rack' -Airbrake.configuration.logger = Logger.new STDOUT if defined?(Airbrake) - ShamRack.at("api.airbrake.io") do |env| response = <<-end_xml diff --git a/features/support/aruba.rb b/features/support/aruba.rb index a5d820829..23705f6b6 100644 --- a/features/support/aruba.rb +++ b/features/support/aruba.rb @@ -1,5 +1,5 @@ Before do - @aruba_timeout_seconds = 60 + @aruba_timeout_seconds = 30 @aruba_io_wait_seconds = 5 @dirs = ["tmp"] end diff --git a/features/support/env.rb b/features/support/env.rb index a04c96b6f..e49bfebce 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -6,22 +6,12 @@ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze TEMP_DIR = File.join(PROJECT_ROOT, 'tmp').freeze LOCAL_RAILS_ROOT = File.join(TEMP_DIR, 'rails_root').freeze -BUILT_GEM_ROOT = File.join(TEMP_DIR, 'built_gems').freeze -LOCAL_GEM_ROOT = File.join(TEMP_DIR, 'local_gems').freeze RACK_FILE = File.join(TEMP_DIR, 'rack_app.rb').freeze -RACK_GEM_FILE = File.join(TEMP_DIR, "Gemfile").freeze Before do - FileUtils.rm_rf(TEMP_DIR) - FileUtils.mkdir_p(TEMP_DIR) - #FileUtils.rm_rf(BUILT_GEM_ROOT) FileUtils.rm_rf(LOCAL_RAILS_ROOT) - #FileUtils.rm_f(RACK_FILE) - #FileUtils.mkdir_p(BUILT_GEM_ROOT) end - - When /^I reset Bundler environment variable$/ do BUNDLE_ENV_VARS.each do |key| ENV[key] = nil @@ -31,3 +21,4 @@ def prepend_path(path) ENV['PATH'] = path + ":" + ENV['PATH'] end + diff --git a/features/support/file_helpers.rb b/features/support/file_helpers.rb deleted file mode 100644 index c86c96da6..000000000 --- a/features/support/file_helpers.rb +++ /dev/null @@ -1,24 +0,0 @@ -module FileHelpers - def append_to(path, contents) - in_current_dir do - File.open(path, "a") do |file| - file.puts - file.puts contents - end - end - end - - def append_to_gemfile(contents) - append_to('Gemfile', contents) - end - - def comment_out_gem_in_gemfile(gemname) - in_current_dir do - gemfile = File.read("Gemfile") - gemfile.sub!(/^(\s*)(gem\s*['"]#{gemname})/, "\\1# \\2") - File.open("Gemfile", 'w'){ |file| file.write(gemfile) } - end - end -end - -World(FileHelpers) diff --git a/features/support/rails.rb b/features/support/rails.rb index a57a2399b..86c092e05 100644 --- a/features/support/rails.rb +++ b/features/support/rails.rb @@ -12,7 +12,6 @@ ORIGINAL_BUNDLE_VARS.each_pair do |key, value| ENV[key] = value end - Cucumber.wants_to_quit = true if s.failed? end @@ -124,7 +123,6 @@ def require_thread end def perform_request(uri, environment = 'production') - if rails3? request_script = <<-SCRIPT require File.expand_path('../config/environment', __FILE__) @@ -142,64 +140,8 @@ def perform_request(uri, environment = 'production') end SCRIPT File.open(File.join(rails_root, 'request.rb'), 'w') { |file| file.write(request_script) } - elsif rails_uses_rack? - request_script = <<-SCRIPT - require File.expand_path('../config/environment', __FILE__) - - env = Rack::MockRequest.env_for(#{uri.inspect}) - app = Rack::Lint.new(ActionController::Dispatcher.new) - - status, headers, body = app.call(env) - - response = "" - if body.respond_to?(:to_str) - response << body - else - body.each { |part| response << part } - end - - puts response - SCRIPT - File.open(File.join(rails_root, 'request.rb'), 'w') { |file| file.write(request_script) } - else - uri = URI.parse(uri) - request_script = <<-SCRIPT - require 'cgi' - class CGIWrapper < CGI - def initialize(*args) - @env_table = {} - @stdinput = $stdin - super(*args) - end - attr_reader :env_table - end - $stdin = StringIO.new("") - cgi = CGIWrapper.new - cgi.env_table.update({ - 'HTTPS' => 'off', - 'REQUEST_METHOD' => "GET", - 'HTTP_HOST' => #{[uri.host, uri.port].join(':').inspect}, - 'SERVER_PORT' => #{uri.port.inspect}, - 'REQUEST_URI' => #{uri.request_uri.inspect}, - 'PATH_INFO' => #{uri.path.inspect}, - 'QUERY_STRING' => #{uri.query.inspect} - }) - require 'dispatcher' unless defined?(ActionController::Dispatcher) - Dispatcher.dispatch(cgi) - SCRIPT - File.open(File.join(rails_root, 'request.rb'), 'w') { |file| file.write(request_script) } - end end - def monkeypatch_old_version - monkeypatchin= <<-MONKEYPATCHIN - - MissingSourceFile::REGEXPS << [/^cannot load such file -- (.+)$/i, 1] - - MONKEYPATCHIN - - File.open(File.join(rails_root,"config","initializers", 'monkeypatchin.rb'), 'w') { |file| file.write(monkeypatchin) } - end end World(RailsHelpers) diff --git a/features/support/rake/Rakefile b/features/support/rake/Rakefile index a28352f8e..07b230085 100644 --- a/features/support/rake/Rakefile +++ b/features/support/rake/Rakefile @@ -45,8 +45,7 @@ end module Airbrake def self.notify_or_ignore(*args) - # TODO if you need to check more params, you'll have to use json.dump or something - $stderr.puts "airbrake #{args[1][:component]}" + $stderr.puts "[airbrake] #{args[1][:component]}" end end diff --git a/features/support/terminal.rb b/features/support/terminal.rb deleted file mode 100644 index 042e88596..000000000 --- a/features/support/terminal.rb +++ /dev/null @@ -1,107 +0,0 @@ -require 'fileutils' - -Before do - @terminal = Terminal.new -end - -After do |story| - if story.failed? - # puts @terminal.output - end -end - -class Terminal - attr_reader :output, :status - attr_accessor :environment_variables, :invoke_heroku_rake_tasks_locally - - def initialize - @cwd = FileUtils.pwd - @output = "" - @status = 0 - @logger = Logger.new(File.join(TEMP_DIR, 'terminal.log')) - - @invoke_heroku_rake_tasks_locally = false - - @environment_variables = { - "GEM_HOME" => LOCAL_GEM_ROOT, - "GEM_PATH" => "#{LOCAL_GEM_ROOT}:#{BUILT_GEM_ROOT}", - "PATH" => "#{gem_bin_path}:#{ENV['PATH']}" - } - end - - def cd(directory) - @cwd = directory - end - - def run(command) - command = optionally_invoke_heroku_rake_tasks_locally(command) - - output << "#{command}\n" - FileUtils.cd(@cwd) do - # The ; forces ruby to shell out so the env settings work right - cmdline = "#{environment_settings} #{command} 2>&1 ; " - logger.debug(cmdline) - result = `#{cmdline}` - logger.debug(result) - output << result - end - @status = $? - end - - def optionally_invoke_heroku_rake_tasks_locally(command) - if invoke_heroku_rake_tasks_locally - command.sub(/^heroku /, '') - else - command - end - end - - def echo(string) - logger.debug(string) - end - - def flush! - @output = "" - end - - def build_and_install_gem(gemspec) - pkg_dir = File.join(TEMP_DIR, 'pkg') - FileUtils.mkdir_p(pkg_dir) - output = `gem build #{gemspec} 2>&1` - gem_file = Dir.glob("*.gem").first - unless gem_file - raise "Gem didn't build:\n#{output}" - end - target = File.join(pkg_dir, gem_file) - FileUtils.mv(gem_file, target) - install_gem_to(LOCAL_GEM_ROOT, target) - end - - def install_gem(gem) - install_gem_to(LOCAL_GEM_ROOT, gem) - end - - def uninstall_gem(gem) - `gem uninstall -i #{LOCAL_GEM_ROOT} #{gem}` - end - - def prepend_path(path) - @environment_variables['PATH'] = path + ":" + @environment_variables['PATH'] - end - - private - - def install_gem_to(root, gem) - `gem install -i #{root} --no-ri --no-rdoc #{gem}` - end - - def environment_settings - @environment_variables.map { |key, value| "#{key}=#{value}" }.join(' ') - end - - def gem_bin_path - File.join(LOCAL_GEM_ROOT, "bin") - end - - attr_reader :logger -end diff --git a/features/user_informer.feature b/features/user_informer.feature index 13c4f73c6..6940be23b 100644 --- a/features/user_informer.feature +++ b/features/user_informer.feature @@ -1,13 +1,12 @@ Feature: Inform the user of the airbrake notice that was just created Background: - Given I successfully run `bundle exec rails new rails_root` + Given I successfully run `rails new rails_root -O --skip-gemfile` And I cd to "rails_root" - And I configure the application to use Airbrake And I configure the Airbrake shim Scenario: Rescue an exception in a controller - When I run the airbrake generator with "-k myapikey" + When I run `rails generate airbrake -k myapikey` And I define a response for "TestController#index": """ raise RuntimeError, "some message" @@ -25,7 +24,7 @@ Feature: Inform the user of the airbrake notice that was just created """ config.user_information = 'Error #{{ error_id }}' """ - And I run the airbrake generator with "-k myapikey" + And I run `rails generate airbrake -k myapikey` And I define a response for "TestController#index": """ raise RuntimeError, "some message" @@ -38,12 +37,12 @@ Feature: Inform the user of the airbrake notice that was just created And I perform a request to "http://example.com:123/test/index?param=value" in the "production" environment Then I should see "Error #b6817316-9c45-ed26-45eb-780dbb86aadb" - Scenario: Don't inform them user + Scenario: Don't inform the user When I configure the notifier to use the following configuration lines: """ config.user_information = false """ - And I run the airbrake generator with "-k myapikey" + And I run `rails generate airbrake -k myapikey` And I define a response for "TestController#index": """ raise RuntimeError, "some message" diff --git a/gemfiles/3.0.gemfile.lock b/gemfiles/3.0.gemfile.lock new file mode 100644 index 000000000..0a108b4a2 --- /dev/null +++ b/gemfiles/3.0.gemfile.lock @@ -0,0 +1,187 @@ +PATH + remote: /home/hrvoje/code/airbrake-ci + specs: + airbrake (3.1.6) + builder + girl_friday + +GEM + remote: http://rubygems.org/ + specs: + abstract (1.0.0) + actionmailer (3.0.15) + actionpack (= 3.0.15) + mail (~> 2.2.19) + actionpack (3.0.15) + activemodel (= 3.0.15) + activesupport (= 3.0.15) + builder (~> 2.1.2) + erubis (~> 2.6.6) + i18n (~> 0.5.0) + rack (~> 1.2.5) + rack-mount (~> 0.6.14) + rack-test (~> 0.5.7) + tzinfo (~> 0.3.23) + activemodel (3.0.15) + activesupport (= 3.0.15) + builder (~> 2.1.2) + i18n (~> 0.5.0) + activerecord (3.0.15) + activemodel (= 3.0.15) + activesupport (= 3.0.15) + arel (~> 2.0.10) + tzinfo (~> 0.3.23) + activeresource (3.0.15) + activemodel (= 3.0.15) + activesupport (= 3.0.15) + activesupport (3.0.15) + addressable (2.2.8) + appraisal (0.4.1) + bundler + rake + arel (2.0.10) + aruba (0.4.6) + bcat (>= 0.6.1) + childprocess (>= 0.2.0) + cucumber (>= 1.0.2) + rdiscount (>= 1.6.8) + rspec (>= 2.6.0) + bcat (0.6.2) + rack (~> 1.0) + bourne (1.1.2) + mocha (= 0.10.5) + builder (2.1.2) + capistrano (2.8.0) + highline + net-scp (>= 1.0.0) + net-sftp (>= 2.0.0) + net-ssh (>= 2.0.14) + net-ssh-gateway (>= 1.1.0) + capybara (1.1.2) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + selenium-webdriver (~> 2.0) + xpath (~> 0.1.4) + childprocess (0.3.2) + ffi (~> 1.0.6) + connection_pool (0.9.2) + cucumber (1.2.1) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.0) + json (>= 1.4.6) + cucumber-rails (1.1.1) + capybara (>= 1.1.1) + cucumber (>= 1.1.0) + nokogiri (>= 1.5.0) + diff-lcs (1.1.3) + erubis (2.6.6) + abstract (>= 1.0.0) + fakeweb (1.3.0) + ffi (1.0.11) + gherkin (2.11.0) + json (>= 1.4.6) + girl_friday (0.10.0) + connection_pool (~> 0.9.0) + highline (1.6.12) + i18n (0.5.0) + json (1.7.3) + libwebsocket (0.1.3) + addressable + mail (2.2.19) + activesupport (>= 2.3.6) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + metaclass (0.0.1) + mime-types (1.18) + mocha (0.10.5) + metaclass (~> 0.0.1) + multi_json (1.3.6) + net-scp (1.0.4) + net-ssh (>= 1.99.1) + net-sftp (2.0.5) + net-ssh (>= 2.0.9) + net-ssh (2.5.2) + net-ssh-gateway (1.1.0) + net-ssh (>= 1.99.1) + nokogiri (1.5.4) + polyglot (0.3.3) + rack (1.2.5) + rack-mount (0.6.14) + rack (>= 1.0.0) + rack-test (0.5.7) + rack (>= 1.0) + rails (3.0.15) + actionmailer (= 3.0.15) + actionpack (= 3.0.15) + activerecord (= 3.0.15) + activeresource (= 3.0.15) + activesupport (= 3.0.15) + bundler (~> 1.0) + railties (= 3.0.15) + railties (3.0.15) + actionpack (= 3.0.15) + activesupport (= 3.0.15) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.4) + rake (0.9.2.2) + rdiscount (1.6.8) + rdoc (3.12) + json (~> 1.4) + rspec (2.6.0) + rspec-core (~> 2.6.0) + rspec-expectations (~> 2.6.0) + rspec-mocks (~> 2.6.0) + rspec-core (2.6.4) + rspec-expectations (2.6.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.6.0) + rspec-rails (2.6.1) + actionpack (~> 3.0) + activesupport (~> 3.0) + railties (~> 3.0) + rspec (~> 2.6.0) + rubyzip (0.9.8) + selenium-webdriver (2.22.2) + childprocess (>= 0.2.5) + ffi (~> 1.0) + libwebsocket (~> 0.1.3) + multi_json (~> 1.0) + rubyzip + sham_rack (1.3.4) + rack + shoulda (2.11.3) + sinatra (1.2.8) + rack (~> 1.1) + tilt (>= 1.2.2, < 2.0) + thor (0.14.6) + tilt (1.3.3) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.33) + xpath (0.1.4) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + airbrake! + appraisal + aruba + bourne (>= 1.0) + capistrano + cucumber-rails (~> 1.1.1) + fakeweb (~> 1.3.0) + nokogiri (~> 1.5.0) + rails (~> 3.0.15) + rspec (~> 2.6.0) + rspec-rails + sham_rack (~> 1.3.0) + shoulda (~> 2.11.3) + sinatra diff --git a/gemfiles/3.1.gemfile.lock b/gemfiles/3.1.gemfile.lock new file mode 100644 index 000000000..07e968800 --- /dev/null +++ b/gemfiles/3.1.gemfile.lock @@ -0,0 +1,199 @@ +PATH + remote: /home/hrvoje/code/airbrake-ci + specs: + airbrake (3.1.6) + builder + girl_friday + +GEM + remote: http://rubygems.org/ + specs: + actionmailer (3.1.6) + actionpack (= 3.1.6) + mail (~> 2.3.3) + actionpack (3.1.6) + activemodel (= 3.1.6) + activesupport (= 3.1.6) + builder (~> 3.0.0) + erubis (~> 2.7.0) + i18n (~> 0.6) + rack (~> 1.3.6) + rack-cache (~> 1.2) + rack-mount (~> 0.8.2) + rack-test (~> 0.6.1) + sprockets (~> 2.0.4) + activemodel (3.1.6) + activesupport (= 3.1.6) + builder (~> 3.0.0) + i18n (~> 0.6) + activerecord (3.1.6) + activemodel (= 3.1.6) + activesupport (= 3.1.6) + arel (~> 2.2.3) + tzinfo (~> 0.3.29) + activeresource (3.1.6) + activemodel (= 3.1.6) + activesupport (= 3.1.6) + activesupport (3.1.6) + multi_json (>= 1.0, < 1.3) + addressable (2.2.8) + appraisal (0.4.1) + bundler + rake + arel (2.2.3) + aruba (0.4.6) + bcat (>= 0.6.1) + childprocess (>= 0.2.0) + cucumber (>= 1.0.2) + rdiscount (>= 1.6.8) + rspec (>= 2.6.0) + bcat (0.6.2) + rack (~> 1.0) + bourne (1.1.2) + mocha (= 0.10.5) + builder (3.0.0) + capistrano (2.8.0) + highline + net-scp (>= 1.0.0) + net-sftp (>= 2.0.0) + net-ssh (>= 2.0.14) + net-ssh-gateway (>= 1.1.0) + capybara (1.1.2) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + selenium-webdriver (~> 2.0) + xpath (~> 0.1.4) + childprocess (0.3.2) + ffi (~> 1.0.6) + connection_pool (0.9.2) + cucumber (1.2.1) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.0) + json (>= 1.4.6) + cucumber-rails (1.1.1) + capybara (>= 1.1.1) + cucumber (>= 1.1.0) + nokogiri (>= 1.5.0) + diff-lcs (1.1.3) + erubis (2.7.0) + fakeweb (1.3.0) + ffi (1.0.11) + gherkin (2.11.0) + json (>= 1.4.6) + girl_friday (0.10.0) + connection_pool (~> 0.9.0) + highline (1.6.12) + hike (1.2.1) + i18n (0.6.0) + json (1.7.3) + libwebsocket (0.1.3) + addressable + mail (2.3.3) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + metaclass (0.0.1) + mime-types (1.18) + mocha (0.10.5) + metaclass (~> 0.0.1) + multi_json (1.2.0) + net-scp (1.0.4) + net-ssh (>= 1.99.1) + net-sftp (2.0.5) + net-ssh (>= 2.0.9) + net-ssh (2.5.2) + net-ssh-gateway (1.1.0) + net-ssh (>= 1.99.1) + nokogiri (1.5.4) + polyglot (0.3.3) + rack (1.3.6) + rack-cache (1.2) + rack (>= 0.4) + rack-mount (0.8.3) + rack (>= 1.0.0) + rack-protection (1.2.0) + rack + rack-ssl (1.3.2) + rack + rack-test (0.6.1) + rack (>= 1.0) + rails (3.1.6) + actionmailer (= 3.1.6) + actionpack (= 3.1.6) + activerecord (= 3.1.6) + activeresource (= 3.1.6) + activesupport (= 3.1.6) + bundler (~> 1.0) + railties (= 3.1.6) + railties (3.1.6) + actionpack (= 3.1.6) + activesupport (= 3.1.6) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.6) + rake (0.9.2.2) + rdiscount (1.6.8) + rdoc (3.12) + json (~> 1.4) + rspec (2.6.0) + rspec-core (~> 2.6.0) + rspec-expectations (~> 2.6.0) + rspec-mocks (~> 2.6.0) + rspec-core (2.6.4) + rspec-expectations (2.6.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.6.0) + rspec-rails (2.6.1) + actionpack (~> 3.0) + activesupport (~> 3.0) + railties (~> 3.0) + rspec (~> 2.6.0) + rubyzip (0.9.8) + selenium-webdriver (2.22.2) + childprocess (>= 0.2.5) + ffi (~> 1.0) + libwebsocket (~> 0.1.3) + multi_json (~> 1.0) + rubyzip + sham_rack (1.3.4) + rack + shoulda (2.11.3) + sinatra (1.3.3) + rack (~> 1.3, >= 1.3.6) + rack-protection (~> 1.2) + tilt (~> 1.3, >= 1.3.3) + sprockets (2.0.4) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + thor (0.14.6) + tilt (1.3.3) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.33) + xpath (0.1.4) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + airbrake! + appraisal + aruba + bourne (>= 1.0) + capistrano + cucumber-rails (~> 1.1.1) + fakeweb (~> 1.3.0) + nokogiri (~> 1.5.0) + rails (~> 3.1.6) + rspec (~> 2.6.0) + rspec-rails + sham_rack (~> 1.3.0) + shoulda (~> 2.11.3) + sinatra diff --git a/gemfiles/3.2.gemfile.lock b/gemfiles/3.2.gemfile.lock new file mode 100644 index 000000000..f88a6fe60 --- /dev/null +++ b/gemfiles/3.2.gemfile.lock @@ -0,0 +1,197 @@ +PATH + remote: /home/hrvoje/code/airbrake-ci + specs: + airbrake (3.1.6) + builder + girl_friday + +GEM + remote: http://rubygems.org/ + specs: + actionmailer (3.2.6) + actionpack (= 3.2.6) + mail (~> 2.4.4) + actionpack (3.2.6) + activemodel (= 3.2.6) + activesupport (= 3.2.6) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.1) + rack (~> 1.4.0) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.1.3) + activemodel (3.2.6) + activesupport (= 3.2.6) + builder (~> 3.0.0) + activerecord (3.2.6) + activemodel (= 3.2.6) + activesupport (= 3.2.6) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.6) + activemodel (= 3.2.6) + activesupport (= 3.2.6) + activesupport (3.2.6) + i18n (~> 0.6) + multi_json (~> 1.0) + addressable (2.2.8) + appraisal (0.4.1) + bundler + rake + arel (3.0.2) + aruba (0.4.6) + bcat (>= 0.6.1) + childprocess (>= 0.2.0) + cucumber (>= 1.0.2) + rdiscount (>= 1.6.8) + rspec (>= 2.6.0) + bcat (0.6.2) + rack (~> 1.0) + bourne (1.1.2) + mocha (= 0.10.5) + builder (3.0.0) + capistrano (2.8.0) + highline + net-scp (>= 1.0.0) + net-sftp (>= 2.0.0) + net-ssh (>= 2.0.14) + net-ssh-gateway (>= 1.1.0) + capybara (1.1.2) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + selenium-webdriver (~> 2.0) + xpath (~> 0.1.4) + childprocess (0.3.2) + ffi (~> 1.0.6) + connection_pool (0.9.2) + cucumber (1.2.1) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.0) + json (>= 1.4.6) + cucumber-rails (1.1.1) + capybara (>= 1.1.1) + cucumber (>= 1.1.0) + nokogiri (>= 1.5.0) + diff-lcs (1.1.3) + erubis (2.7.0) + fakeweb (1.3.0) + ffi (1.0.11) + gherkin (2.11.0) + json (>= 1.4.6) + girl_friday (0.10.0) + connection_pool (~> 0.9.0) + highline (1.6.12) + hike (1.2.1) + i18n (0.6.0) + journey (1.0.3) + json (1.7.3) + libwebsocket (0.1.3) + addressable + mail (2.4.4) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + metaclass (0.0.1) + mime-types (1.18) + mocha (0.10.5) + metaclass (~> 0.0.1) + multi_json (1.3.6) + net-scp (1.0.4) + net-ssh (>= 1.99.1) + net-sftp (2.0.5) + net-ssh (>= 2.0.9) + net-ssh (2.5.2) + net-ssh-gateway (1.1.0) + net-ssh (>= 1.99.1) + nokogiri (1.5.4) + polyglot (0.3.3) + rack (1.4.1) + rack-cache (1.2) + rack (>= 0.4) + rack-protection (1.2.0) + rack + rack-ssl (1.3.2) + rack + rack-test (0.6.1) + rack (>= 1.0) + rails (3.2.6) + actionmailer (= 3.2.6) + actionpack (= 3.2.6) + activerecord (= 3.2.6) + activeresource (= 3.2.6) + activesupport (= 3.2.6) + bundler (~> 1.0) + railties (= 3.2.6) + railties (3.2.6) + actionpack (= 3.2.6) + activesupport (= 3.2.6) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (>= 0.14.6, < 2.0) + rake (0.9.2.2) + rdiscount (1.6.8) + rdoc (3.12) + json (~> 1.4) + rspec (2.6.0) + rspec-core (~> 2.6.0) + rspec-expectations (~> 2.6.0) + rspec-mocks (~> 2.6.0) + rspec-core (2.6.4) + rspec-expectations (2.6.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.6.0) + rspec-rails (2.6.1) + actionpack (~> 3.0) + activesupport (~> 3.0) + railties (~> 3.0) + rspec (~> 2.6.0) + rubyzip (0.9.8) + selenium-webdriver (2.22.2) + childprocess (>= 0.2.5) + ffi (~> 1.0) + libwebsocket (~> 0.1.3) + multi_json (~> 1.0) + rubyzip + sham_rack (1.3.4) + rack + shoulda (2.11.3) + sinatra (1.3.3) + rack (~> 1.3, >= 1.3.6) + rack-protection (~> 1.2) + tilt (~> 1.3, >= 1.3.3) + sprockets (2.1.3) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + thor (0.15.2) + tilt (1.3.3) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.33) + xpath (0.1.4) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + airbrake! + appraisal + aruba + bourne (>= 1.0) + capistrano + cucumber-rails (~> 1.1.1) + fakeweb (~> 1.3.0) + nokogiri (~> 1.5.0) + rails (~> 3.2.6) + rspec (~> 2.6.0) + rspec-rails + sham_rack (~> 1.3.0) + shoulda (~> 2.11.3) + sinatra diff --git a/test/helper.rb b/test/helper.rb index 8cf7920f8..4116e01c0 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,5 +1,3 @@ -require 'simplecov' -SimpleCov.start require 'test/unit' require 'rubygems'