Skip to content
Browse files

Fixed deploy hooks not working when the gem isn't installed

  • Loading branch information...
1 parent f68b254 commit f784dec1db9b3b8eb11ddf7b6d25d9ce82f538b1 @jferris jferris committed Jan 20, 2010
View
13 features/rails.feature
@@ -34,11 +34,22 @@ Feature: Install the Gem in a Rails application
And I run "script/generate hoptoad"
Then I should see "Must pass --api-key or create config/initializers/hoptoad.rb"
- Scenario: Configure and deploy
+ Scenario: Configure and deploy using only installed gem
When I generate a new Rails application
And I run "capify ."
And I configure the Hoptoad shim
And I configure my application to require the "hoptoad_notifier" gem
And I run "script/generate hoptoad -k myapikey"
And I run "cap -T"
Then I should see "deploy:notify_hoptoad"
+
+ Scenario: Configure and deploy using only vendored gem
+ When I generate a new Rails application
+ And I run "capify ."
+ And I configure the Hoptoad shim
+ And I configure my application to require the "hoptoad_notifier" gem
+ And I unpack the "hoptoad_notifier" gem
+ And I run "script/generate hoptoad -k myapikey"
+ And I uninstall the "hoptoad_notifier" gem
+ And I run "cap -T"
+ Then I should see "deploy:notify_hoptoad"
View
4 features/step_definitions/rails_application_steps.rb
@@ -88,7 +88,9 @@
end
Then /^I should see "([^\"]*)"$/ do |expected_text|
- @terminal.output.should include(expected_text)
+ unless @terminal.output.include?(expected_text)
+ raise "Got terminal output:\n#{@terminal.output}\nExpected output:\n#{expected_text}"
+ end
end
When /^I uninstall the "([^\"]*)" gem$/ do |gem_name|
View
6 generators/hoptoad/hoptoad_generator.rb
@@ -15,7 +15,7 @@ def manifest
m.directory 'lib/tasks'
m.file 'hoptoad_notifier_tasks.rake', 'lib/tasks/hoptoad_notifier_tasks.rake'
if File.exists?('config/deploy.rb')
- m.append_to 'config/deploy.rb', "require 'hoptoad_notifier/capistrano'"
+ m.append_to 'config/deploy.rb', capistrano_hook
end
if options[:api_key]
if use_initializer?
@@ -39,4 +39,8 @@ def api_key_configured?
File.exists?('config/initializers/hoptoad.rb') ||
system("grep HoptoadNotifier config/environment.rb")
end
+
+ def capistrano_hook
+ IO.read(source_path('capistrano_hook.rb'))
+ end
end
View
6 generators/hoptoad/templates/capistrano_hook.rb
@@ -0,0 +1,6 @@
+
+Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier|
+ $: << File.join(vendored_notifier, 'lib')
+end
+
+require 'hoptoad_notifier/capistrano'

0 comments on commit f784dec

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