Skip to content

Commit 20ba767

Browse files
committed
Tests running executable service hooks
1 parent 7e1b73c commit 20ba767

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

features/hook/running-a-deploy-hook.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,27 @@ Feature: Running A Deploy Hook
117117
When I run the <Callback Name> callback
118118
Then the <Callback Name> ruby hook for my service is executed
119119

120+
Examples:
121+
| Callback Name |
122+
| before_deploy |
123+
| before_bundle |
124+
| after_bundle |
125+
| before_compile_assets |
126+
| after_compile_assets |
127+
| before_migrate |
128+
| after_migrate |
129+
| before_symlink |
130+
| after_symlink |
131+
| before_restart |
132+
| after_restart |
133+
| after_deploy |
134+
135+
Scenario Outline: Running a callback with an executable service hook
136+
Given I have a service named selective
137+
And my service has a <Callback Name> executable hook
138+
When I run the <Callback Name> callback
139+
Then the <Callback Name> executable hook for my service is executed
140+
120141
Examples:
121142
| Callback Name |
122143
| before_deploy |

features/hook/step_definitions/running-a-deploy-hook-steps.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,27 @@ def service_name
119119
expect(output_text).to include("Executing #{hook}")
120120
end
121121

122+
Given %r{^my service has a (.+) executable hook$} do |callback_name|
123+
setup_service_path(service_name)
124+
125+
hook = service_path(service_name).join(callback_name)
126+
f = File.open(hook.to_s, 'w')
127+
f.write("#!/bin/bash\n\necho #{hook.to_s}")
128+
f.close
129+
130+
hook.chmod(0755)
131+
end
132+
133+
Then %r{^the (.+) executable hook for my service is executed$} do |callback_name|
134+
expect(ExecutedCommands.service_hook_executed?(service_name, callback_name)).
135+
to eql(true)
136+
end
137+
138+
Then %r{^the (.+) executable hook for my service is not executed$} do |callback_name|
139+
expect(ExecutedCommands.service_hook_executed?(service_name, callback_name)).
140+
to eql(false)
141+
end
142+
122143
Then %{I see the output} do
123144
puts "OUTPUT START\n\n#{output_text}\n\nOUTPUT END"
124145
end

features/support/runner.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ def self.deploy_hook_executed?(callback_name)
2323
}.length > 0
2424
end
2525

26+
def self.service_hook_executed?(service_name, callback_name)
27+
executed.
28+
select {|x|
29+
x.match(
30+
%r{engineyard-serverside-execute-service-hook #{service_name}/#{callback_name}}
31+
)
32+
}.length > 0
33+
end
34+
2635
end
2736

2837
module Runner

0 commit comments

Comments
 (0)