/features/rails.feature

https://github.com/Sutto/airbrake · Gherkin Specification · 254 lines · 236 code · 18 blank · 0 comment · 7 complexity · 09f1a99b81e553171ea8edcb35f038cf MD5 · raw file

  1. Feature: Install the Gem in a Rails application
  2. Background:
  3. Given I have built and installed the "airbrake" gem
  4. Scenario: Use the gem without vendoring the gem in a Rails application
  5. When 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 the airbrake generator with "-k myapikey"
  9. Then the command should have run successfully
  10. And I should receive a Airbrake notification
  11. And I should see the Rails version
  12. Scenario: vendor the gem and uninstall
  13. When I generate a new Rails application
  14. And I configure the Airbrake shim
  15. And I configure my application to require the "airbrake" gem
  16. And I unpack the "airbrake" gem
  17. And I run the airbrake generator with "-k myapikey"
  18. Then the command should have run successfully
  19. When I uninstall the "airbrake" gem
  20. And I install cached gems
  21. And I run "rake airbrake:test"
  22. Then I should see "** [Airbrake] Success: Net::HTTPOK"
  23. And I should receive two Airbrake notifications
  24. Scenario: Configure the notifier by hand
  25. When I generate a new Rails application
  26. And I configure the Airbrake shim
  27. And I configure the notifier to use "myapikey" as an API key
  28. And I configure my application to require the "airbrake" gem
  29. And I run the airbrake generator with ""
  30. Then I should receive a Airbrake notification
  31. Scenario: Configuration within initializer isn't overridden by Railtie
  32. When I generate a new Rails application
  33. And I configure the Airbrake shim
  34. And I configure my application to require the "airbrake" gem
  35. And I run the airbrake generator with "-k myapikey"
  36. Then the command should have run successfully
  37. When I configure the notifier to use the following configuration lines:
  38. """
  39. config.api_key = "myapikey"
  40. config.project_root = "argle/bargle"
  41. """
  42. And I define a response for "TestController#index":
  43. """
  44. session[:value] = "test"
  45. raise RuntimeError, "some message"
  46. """
  47. And I route "/test/index" to "test#index"
  48. And I perform a request to "http://example.com:123/test/index?param=value"
  49. Then I should receive the following Airbrake notification:
  50. | project-root | argle/bargle |
  51. Scenario: Try to install without an api key
  52. When I generate a new Rails application
  53. And I configure my application to require the "airbrake" gem
  54. And I run the airbrake generator with ""
  55. Then I should see "Must pass --api-key or --heroku or create config/initializers/airbrake.rb"
  56. Scenario: Configure and deploy using only installed gem
  57. When I generate a new Rails application
  58. And I run "capify ."
  59. And I configure the Airbrake shim
  60. And I configure my application to require the "airbrake" gem
  61. And I run the airbrake generator with "-k myapikey"
  62. And I run "cap -T"
  63. Then I should see "airbrake:deploy"
  64. Scenario: Configure and deploy using only vendored gem
  65. When I generate a new Rails application
  66. And I run "capify ."
  67. And I configure the Airbrake shim
  68. And I configure my application to require the "airbrake" gem
  69. And I unpack the "airbrake" gem
  70. And I run the airbrake generator with "-k myapikey"
  71. And I uninstall the "airbrake" gem
  72. And I install cached gems
  73. And I run "cap -T"
  74. Then I should see "airbrake:deploy"
  75. Scenario: Try to install when the airbrake plugin still exists
  76. When I generate a new Rails application
  77. And I install the "airbrake" plugin
  78. And I configure the Airbrake shim
  79. And I configure the notifier to use "myapikey" as an API key
  80. And I configure my application to require the "airbrake" gem
  81. And I run the airbrake generator with ""
  82. Then I should see "You must first remove the airbrake plugin. Please run: script/plugin remove airbrake"
  83. Scenario: Rescue an exception in a controller
  84. When I generate a new Rails application
  85. And I configure the Airbrake shim
  86. And I configure my application to require the "airbrake" gem
  87. And I run the airbrake generator with "-k myapikey"
  88. And I define a response for "TestController#index":
  89. """
  90. session[:value] = "test"
  91. raise RuntimeError, "some message"
  92. """
  93. And I route "/test/index" to "test#index"
  94. And I perform a request to "http://example.com:123/test/index?param=value"
  95. Then I should receive the following Airbrake notification:
  96. | component | test |
  97. | action | index |
  98. | error message | RuntimeError: some message |
  99. | error class | RuntimeError |
  100. | session | value: test |
  101. | parameters | param: value |
  102. | url | http://example.com:123/test/index?param=value |
  103. Scenario: The gem should not be considered a framework gem
  104. When I generate a new Rails application
  105. And I configure the Airbrake shim
  106. And I configure my application to require the "airbrake" gem
  107. And I run the airbrake generator with "-k myapikey"
  108. And I run "rake gems"
  109. Then I should see that "airbrake" is not considered a framework gem
  110. Scenario: The app uses Vlad instead of Capistrano
  111. When I generate a new Rails application
  112. And I configure the Airbrake shim
  113. And I configure my application to require the "airbrake" gem
  114. And I run "touch config/deploy.rb"
  115. And I run "rm Capfile"
  116. And I run the airbrake generator with "-k myapikey"
  117. Then "config/deploy.rb" should not contain "capistrano"
  118. Scenario: Support the Heroku addon in the generator
  119. When I generate a new Rails application
  120. And I configure the Airbrake shim
  121. And I configure the Heroku rake shim
  122. And I configure the Heroku gem shim with "myapikey"
  123. And I configure my application to require the "airbrake" gem
  124. And I run the airbrake generator with "--heroku"
  125. Then the command should have run successfully
  126. And I should receive a Airbrake notification
  127. And I should see the Rails version
  128. And my Airbrake configuration should contain the following line:
  129. """
  130. config.api_key = ENV['HOPTOAD_API_KEY']
  131. """
  132. Scenario: Support the --app option for the Heroku addon in the generator
  133. When I generate a new Rails application
  134. And I configure the Airbrake shim
  135. And I configure the Heroku rake shim
  136. And I configure the Heroku gem shim with "myapikey" and multiple app support
  137. And I configure my application to require the "airbrake" gem
  138. And I run the airbrake generator with "--heroku -a myapp"
  139. Then the command should have run successfully
  140. And I should receive a Airbrake notification
  141. And I should see the Rails version
  142. And my Airbrake configuration should contain the following line:
  143. """
  144. config.api_key = ENV['HOPTOAD_API_KEY']
  145. """
  146. Scenario: Filtering parameters in a controller
  147. When I generate a new Rails application
  148. And I configure the Airbrake shim
  149. And I configure my application to require the "airbrake" gem
  150. And I run the airbrake generator with "-k myapikey"
  151. When I configure the notifier to use the following configuration lines:
  152. """
  153. config.api_key = "myapikey"
  154. config.params_filters << "credit_card_number"
  155. """
  156. And I define a response for "TestController#index":
  157. """
  158. params[:credit_card_number] = "red23"
  159. raise RuntimeError, "some message"
  160. """
  161. And I route "/test/index" to "test#index"
  162. And I perform a request to "http://example.com:123/test/index?param=value"
  163. Then I should receive the following Airbrake notification:
  164. | component | test |
  165. | action | index |
  166. | error message | RuntimeError: some message |
  167. | error class | RuntimeError |
  168. | parameters | credit_card_number: [FILTERED] |
  169. | url | http://example.com:123/test/index?param=value |
  170. Scenario: Filtering session in a controller
  171. When I generate a new Rails application
  172. And I configure the Airbrake shim
  173. And I configure my application to require the "airbrake" gem
  174. And I run the airbrake generator with "-k myapikey"
  175. When I configure the notifier to use the following configuration lines:
  176. """
  177. config.api_key = "myapikey"
  178. config.params_filters << "secret"
  179. """
  180. And I define a response for "TestController#index":
  181. """
  182. session["secret"] = "blue42"
  183. raise RuntimeError, "some message"
  184. """
  185. And I route "/test/index" to "test#index"
  186. And I perform a request to "http://example.com:123/test/index?param=value"
  187. Then I should receive the following Airbrake notification:
  188. | component | test |
  189. | action | index |
  190. | error message | RuntimeError: some message |
  191. | error class | RuntimeError |
  192. | session | secret: [FILTERED] |
  193. | url | http://example.com:123/test/index?param=value |
  194. Scenario: Filtering session and params based on Rails parameter filters
  195. When I generate a new Rails application
  196. And I configure the Airbrake shim
  197. And I configure my application to require the "airbrake" gem
  198. And I run the airbrake generator with "-k myapikey"
  199. And I configure the application to filter parameter "secret"
  200. And I define a response for "TestController#index":
  201. """
  202. params["secret"] = "red23"
  203. session["secret"] = "blue42"
  204. raise RuntimeError, "some message"
  205. """
  206. And I route "/test/index" to "test#index"
  207. And I perform a request to "http://example.com:123/test/index?param=value"
  208. Then I should receive the following Airbrake notification:
  209. | component | test |
  210. | action | index |
  211. | error message | RuntimeError: some message |
  212. | error class | RuntimeError |
  213. | params | secret: [FILTERED] |
  214. | session | secret: [FILTERED] |
  215. | url | http://example.com:123/test/index?param=value |
  216. Scenario: Notify airbrake within the controller
  217. When I generate a new Rails application
  218. And I configure the Airbrake shim
  219. And I configure my application to require the "airbrake" gem
  220. And I run the airbrake generator with "-k myapikey"
  221. And I define a response for "TestController#index":
  222. """
  223. session[:value] = "test"
  224. notify_airbrake(RuntimeError.new("some message"))
  225. render :nothing => true
  226. """
  227. And I route "/test/index" to "test#index"
  228. And I perform a request to "http://example.com:123/test/index?param=value"
  229. Then I should receive the following Airbrake notification:
  230. | component | test |
  231. | action | index |
  232. | error message | RuntimeError: some message |
  233. | error class | RuntimeError |
  234. | session | value: test |
  235. | parameters | param: value |
  236. | url | http://example.com:123/test/index?param=value |