Skip to content
Browse files

don't append capistrano details to config.deploy.rb when target app u…

…ses Vlad
  • Loading branch information...
1 parent 48f2179 commit a010408926d25673ed6dbc17e0d5b3c93da4ff8f Dan Lawless committed
Showing with 21 additions and 2 deletions.
  1. +9 −0 features/rails.feature
  2. +10 −0 features/step_definitions/file_steps.rb
  3. +2 −2 generators/hoptoad/hoptoad_generator.rb
View
9 features/rails.feature
@@ -91,3 +91,12 @@ Feature: Install the Gem in a Rails application
And I run "script/generate hoptoad -k myapikey"
And I run "rake gems"
Then I should see that "hoptoad_notifier" 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 Hoptoad shim
+ And I configure my application to require the "hoptoad_notifier" gem
+ And I run "touch config/deploy.rb"
+ And I run "rm Capfile"
+ And I run "script/generate hoptoad -k myapikey"
+ Then "config/deploy.rb" should not contain text of "generators/hoptoad/templates/capistrano_hook.rb"
View
10 features/step_definitions/file_steps.rb
@@ -0,0 +1,10 @@
+Then /^"([^\"]*)" should not contain text of "([^\"]*)"$/ do |target_file, contents_file|
+ notifier_root = File.join(File.dirname(__FILE__), '..', '..')
+ full_path_contents = File.join(notifier_root, contents_file)
+ contents_text = File.open(full_path_contents).read
+
+ full_path_target = File.join(RAILS_ROOT, target_file)
+ target_text = File.open(full_path_target).read
+
+ target_text.should_not include(contents_text)
+end
View
4 generators/hoptoad/hoptoad_generator.rb
@@ -18,7 +18,7 @@ def manifest
record do |m|
m.directory 'lib/tasks'
m.file 'hoptoad_notifier_tasks.rake', 'lib/tasks/hoptoad_notifier_tasks.rake'
- if File.exists?('config/deploy.rb')
+ if ['config/deploy.rb', 'Capfile'].all? { |file| File.exists?(file) }
m.append_to 'config/deploy.rb', capistrano_hook
end
if options[:api_key]
@@ -47,7 +47,7 @@ def api_key_configured?
def capistrano_hook
IO.read(source_path('capistrano_hook.rb'))
end
-
+
def plugin_is_present?
File.exists?('vendor/plugins/hoptoad_notifier')
end

0 comments on commit a010408

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