Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added scenarios for missing api key/configuring by hand

  • Loading branch information...
commit 022a1a3f4c856859f6a2910f6dc138cf36c23871 1 parent 7df97d7
Joe Ferris jferris authored
15 features/rails.feature
@@ -10,3 +10,18 @@ Feature: Install the Gem in a Rails application
10 10 And I run "script/generate hoptoad -k myapikey"
11 11 And I run "rake hoptoad:test --trace"
12 12 Then I should receive a Hoptoad notification
  13 +
  14 + Scenario: Configure the notifier by hand
  15 + When I generate a new Rails application
  16 + And I configure the Hoptoad shim
  17 + And I configure the notifier to use "myapikey" as an API key
  18 + And I configure my application to require the "hoptoad_notifier" gem
  19 + And I run "script/generate hoptoad"
  20 + And I run "rake hoptoad:test --trace"
  21 + Then I should receive a Hoptoad notification
  22 +
  23 + Scenario: Try to install without an api key
  24 + When I generate a new Rails application
  25 + And I configure my application to require the "hoptoad_notifier" gem
  26 + And I run "script/generate hoptoad"
  27 + Then I should see "Must pass --api-key or create config/initializers/hoptoad.rb"
15 features/step_definitions/rails_application_steps.rb
@@ -37,3 +37,18 @@
37 37 target = File.join(RAILS_ROOT, 'config', 'initializers', 'hoptoad_shim.rb')
38 38 FileUtils.cp(shim_file, target)
39 39 end
  40 +
  41 +When /^I configure the notifier to use "([^\"]*)" as an API key$/ do |api_key|
  42 + config_file = File.join(RAILS_ROOT, 'config', 'initializers', 'hoptoad.rb')
  43 + File.open(config_file, 'w') do |file|
  44 + file.write(<<-EOF)
  45 + HoptoadNotifier.configure do |config|
  46 + config.api_key = #{api_key.inspect}
  47 + end
  48 + EOF
  49 + end
  50 +end
  51 +
  52 +Then /^I should see "([^\"]*)"$/ do |expected_text|
  53 + @terminal.output.should include(expected_text)
  54 +end

0 comments on commit 022a1a3

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