Skip to content

Commit

Permalink
add a failing scenario for airbrake#92
Browse files Browse the repository at this point in the history
  • Loading branch information
shime committed Jun 6, 2012
1 parent e237fe1 commit 8d89b5c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 49 deletions.
77 changes: 31 additions & 46 deletions features/rails.feature
Expand Up @@ -2,19 +2,18 @@ Feature: Install the Gem in a Rails application

Background:
Given I have built and installed the "airbrake" gem
And I generate a new Rails application

Scenario: Use the gem without vendoring the gem in a Rails application
When I generate a new Rails application
And I configure the Airbrake shim
When I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I run the airbrake generator with "-k myapikey"
Then the command should have run successfully
And I should receive a Airbrake notification
And I should see the Rails version

Scenario: vendor the gem and uninstall
When I generate a new Rails application
And I configure the Airbrake shim
When I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I unpack the "airbrake" gem
And I run the airbrake generator with "-k myapikey"
Expand All @@ -26,18 +25,15 @@ Feature: Install the Gem in a Rails application
And I should receive two Airbrake notifications

Scenario: Configure the notifier by hand
When I generate a new Rails application
And I configure the Airbrake shim
When I configure the Airbrake shim
And I configure the notifier to use "myapikey" as an API key
And I configure my application to require the "airbrake" gem
And I run the airbrake generator with ""
Then I should receive a Airbrake notification

Scenario: Configuration within initializer isn't overridden by Railtie
When I generate a new Rails application
And I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I run the airbrake generator with "-k myapikey"
When I configure the Airbrake shim
And I configure usage of Airbrake
Then the command should have run successfully
When I configure the notifier to use the following configuration lines:
"""
Expand All @@ -54,14 +50,12 @@ 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 generate a new Rails application
And I configure my application to require the "airbrake" gem
When I configure my application to require the "airbrake" gem
And I run the airbrake generator with ""
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 generate a new Rails application
And I run "capify ."
When I run "capify ."
And I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I run the airbrake generator with "-k myapikey"
Expand All @@ -70,8 +64,7 @@ Feature: Install the Gem in a Rails application
Then I should see "airbrake:deploy"

Scenario: Configure and deploy using only vendored gem
When I generate a new Rails application
And I run "capify ."
When I run "capify ."
And I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I unpack the "airbrake" gem
Expand All @@ -83,19 +76,16 @@ Feature: Install the Gem in a Rails application
Then I should see "airbrake:deploy"

Scenario: Try to install when the airbrake plugin still exists
When I generate a new Rails application
And I install the "airbrake" plugin
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 configure my application to require the "airbrake" gem
And I run the airbrake generator with ""
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 generate a new Rails application
And I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I run the airbrake generator with "-k myapikey"
When I configure the Airbrake shim
And I configure usage of Airbrake
And I define a response for "TestController#index":
"""
session[:value] = "test"
Expand All @@ -106,25 +96,22 @@ Feature: Install the Gem in a Rails application
Then I should receive a Airbrake notification

Scenario: The gem should not be considered a framework gem
When I generate a new Rails application
And I configure the Airbrake shim
When I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I run the airbrake generator with "-k myapikey"
And I run "rake gems"
Then I should see that "airbrake" is not considered a framework gem

Scenario: The app uses Vlad instead of Capistrano
When I generate a new Rails application
And I configure the Airbrake shim
When I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I run "touch config/deploy.rb"
And I run "rm Capfile"
And I run the airbrake generator with "-k myapikey"
Then "config/deploy.rb" should not contain "capistrano"

Scenario: Support the Heroku addon in the generator
When I generate a new Rails application
And I configure the Airbrake shim
When I configure the Airbrake shim
And I configure the Heroku rake shim
And I configure the Heroku gem shim with "myapikey"
And I configure my application to require the "airbrake" gem
Expand All @@ -138,8 +125,7 @@ Feature: Install the Gem in a Rails application
"""

Scenario: Support the --app option for the Heroku addon in the generator
When I generate a new Rails application
And I configure the Airbrake shim
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 configure my application to require the "airbrake" gem
Expand All @@ -153,10 +139,8 @@ Feature: Install the Gem in a Rails application
"""

Scenario: Filtering parameters in a controller
When I generate a new Rails application
And I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I run the airbrake generator with "-k myapikey"
When I configure the Airbrake shim
And I configure usage of Airbrake
When I configure the notifier to use the following configuration lines:
"""
config.api_key = "myapikey"
Expand All @@ -172,10 +156,8 @@ Feature: Install the Gem in a Rails application
Then I should receive a Airbrake notification

Scenario: Filtering session in a controller
When I generate a new Rails application
And I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I run the airbrake generator with "-k myapikey"
When I configure the Airbrake shim
And I configure usage of Airbrake
When I configure the notifier to use the following configuration lines:
"""
config.api_key = "myapikey"
Expand All @@ -191,10 +173,8 @@ Feature: Install the Gem in a Rails application
Then I should receive a Airbrake notification

Scenario: Filtering session and params based on Rails parameter filters
When I generate a new Rails application
And I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I run the airbrake generator with "-k myapikey"
When I configure the Airbrake shim
And I configure usage of Airbrake
And I configure the application to filter parameter "secret"
And I define a response for "TestController#index":
"""
Expand All @@ -207,10 +187,8 @@ Feature: Install the Gem in a Rails application
Then I should receive a Airbrake notification

Scenario: Notify airbrake within the controller
When I generate a new Rails application
And I configure the Airbrake shim
And I configure my application to require the "airbrake" gem
And I run the airbrake generator with "-k myapikey"
When I configure the Airbrake shim
And I configure usage of Airbrake
And I define a response for "TestController#index":
"""
session[:value] = "test"
Expand All @@ -220,3 +198,10 @@ Feature: Install the Gem in a Rails application
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

Scenario: Reporting 404s
When I configure the Airbrake shim
And I configure usage of Airbrake
And I perform a request to "http://example.com:123/this/route/does/not/exist"
And I should see "The page you were looking for doesn't exist."
And I should receive a Airbrake notification
14 changes: 11 additions & 3 deletions features/step_definitions/rails_application_steps.rb
@@ -1,6 +1,10 @@
require 'uri'
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

When /^I generate a new Rails application$/ do
@terminal.cd(TEMP_DIR)

Expand Down Expand Up @@ -48,9 +52,6 @@
@terminal.install_gem(gem_name)
end

Given /^I have built and installed the "([^\"]*)" gem$/ do |gem_name|
@terminal.build_and_install_gem(File.join(PROJECT_ROOT, "#{gem_name}.gemspec"))
end

When /^I configure my application to require the "capistrano" gem if necessary$/ do
When %{I configure my application to require the "capistrano" gem} if version_string >= "3.0.0"
Expand Down Expand Up @@ -423,3 +424,10 @@ def rails_non_initializer_airbrake_config_file
response = Nokogiri::HTML.parse('<html>' + @terminal.output.split('<html>').last)
response.at_css("script[type='text/javascript'][src$='/javascripts/notifier.js']").should be_nil
end


When /^I configure usage of Airbrake$/ do
When %{I configure my application to require the "airbrake" gem}
When %{I run the airbrake generator with "-k myapikey"}
@terminal.flush! # flush the results of setting up Airbrake (generates notification)
end
4 changes: 4 additions & 0 deletions features/support/terminal.rb
Expand Up @@ -60,6 +60,10 @@ 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)
Expand Down

0 comments on commit 8d89b5c

Please sign in to comment.