Skip to content
Browse files

update scenarios

  • Loading branch information...
1 parent d21a2c4 commit 118e9e504e6c4141728ec891fba559719b583844 @shime shime committed Sep 3, 2012
Showing with 36 additions and 12 deletions.
  1. +21 −0 features/rails.feature
  2. +15 −12 features/step_definitions/rails_application_steps.rb
View
21 features/rails.feature
@@ -94,6 +94,7 @@ 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
+ Then I should see "test"
Scenario: The gem should not be considered a framework gem
When I configure the Airbrake shim
@@ -154,6 +155,8 @@ 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
+ Then I should not see "red23"
+ And I should see "FILTERED"
Scenario: Filtering session in a controller
When I configure the Airbrake shim
@@ -171,6 +174,8 @@ 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
+ 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
@@ -185,6 +190,9 @@ 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
+ And I should not see "red23"
+ And I should not see "blue42"
+ And I should see "FILTERED"
Scenario: Notify airbrake within the controller
When I configure the Airbrake shim
@@ -198,6 +206,7 @@ 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
+ And I should see "test"
Scenario: Reporting 404s should be disabled by default
When I configure the Airbrake shim
@@ -249,3 +258,15 @@ Feature: Install the Gem in a Rails application
And I perform a request to "http://example.com:123/test/index"
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 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"
+ Then I should see "Notice details:"
+ And I should see "some message"
View
27 features/step_definitions/rails_application_steps.rb
@@ -9,6 +9,18 @@
pending
end
+Given /^Airbrake server is not responding$/ do
+ bundle_gem("sham_rack")
+ content = <<-CONTENT
+ require 'sham_rack'
+
+ ShamRack.at("api.airbrake.io") {["500", { "Content-type" => "text/xml" }, ["Internal server error"]]}
+
+ CONTENT
+ target = File.join(rails_root, 'config', 'initializers', 'airbrake_shim.rb')
+ File.open(target,"w") { |f| f.write content }
+end
+
When /^I generate a new Rails application$/ do
@terminal.cd(TEMP_DIR)
@@ -95,20 +107,11 @@
end
When /^I configure the Airbrake shim$/ do
- if bundler_manages_gems?
- bundle_gem("sham_rack")
- end
+ bundle_gem("sham_rack")
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
When /^I configure the notifier to use "([^\"]*)" as an API key$/ do |api_key|

0 comments on commit 118e9e5

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