whisk_deploy 0.6.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +292 -0
- data/MIT-LICENSE +20 -0
- data/README.integration_specs +24 -0
- data/README.markdown +832 -0
- data/Rakefile +105 -0
- data/VERSION +1 -0
- data/WHY.txt +45 -0
- data/bin/wd +61 -0
- data/bin/wd_role +42 -0
- data/examples/deploy-configs.yml +13 -0
- data/examples/deploy-local.yml +4 -0
- data/examples/deploy-multiple-remotes.yml +26 -0
- data/examples/deploy-staging.yml +8 -0
- data/examples/deploy.rake +11 -0
- data/examples/deploy.yml +16 -0
- data/init.rb +1 -0
- data/install.rb +5 -0
- data/lib/whiskey_disk.rb +327 -0
- data/lib/whiskey_disk/config.rb +127 -0
- data/lib/whiskey_disk/config/abstract_filter.rb +19 -0
- data/lib/whiskey_disk/config/filter.rb +48 -0
- data/lib/whiskey_disk/config/filters/add_environment_name_filter.rb +11 -0
- data/lib/whiskey_disk/config/filters/add_project_name_filter.rb +11 -0
- data/lib/whiskey_disk/config/filters/check_for_duplicate_domains_filter.rb +21 -0
- data/lib/whiskey_disk/config/filters/convert_role_strings_to_list_filter.rb +20 -0
- data/lib/whiskey_disk/config/filters/default_config_target_filter.rb +12 -0
- data/lib/whiskey_disk/config/filters/default_domain_filter.rb +12 -0
- data/lib/whiskey_disk/config/filters/drop_empty_domain_roles_filter.rb +32 -0
- data/lib/whiskey_disk/config/filters/environment_scope_filter.rb +20 -0
- data/lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb +29 -0
- data/lib/whiskey_disk/config/filters/localize_domains_filter.rb +24 -0
- data/lib/whiskey_disk/config/filters/modules/scope_helper.rb +11 -0
- data/lib/whiskey_disk/config/filters/normalize_ssh_options_filter.rb +29 -0
- data/lib/whiskey_disk/config/filters/project_scope_filter.rb +34 -0
- data/lib/whiskey_disk/config/filters/select_project_and_environment_filter.rb +12 -0
- data/lib/whiskey_disk/config/filters/stringify_hash_keys_filter.rb +25 -0
- data/lib/whiskey_disk/helpers.rb +50 -0
- data/lib/whiskey_disk/rake.rb +47 -0
- data/scenarios/git_repositories/config.git/HEAD +1 -0
- data/scenarios/git_repositories/config.git/config +5 -0
- data/scenarios/git_repositories/config.git/description +1 -0
- data/scenarios/git_repositories/config.git/git-daemon-export-ok +0 -0
- data/scenarios/git_repositories/config.git/hooks/applypatch-msg.sample +15 -0
- data/scenarios/git_repositories/config.git/hooks/commit-msg.sample +24 -0
- data/scenarios/git_repositories/config.git/hooks/post-commit.sample +8 -0
- data/scenarios/git_repositories/config.git/hooks/post-receive.sample +15 -0
- data/scenarios/git_repositories/config.git/hooks/post-update.sample +8 -0
- data/scenarios/git_repositories/config.git/hooks/pre-applypatch.sample +14 -0
- data/scenarios/git_repositories/config.git/hooks/pre-commit.sample +46 -0
- data/scenarios/git_repositories/config.git/hooks/pre-rebase.sample +169 -0
- data/scenarios/git_repositories/config.git/hooks/prepare-commit-msg.sample +36 -0
- data/scenarios/git_repositories/config.git/hooks/update.sample +128 -0
- data/scenarios/git_repositories/config.git/info/exclude +6 -0
- data/scenarios/git_repositories/config.git/objects/0d/b14dd6ddc54017c0a11960dcda82ed802cde69 +0 -0
- data/scenarios/git_repositories/config.git/objects/0e/e781f5ce80d64db32a74a7aae7b5248dafe112 +3 -0
- data/scenarios/git_repositories/config.git/objects/17/6bf54cf17d1d1c24556dc059c4144a5df230e8 +0 -0
- data/scenarios/git_repositories/config.git/objects/20/e9ff3feaa8ede30f707e5f1b4356e3c02bb7ec +0 -0
- data/scenarios/git_repositories/config.git/objects/45/117b1c775f0de415478dbf08ed9d667ab17d13 +0 -0
- data/scenarios/git_repositories/config.git/objects/51/3954c9aca090e6ce40359f0e9fde30ea78eb8c +0 -0
- data/scenarios/git_repositories/config.git/objects/66/947a7a11a6f5d3d561fe95de284ced3010819a +0 -0
- data/scenarios/git_repositories/config.git/objects/6b/bc79311bfac47d3ed724aa82a4814e0dda4c67 +0 -0
- data/scenarios/git_repositories/config.git/objects/71/eb5df52676e8e6efba471050b46978173af110 +1 -0
- data/scenarios/git_repositories/config.git/objects/84/17d2fe3e8fcc0825249c517b29b0f9ea8b8b31 +2 -0
- data/scenarios/git_repositories/config.git/objects/8b/384fcfcf7c0dee7c3c1d5636bee9e645d9cf38 +0 -0
- data/scenarios/git_repositories/config.git/objects/bb/59da633ba74296b0c2f9ff70784ac155ddb599 +0 -0
- data/scenarios/git_repositories/config.git/objects/cc/b86b26189afbf45d8eb9165812ab86dbdfca63 +0 -0
- data/scenarios/git_repositories/config.git/objects/d1/0bcd51fec41f854001e4d61f99d9e282a695d3 +0 -0
- data/scenarios/git_repositories/config.git/objects/d8/a8b0f5b1fd66844efb141d9544965ea0065f2d +0 -0
- data/scenarios/git_repositories/config.git/objects/e6/b02c66ad632e6b8535c4630cb8fe07732a72fc +0 -0
- data/scenarios/git_repositories/config.git/objects/e8/b8bfeeba735c0a1a873082554cb4d7256ac125 +0 -0
- data/scenarios/git_repositories/config.git/objects/f9/0181466a1a60b793ca9cc9abd584c18d4e3887 +0 -0
- data/scenarios/git_repositories/config.git/objects/f9/49d5d8a4f12c91471e34d4e277239c35ebd10d +0 -0
- data/scenarios/git_repositories/config.git/refs/heads/master +1 -0
- data/scenarios/git_repositories/project.git/HEAD +1 -0
- data/scenarios/git_repositories/project.git/config +5 -0
- data/scenarios/git_repositories/project.git/description +1 -0
- data/scenarios/git_repositories/project.git/git-daemon-export-ok +0 -0
- data/scenarios/git_repositories/project.git/hooks/applypatch-msg.sample +15 -0
- data/scenarios/git_repositories/project.git/hooks/commit-msg.sample +24 -0
- data/scenarios/git_repositories/project.git/hooks/post-commit.sample +8 -0
- data/scenarios/git_repositories/project.git/hooks/post-receive.sample +15 -0
- data/scenarios/git_repositories/project.git/hooks/post-update.sample +8 -0
- data/scenarios/git_repositories/project.git/hooks/pre-applypatch.sample +14 -0
- data/scenarios/git_repositories/project.git/hooks/pre-commit.sample +46 -0
- data/scenarios/git_repositories/project.git/hooks/pre-rebase.sample +169 -0
- data/scenarios/git_repositories/project.git/hooks/prepare-commit-msg.sample +36 -0
- data/scenarios/git_repositories/project.git/hooks/update.sample +128 -0
- data/scenarios/git_repositories/project.git/info/exclude +6 -0
- data/scenarios/git_repositories/project.git/objects/04/26e152e66c8cd42974279bdcae09be9839c172 +0 -0
- data/scenarios/git_repositories/project.git/objects/04/f4de85eaf72ef1631dc6d7424045c0a749b757 +1 -0
- data/scenarios/git_repositories/project.git/objects/06/13fe277280cbcdb2856e1eefc70bdaff011b20 +0 -0
- data/scenarios/git_repositories/project.git/objects/06/7aca89b86265eee211387434c3e50f37ccf009 +0 -0
- data/scenarios/git_repositories/project.git/objects/09/445dacc4822722612d60833c9948219ecdd8f5 +0 -0
- data/scenarios/git_repositories/project.git/objects/11/c4ec64326de35462f4e79d0f4229bf8e26e0c5 +0 -0
- data/scenarios/git_repositories/project.git/objects/20/1c7641c2e42b0b904e5c1f793489d8b858e4da +2 -0
- data/scenarios/git_repositories/project.git/objects/23/979639da60d2d31e9744468df1c1221b101e64 +0 -0
- data/scenarios/git_repositories/project.git/objects/27/a3fff2c4c45ab5513a405f694c0a042cb5d417 +1 -0
- data/scenarios/git_repositories/project.git/objects/2c/0c33cfba8e1af15df88522c0db2b10a6a94138 +2 -0
- data/scenarios/git_repositories/project.git/objects/38/b574660305ecb5fec6b2daa7ee1e0dbf1b6003 +0 -0
- data/scenarios/git_repositories/project.git/objects/4a/57abb5e4e426cfc9101b3af22ac83ccbd8e2ad +0 -0
- data/scenarios/git_repositories/project.git/objects/4c/77ebdd985e57afe7988480720c5dc77ec525c9 +0 -0
- data/scenarios/git_repositories/project.git/objects/51/c94da6f1b8aa9d2346088d3d362475b60c7f32 +0 -0
- data/scenarios/git_repositories/project.git/objects/5b/a96acf9cc9b87babe37c032676f53bf1ba9ae7 +2 -0
- data/scenarios/git_repositories/project.git/objects/5d/f555601d60f1c2a84d2364af0ad640612c3ba5 +0 -0
- data/scenarios/git_repositories/project.git/objects/71/03b5ac94940d596c2160a5cfcd55ca4ccac41f +0 -0
- data/scenarios/git_repositories/project.git/objects/73/3fc331098b03523f414f3509b9ae6e637c6866 +0 -0
- data/scenarios/git_repositories/project.git/objects/80/26076649ceccbe96a6292f2432652f08483035 +0 -0
- data/scenarios/git_repositories/project.git/objects/86/d1ef0976be4567de562224e1b51fbf9820c53a +1 -0
- data/scenarios/git_repositories/project.git/objects/87/a9d8b09b3401d21b23d90253332d6b28b47db2 +0 -0
- data/scenarios/git_repositories/project.git/objects/8b/030ba688255c917d189ae3f87d7c5ccd226bc2 +0 -0
- data/scenarios/git_repositories/project.git/objects/95/c9d5ad9b1c90e4c805516783105fc2037dedeb +2 -0
- data/scenarios/git_repositories/project.git/objects/95/d82d043af35a80eabfd56c0d705abfa3488787 +2 -0
- data/scenarios/git_repositories/project.git/objects/96/0bf34bb0b46d0aeb0be87f688f4ef06a4b35e1 +0 -0
- data/scenarios/git_repositories/project.git/objects/a3/860106dc1d148c7831cd45ae38829b4ed47702 +2 -0
- data/scenarios/git_repositories/project.git/objects/a8/506d6439b71784a72ac72d284b2ad53088f573 +0 -0
- data/scenarios/git_repositories/project.git/objects/ad/22ea6c7563777936ecfbe50d8e2cf8120fd525 +0 -0
- data/scenarios/git_repositories/project.git/objects/ae/3900de54aff557c61c81146d00f9d38e55a265 +1 -0
- data/scenarios/git_repositories/project.git/objects/bf/5e3740d52b80abb0378b3f85f93a53b1294521 +1 -0
- data/scenarios/git_repositories/project.git/objects/bf/b59811cdbc069418dee14b171e6e7e979784b7 +0 -0
- data/scenarios/git_repositories/project.git/objects/cc/5ac0afb24e727d5de344cc26a425f4fb7fd17d +3 -0
- data/scenarios/git_repositories/project.git/objects/d1/091aa2dd76885108461110c639e6b33a297fce +0 -0
- data/scenarios/git_repositories/project.git/objects/d8/913f6650eb2b7bf2a633732d8452008ca23dcb +0 -0
- data/scenarios/git_repositories/project.git/objects/db/d1b9667f1b26b13331ac0c321dced8be1aeab0 +3 -0
- data/scenarios/git_repositories/project.git/objects/e4/3b9107e9b1908ce415025e64eb83a493d329b7 +0 -0
- data/scenarios/git_repositories/project.git/objects/ef/2a88894d5421920b9dfe67a9a4d8043830e62e +0 -0
- data/scenarios/git_repositories/project.git/objects/f4/0123a1ff20c65d8dc15a38a83222647908e6f7 +0 -0
- data/scenarios/git_repositories/project.git/objects/f5/0af315b75ca0b12c720dec6d916b76b968c319 +0 -0
- data/scenarios/git_repositories/project.git/objects/f6/0215709b7b23f3738e9cbaf634b1c86bbd376a +0 -0
- data/scenarios/git_repositories/project.git/refs/heads/bad_rakefile +1 -0
- data/scenarios/git_repositories/project.git/refs/heads/hook_with_changed +1 -0
- data/scenarios/git_repositories/project.git/refs/heads/master +1 -0
- data/scenarios/git_repositories/project.git/refs/heads/no_rake_hooks +1 -0
- data/scenarios/git_repositories/project.git/refs/heads/post_rake_tasks +1 -0
- data/scenarios/invalid/deploy.yml +1 -0
- data/scenarios/local/deploy.yml.erb +17 -0
- data/scenarios/remote/deploy.yml +119 -0
- data/scenarios/setup/vagrant/.gitignore +3 -0
- data/scenarios/setup/vagrant/Vagrantfile +10 -0
- data/scenarios/setup/vagrant/manifests/integration.pp +32 -0
- data/scenarios/setup/vagrant/pids/.gitignore +1 -0
- data/spec/.bacon +0 -0
- data/spec/init_spec.rb +9 -0
- data/spec/install_spec.rb +43 -0
- data/spec/integration/branch_switching_spec.rb +41 -0
- data/spec/integration/deployment_failures_spec.rb +106 -0
- data/spec/integration/helper_spec.rb +90 -0
- data/spec/integration/invalid_configuration_spec.rb +39 -0
- data/spec/integration/local_deployments_spec.rb +230 -0
- data/spec/integration/post_rake_tasks_spec.rb +226 -0
- data/spec/integration/post_scripts_spec.rb +246 -0
- data/spec/integration/remote_deployments_spec.rb +166 -0
- data/spec/integration/staleness_checks_spec.rb +72 -0
- data/spec/spec_helper.rb +117 -0
- data/spec/wd_command_spec.rb +986 -0
- data/spec/wd_role_command_spec.rb +49 -0
- data/spec/whiskey_disk/config/filter_spec.rb +77 -0
- data/spec/whiskey_disk/config/filters/add_environment_name_filter_spec.rb +20 -0
- data/spec/whiskey_disk/config/filters/add_project_name_filter_spec.rb +19 -0
- data/spec/whiskey_disk/config/filters/check_for_duplicate_domains_filter_spec.rb +29 -0
- data/spec/whiskey_disk/config/filters/convert_role_strings_to_list_filter_spec.rb +48 -0
- data/spec/whiskey_disk/config/filters/default_config_target_filter_spec.rb +19 -0
- data/spec/whiskey_disk/config/filters/default_domain_filter_spec.rb +18 -0
- data/spec/whiskey_disk/config/filters/drop_empty_domain_roles_filter_spec.rb +60 -0
- data/spec/whiskey_disk/config/filters/environment_scope_filter_spec.rb +32 -0
- data/spec/whiskey_disk/config/filters/hashify_domain_entries_filter_spec.rb +41 -0
- data/spec/whiskey_disk/config/filters/localize_domains_filter_spec.rb +30 -0
- data/spec/whiskey_disk/config/filters/normalize_ssh_options_filter_spec.rb +56 -0
- data/spec/whiskey_disk/config/filters/project_scope_filter_spec.rb +75 -0
- data/spec/whiskey_disk/config/filters/select_project_and_environment_filter_spec.rb +30 -0
- data/spec/whiskey_disk/config/filters/stringify_hash_keys_filter_spec.rb +40 -0
- data/spec/whiskey_disk/config_spec.rb +754 -0
- data/spec/whiskey_disk/helpers_spec.rb +443 -0
- data/spec/whiskey_disk/rake_spec.rb +261 -0
- data/spec/whiskey_disk_spec.rb +1224 -0
- data/tasks/deploy.rake +2 -0
- data/whisk_deploy.gemspec +215 -0
- metadata +241 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper.rb'))
|
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'whiskey_disk'))
|
|
3
|
+
|
|
4
|
+
integration_spec do
|
|
5
|
+
describe 'when configured for a remote deployment' do
|
|
6
|
+
before do
|
|
7
|
+
setup_deployment_area
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe 'with a single remote domain' do
|
|
11
|
+
before do
|
|
12
|
+
@config = scenario_config('remote/deploy.yml')
|
|
13
|
+
@args = "--path=#{@config} --to=project:remote"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe 'performing a setup' do
|
|
17
|
+
it 'performs a checkout of the repository to the target path' do
|
|
18
|
+
run_setup(@args)
|
|
19
|
+
File.exists?(deployed_file('project/README')).should == true
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'has the working copy set to the master branch' do
|
|
23
|
+
run_setup(@args)
|
|
24
|
+
current_branch('project').should == 'master'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'has the working copy set to the specified branch when one is available' do
|
|
28
|
+
@args = "--path=#{@config} --to=project:remote-on-other-branch"
|
|
29
|
+
run_setup(@args)
|
|
30
|
+
current_branch('project').should == 'no_rake_hooks'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'reports the remote setup as successful' do
|
|
34
|
+
run_setup(@args)
|
|
35
|
+
File.read(integration_log).should =~ /vagrant => succeeded/
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'exits with a true status' do
|
|
39
|
+
run_setup(@args).should == true
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe 'performing a deployment' do
|
|
44
|
+
before do
|
|
45
|
+
checkout_repo('project')
|
|
46
|
+
File.unlink(deployed_file('project/README')) # modify the deployed checkout
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'updates the checkout of the repository on the target path' do
|
|
50
|
+
run_deploy(@args)
|
|
51
|
+
File.exists?(deployed_file('project/README')).should == true
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'has the working copy set to the master branch' do
|
|
55
|
+
run_deploy(@args)
|
|
56
|
+
current_branch('project').should == 'master'
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'has the working copy set to the specified branch when one is available' do
|
|
60
|
+
@args = "--path=#{@config} --to=project:remote-on-other-branch"
|
|
61
|
+
checkout_branch('project', 'no_rake_hooks')
|
|
62
|
+
run_deploy(@args)
|
|
63
|
+
current_branch('project').should == 'no_rake_hooks'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'reports the remote deployment as successful' do
|
|
67
|
+
run_deploy(@args)
|
|
68
|
+
File.read(integration_log).should =~ /vagrant => succeeded/
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'exits with a true status' do
|
|
72
|
+
run_deploy(@args).should == true
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe 'performing a deploy after a setup' do
|
|
77
|
+
describe 'and using the master branch' do
|
|
78
|
+
before do
|
|
79
|
+
run_setup(@args)
|
|
80
|
+
File.unlink(deployed_file('project/README')) # modify the deployed checkout
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'updates the checkout of the repository on the target path' do
|
|
84
|
+
run_deploy(@args)
|
|
85
|
+
File.exists?(deployed_file('project/README')).should == true
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'has the working copy set to the master branch' do
|
|
89
|
+
run_deploy(@args)
|
|
90
|
+
current_branch('project').should == 'master'
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'has the working copy set to the specified branch when one is available' do
|
|
94
|
+
setup_deployment_area
|
|
95
|
+
|
|
96
|
+
@args = "--path=#{@config} --to=project:remote-on-other-branch"
|
|
97
|
+
run_setup(@args)
|
|
98
|
+
|
|
99
|
+
File.unlink(deployed_file('project/README'))
|
|
100
|
+
|
|
101
|
+
run_deploy(@args)
|
|
102
|
+
current_branch('project').should == 'no_rake_hooks'
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'reports the remote deployment as successful' do
|
|
106
|
+
run_deploy(@args)
|
|
107
|
+
File.read(integration_log).should =~ /vagrant => succeeded/
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'exits with a true status' do
|
|
111
|
+
run_deploy(@args).should == true
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
describe 'with ssh options specified' do
|
|
118
|
+
before do
|
|
119
|
+
@config = scenario_config('remote/deploy.yml')
|
|
120
|
+
@args = "--path=#{@config} --to=project:with_ssh_options"
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
describe 'performing a setup' do
|
|
124
|
+
# TODO FIXME -- this spec fails due to interplay between STDOUT and file buffering in ruby system() (*WTF*)
|
|
125
|
+
#
|
|
126
|
+
# it 'uses specified ssh options when performing the setup' do
|
|
127
|
+
# run_setup(@args)
|
|
128
|
+
# dump_log
|
|
129
|
+
# File.read(integration_log).should =~ /ssh.* -t /
|
|
130
|
+
# end
|
|
131
|
+
|
|
132
|
+
it 'reports the remote setup as successful' do
|
|
133
|
+
run_setup(@args)
|
|
134
|
+
File.read(integration_log).should =~ /vagrant => succeeded/
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'exits with a true status' do
|
|
138
|
+
run_setup(@args).should == true
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
describe 'performing a deployment' do
|
|
143
|
+
before do
|
|
144
|
+
checkout_repo('project')
|
|
145
|
+
File.unlink(deployed_file('project/README')) # modify the deployed checkout
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# TODO FIXME -- this spec fails due to interplay between STDOUT and file buffering in ruby system() (*WTF*)
|
|
149
|
+
#
|
|
150
|
+
# it 'uses specified ssh options when performing the setup' do
|
|
151
|
+
# run_deploy(@args, true)
|
|
152
|
+
# File.read(integration_log).should =~ /ssh.* -t /
|
|
153
|
+
# end
|
|
154
|
+
|
|
155
|
+
it 'reports the remote deployment as successful' do
|
|
156
|
+
run_deploy(@args)
|
|
157
|
+
File.read(integration_log).should =~ /vagrant => succeeded/
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it 'exits with a true status' do
|
|
161
|
+
run_deploy(@args).should == true
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper.rb'))
|
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'whiskey_disk'))
|
|
3
|
+
|
|
4
|
+
integration_spec do
|
|
5
|
+
describe 'when configured for a local deployment' do
|
|
6
|
+
before do
|
|
7
|
+
setup_deployment_area
|
|
8
|
+
@config = scenario_config('local/deploy.yml.erb')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'when staleness checkes are enabled' do
|
|
12
|
+
before do
|
|
13
|
+
@args = "--path=#{@config} --to=project:local-default --check"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe 'performing a deployment' do
|
|
17
|
+
before do
|
|
18
|
+
checkout_repo('project')
|
|
19
|
+
File.unlink(deployed_file('project/README')) # modify the deployed checkout
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'does not update the checkout of the repository on the target path' do
|
|
23
|
+
run_deploy(@args)
|
|
24
|
+
File.exists?(deployed_file('project/README')).should == false
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'reports the local deployment as successful' do
|
|
28
|
+
run_deploy(@args)
|
|
29
|
+
File.read(integration_log).should =~ /local => succeeded/
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'exits with a true status' do
|
|
33
|
+
run_deploy(@args).should == true
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe 'when configured for a remote deployment' do
|
|
40
|
+
before do
|
|
41
|
+
setup_deployment_area
|
|
42
|
+
@config = scenario_config('remote/deploy.yml')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe 'when staleness checkes are enabled' do
|
|
46
|
+
before do
|
|
47
|
+
@args = "--path=#{@config} --to=project:remote --check"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe 'performing a deployment' do
|
|
51
|
+
before do
|
|
52
|
+
checkout_repo('project')
|
|
53
|
+
File.unlink(deployed_file('project/README')) # modify the deployed checkout
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'does not update the checkout of the repository on the target path' do
|
|
57
|
+
run_deploy(@args)
|
|
58
|
+
File.exists?(deployed_file('project/README')).should == false
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'reports the local deployment as successful' do
|
|
62
|
+
run_deploy(@args)
|
|
63
|
+
File.read(integration_log).should =~ /vagrant => succeeded/
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'exits with a true status' do
|
|
67
|
+
run_deploy(@args).should == true
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bacon'
|
|
3
|
+
require 'facon'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'tempfile'
|
|
6
|
+
require 'erb'
|
|
7
|
+
|
|
8
|
+
if ENV['DEBUG'] and ENV['DEBUG'] != ''
|
|
9
|
+
STDERR.puts "Enabling debugger for spec runs..."
|
|
10
|
+
require 'rubygems'
|
|
11
|
+
require 'ruby-debug'
|
|
12
|
+
Debugger.start
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
|
16
|
+
|
|
17
|
+
# local target directory, integration spec workspace
|
|
18
|
+
def deployment_root
|
|
19
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..', 'scenarios', 'setup', 'vagrant', 'deployed', 'target'))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# allow defining an integration spec block
|
|
23
|
+
def integration_spec(&block)
|
|
24
|
+
yield if ENV['INTEGRATION'] and ENV['INTEGRATION'] != ''
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# reset the deployment directory for integration specs
|
|
28
|
+
def setup_deployment_area
|
|
29
|
+
FileUtils.rm_rf(deployment_root)
|
|
30
|
+
File.umask(0)
|
|
31
|
+
Dir.mkdir(deployment_root, 0777)
|
|
32
|
+
Dir.mkdir(deployed_file('log'), 0777)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# run a wd setup using the provided arguments string
|
|
36
|
+
def run_setup(arguments, debugging = true)
|
|
37
|
+
wd_path = File.join(File.dirname(__FILE__), '..', 'bin', 'wd')
|
|
38
|
+
lib_path = File.join(File.dirname(__FILE__), '..', 'lib')
|
|
39
|
+
debug = debugging ? '--debug' : ''
|
|
40
|
+
system("/usr/bin/env ruby -I #{lib_path} -r whiskey_disk -rubygems #{wd_path} setup #{debug} #{arguments} > #{integration_log} 2> #{integration_log}")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def integration_log
|
|
44
|
+
deployed_file('log/out.txt')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# run a wd setup using the provided arguments string
|
|
48
|
+
def run_deploy(arguments, debugging = true)
|
|
49
|
+
wd_path = File.join(File.dirname(__FILE__), '..', 'bin', 'wd')
|
|
50
|
+
lib_path = File.join(File.dirname(__FILE__), '..', 'lib')
|
|
51
|
+
debug = debugging ? '--debug' : ''
|
|
52
|
+
status = system("/usr/bin/env ruby -I #{lib_path} -r whiskey_disk -rubygems #{wd_path} deploy #{debug} #{arguments} > #{integration_log} 2> #{integration_log}")
|
|
53
|
+
status
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# build the correct local path to the deployment configuration for a given scenario
|
|
57
|
+
def scenario_config(path)
|
|
58
|
+
return erb_scenario_config(path) if path =~ /\.erb$/
|
|
59
|
+
scenario_config_path(path)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def scenario_config_path(path)
|
|
63
|
+
File.join(File.dirname(__FILE__), '..', 'scenarios', path)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def erb_scenario_config(path)
|
|
67
|
+
data = File.read(scenario_config_path(path))
|
|
68
|
+
converted = erb_eval(data)
|
|
69
|
+
write_tempfile(converted)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def erb_eval(data)
|
|
73
|
+
ERB.new(data).result
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def write_tempfile(data)
|
|
77
|
+
tmp_file = Tempfile.new('whiskey_disk_integration_spec_scenario')
|
|
78
|
+
tmp_file.puts(data)
|
|
79
|
+
tmp_file.close
|
|
80
|
+
tmp_file.path
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# clone a git repository locally (as if a "wd setup" had been deployed)
|
|
84
|
+
def checkout_repo(repo_name, branch = nil)
|
|
85
|
+
repo_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'scenarios', 'git_repositories', "#{repo_name}.git"))
|
|
86
|
+
system("cd #{deployment_root} && git clone #{repo_path} >/dev/null 2>/dev/null && cd #{repo_name} && git remote set-url origin #{remote_url(repo_name)}")
|
|
87
|
+
checkout_branch(repo_name, branch)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def remote_url(repo)
|
|
91
|
+
"git://wd-git.example.com/#{repo}.git"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def checkout_branch(repo_name, branch = nil)
|
|
95
|
+
return unless branch
|
|
96
|
+
system("cd #{deployment_root}/#{repo_name} && git checkout #{branch} >/dev/null 2>/dev/null")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def jump_to_initial_commit(path)
|
|
100
|
+
system(%Q(cd #{File.join(deployment_root, path)} && git reset --hard `git log --oneline | tail -1 | awk '{print $1}'` >/dev/null 2>/dev/null))
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def run_log
|
|
104
|
+
File.readlines(integration_log)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def deployed_file(path)
|
|
108
|
+
File.join(deployment_root, path)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def dump_log
|
|
112
|
+
STDERR.puts("\n\n\n" + File.read(integration_log) + "\n\n\n")
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def current_branch(path)
|
|
116
|
+
`cd #{deployed_file(path)} && git branch`.split("\n").grep(/^\*/).first.sub(/^\* /, '')
|
|
117
|
+
end
|
|
@@ -0,0 +1,986 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
require 'rake'
|
|
3
|
+
|
|
4
|
+
def run_command
|
|
5
|
+
cmd_path = File.expand_path(File.join(File.dirname(__FILE__), *%w[.. bin wd]))
|
|
6
|
+
path = File.expand_path(File.dirname(cmd_path))
|
|
7
|
+
file = File.read(cmd_path)
|
|
8
|
+
|
|
9
|
+
Dir.chdir(path) do |path|
|
|
10
|
+
eval(file)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe 'wd command' do
|
|
15
|
+
before do
|
|
16
|
+
@stderr, @stdout, $stderr, $stdout = $stderr, $stdout, StringIO.new, StringIO.new
|
|
17
|
+
ENV['to'] = ENV['path'] = nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
after do
|
|
21
|
+
@stderr, @stdout, $stderr, $stdout = $stderr, $stdout, @stderr, @stdout
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe 'when no command-line arguments are specified' do
|
|
25
|
+
before do
|
|
26
|
+
Object.send(:remove_const, :ARGV)
|
|
27
|
+
ARGV = []
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'does not run rake tasks' do
|
|
31
|
+
Rake::Application.should.receive(:new).never
|
|
32
|
+
lambda { run_command }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'exits' do
|
|
36
|
+
lambda { run_command }.should.raise(SystemExit)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'exits with a failure status' do
|
|
40
|
+
begin
|
|
41
|
+
run_command
|
|
42
|
+
rescue Exception => e
|
|
43
|
+
e.success?.should == false
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'outputs usage without a backtrace when --help is specified' do
|
|
49
|
+
Object.send(:remove_const, :ARGV)
|
|
50
|
+
ARGV = ['--help']
|
|
51
|
+
lambda { run_command }.should.raise(SystemExit)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'outputs usage without a backtrace when garbage options are specified' do
|
|
55
|
+
Object.send(:remove_const, :ARGV)
|
|
56
|
+
ARGV = ['--slkjfsdflkj']
|
|
57
|
+
lambda { run_command }.should.raise(SystemExit)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe 'when --version argument is specified' do
|
|
61
|
+
before do
|
|
62
|
+
Object.send(:remove_const, :ARGV)
|
|
63
|
+
ARGV = ['--version']
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# it 'outputs the version stored in the VERSION file' do
|
|
67
|
+
# version = File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', 'VERSION'))).chomp
|
|
68
|
+
# # TODO: capture version output
|
|
69
|
+
# lambda{ run_command }
|
|
70
|
+
# end
|
|
71
|
+
|
|
72
|
+
it 'exits' do
|
|
73
|
+
lambda { run_command }.should.raise(SystemExit)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'exits successfully' do
|
|
77
|
+
begin
|
|
78
|
+
run_command
|
|
79
|
+
rescue SystemExit => e
|
|
80
|
+
e.success?.should == true
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe "when the 'setup' command is specified" do
|
|
86
|
+
before do
|
|
87
|
+
Object.send(:remove_const, :ARGV)
|
|
88
|
+
ARGV = ['setup']
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
describe 'and no target is specified' do
|
|
92
|
+
it 'does not run rake tasks' do
|
|
93
|
+
Rake::Application.should.receive(:new).never
|
|
94
|
+
lambda { run_command }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'exits when a target is specified' do
|
|
98
|
+
lambda { run_command }.should.raise(SystemExit)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it 'exits with a failing status when a target is specified' do
|
|
102
|
+
begin
|
|
103
|
+
run_command
|
|
104
|
+
rescue SystemExit => e
|
|
105
|
+
e.success?.should == false
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
describe 'and a --to argument is specified' do
|
|
112
|
+
before do
|
|
113
|
+
ARGV.push '--to=foo'
|
|
114
|
+
@rake = Rake::Task['deploy:setup']
|
|
115
|
+
@rake.stub!(:invoke)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'does not fail' do
|
|
119
|
+
lambda { run_command }.should.not.raise
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it 'runs the deploy:setup rake task' do
|
|
123
|
+
@rake.should.receive(:invoke)
|
|
124
|
+
run_command
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it 'makes the specified target available as a "to" argument to the rake task' do
|
|
128
|
+
run_command
|
|
129
|
+
ENV['to'].should == 'foo'
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
describe 'and a --path argument is specified' do
|
|
133
|
+
before do
|
|
134
|
+
ARGV.push '--path=/path/to/foo'
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'makes the specified path available as a "path" argument to the rake task' do
|
|
138
|
+
run_command
|
|
139
|
+
ENV['path'].should == '/path/to/foo'
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it 'fails if the rake task fails' do
|
|
143
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
144
|
+
lambda { run_command }.should.raise
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'does not fail if the rake task succeeds' do
|
|
148
|
+
@rake.stub!(:invoke).and_return(true)
|
|
149
|
+
lambda { run_command }.should.not.raise
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
describe 'and a -p argument is specified' do
|
|
154
|
+
before do
|
|
155
|
+
ARGV.push '-p'
|
|
156
|
+
ARGV.push '/path/to/foo'
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'makes the specified path available as a "path" argument to the rake task' do
|
|
160
|
+
run_command
|
|
161
|
+
ENV['path'].should == '/path/to/foo'
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it 'fails if the rake task fails' do
|
|
165
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
166
|
+
lambda { run_command }.should.raise
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it 'does not fail if the rake task succeeds' do
|
|
170
|
+
@rake.stub!(:invoke).and_return(true)
|
|
171
|
+
lambda { run_command }.should.not.raise
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
describe 'and no --path or -p argument is specified' do
|
|
176
|
+
it 'does not make a "path" argument available to the rake task' do
|
|
177
|
+
ENV['path'].should.be.nil
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it 'fails if the rake task fails' do
|
|
181
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
182
|
+
lambda { run_command }.should.raise
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it 'does not fail if the rake task succeeds' do
|
|
186
|
+
@rake.stub!(:invoke).and_return(true)
|
|
187
|
+
lambda { run_command }.should.not.raise
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
describe 'and a --only argument is specified' do
|
|
192
|
+
before do
|
|
193
|
+
@domain = 'smeghost'
|
|
194
|
+
ARGV.push "--only=#{@domain}"
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it 'makes the specified domain available as an "only" argument to the rake task' do
|
|
198
|
+
run_command
|
|
199
|
+
ENV['only'].should == @domain
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it 'fails if the rake task fails' do
|
|
203
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
204
|
+
lambda { run_command }.should.raise
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it 'does not fail if the rake task succeeds' do
|
|
208
|
+
@rake.stub!(:invoke).and_return(true)
|
|
209
|
+
lambda { run_command }.should.not.raise
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
describe 'and a -o argument is specified' do
|
|
214
|
+
before do
|
|
215
|
+
@domain = 'smeghost'
|
|
216
|
+
ARGV.push '-o'
|
|
217
|
+
ARGV.push @domain
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
it 'makes the specified domain available as an "only" argument to the rake task' do
|
|
221
|
+
run_command
|
|
222
|
+
ENV['only'].should == @domain
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it 'fails if the rake task fails' do
|
|
226
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
227
|
+
lambda { run_command }.should.raise
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it 'does not fail if the rake task succeeds' do
|
|
231
|
+
@rake.stub!(:invoke).and_return(true)
|
|
232
|
+
lambda { run_command }.should.not.raise
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
describe 'and no --only or -o argument is specified' do
|
|
237
|
+
it 'does not make an "only" argument available to the rake task' do
|
|
238
|
+
run_command
|
|
239
|
+
ENV['only'].should.be.nil
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
it 'fails if the rake task fails' do
|
|
243
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
244
|
+
lambda { run_command }.should.raise
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
it 'does not fail if the rake task succeeds' do
|
|
248
|
+
@rake.stub!(:invoke).and_return(true)
|
|
249
|
+
lambda { run_command }.should.not.raise
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
describe 'and a --debug argument is specified' do
|
|
254
|
+
before do
|
|
255
|
+
ARGV.push '--debug'
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
it 'runs the deploy:now rake task' do
|
|
259
|
+
@rake.should.receive(:invoke)
|
|
260
|
+
run_command
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
it 'makes the specified target available as a "debug" argument to the rake task' do
|
|
264
|
+
run_command
|
|
265
|
+
ENV['debug'].should == 'true'
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
it 'fails if the rake task fails' do
|
|
269
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
270
|
+
lambda { run_command }.should.raise
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
it 'does not fail if the rake task succeeds' do
|
|
274
|
+
@rake.stub!(:invoke).and_return(true)
|
|
275
|
+
lambda { run_command }.should.not.raise
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
describe 'and a -d argument is specified' do
|
|
280
|
+
before do
|
|
281
|
+
ARGV.push '-d'
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
it 'runs the deploy:now rake task' do
|
|
285
|
+
@rake.should.receive(:invoke)
|
|
286
|
+
run_command
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
it 'makes the specified target available as a "debug" argument to the rake task' do
|
|
290
|
+
run_command
|
|
291
|
+
ENV['debug'].should == 'true'
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
it 'fails if the rake task fails' do
|
|
295
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
296
|
+
lambda { run_command }.should.raise
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
it 'does not fail if the rake task succeeds' do
|
|
300
|
+
@rake.stub!(:invoke).and_return(true)
|
|
301
|
+
lambda { run_command }.should.not.raise
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
describe 'and no --debug or -d argument is specified' do
|
|
306
|
+
it 'does not make a "debug" argument available to the rake task' do
|
|
307
|
+
run_command
|
|
308
|
+
ENV['debug'].should.be.nil
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
it 'runs the deploy:now rake task' do
|
|
312
|
+
@rake.should.receive(:invoke)
|
|
313
|
+
run_command
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
it 'fails if the rake task fails' do
|
|
317
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
318
|
+
lambda { run_command }.should.raise
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
it 'does not fail if the rake task succeeds' do
|
|
322
|
+
@rake.stub!(:invoke).and_return(true)
|
|
323
|
+
lambda { run_command }.should.not.raise
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
describe 'and a -t argument is specified' do
|
|
329
|
+
before do
|
|
330
|
+
ARGV.push '-t'
|
|
331
|
+
ARGV.push 'foo'
|
|
332
|
+
@rake = Rake::Task['deploy:setup']
|
|
333
|
+
@rake.stub!(:invoke)
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
it 'does not fail' do
|
|
337
|
+
lambda { run_command }.should.not.raise
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
it 'runs the deploy:setup rake task' do
|
|
341
|
+
@rake.should.receive(:invoke)
|
|
342
|
+
run_command
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
it 'makes the specified target available as a "to" argument to the rake task' do
|
|
346
|
+
run_command
|
|
347
|
+
ENV['to'].should == 'foo'
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
describe 'and a --path argument is specified' do
|
|
351
|
+
before do
|
|
352
|
+
ARGV.push '--path=/path/to/foo'
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
it 'makes the specified path available as a "path" argument to the rake task' do
|
|
356
|
+
run_command
|
|
357
|
+
ENV['path'].should == '/path/to/foo'
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
it 'fails if the rake task fails' do
|
|
361
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
362
|
+
lambda { run_command }.should.raise
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
it 'does not fail if the rake task succeeds' do
|
|
366
|
+
@rake.stub!(:invoke).and_return(true)
|
|
367
|
+
lambda { run_command }.should.not.raise
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
describe 'and a -p argument is specified' do
|
|
372
|
+
before do
|
|
373
|
+
ARGV.push '-p'
|
|
374
|
+
ARGV.push '/path/to/foo'
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
it 'makes the specified path available as a "path" argument to the rake task' do
|
|
378
|
+
run_command
|
|
379
|
+
ENV['path'].should == '/path/to/foo'
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
it 'fails if the rake task fails' do
|
|
383
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
384
|
+
lambda { run_command }.should.raise
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
it 'does not fail if the rake task succeeds' do
|
|
388
|
+
@rake.stub!(:invoke).and_return(true)
|
|
389
|
+
lambda { run_command }.should.not.raise
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
describe 'and no --path or -p argument is specified' do
|
|
394
|
+
it 'does not make a "path" argument available to the rake task' do
|
|
395
|
+
ENV['path'].should.be.nil
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
it 'fails if the rake task fails' do
|
|
399
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
400
|
+
lambda { run_command }.should.raise
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
it 'does not fail if the rake task succeeds' do
|
|
404
|
+
@rake.stub!(:invoke).and_return(true)
|
|
405
|
+
lambda { run_command }.should.not.raise
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
describe 'and a --only argument is specified' do
|
|
410
|
+
before do
|
|
411
|
+
@domain = 'smeghost'
|
|
412
|
+
ARGV.push "--only=#{@domain}"
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
it 'makes the specified domain available as an "only" argument to the rake task' do
|
|
416
|
+
run_command
|
|
417
|
+
ENV['only'].should == @domain
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
it 'fails if the rake task fails' do
|
|
421
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
422
|
+
lambda { run_command }.should.raise
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
it 'does not fail if the rake task succeeds' do
|
|
426
|
+
@rake.stub!(:invoke).and_return(true)
|
|
427
|
+
lambda { run_command }.should.not.raise
|
|
428
|
+
end
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
describe 'and a -o argument is specified' do
|
|
432
|
+
before do
|
|
433
|
+
@domain = 'smeghost'
|
|
434
|
+
ARGV.push '-o'
|
|
435
|
+
ARGV.push @domain
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
it 'makes the specified domain available as an "only" argument to the rake task' do
|
|
439
|
+
run_command
|
|
440
|
+
ENV['only'].should == @domain
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
it 'fails if the rake task fails' do
|
|
444
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
445
|
+
lambda { run_command }.should.raise
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
it 'does not fail if the rake task succeeds' do
|
|
449
|
+
@rake.stub!(:invoke).and_return(true)
|
|
450
|
+
lambda { run_command }.should.not.raise
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
describe 'and no --only or -o argument is specified' do
|
|
455
|
+
it 'does not make an "only" argument available to the rake task' do
|
|
456
|
+
run_command
|
|
457
|
+
ENV['only'].should.be.nil
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
it 'fails if the rake task fails' do
|
|
461
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
462
|
+
lambda { run_command }.should.raise
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
it 'does not fail if the rake task succeeds' do
|
|
466
|
+
@rake.stub!(:invoke).and_return(true)
|
|
467
|
+
lambda { run_command }.should.not.raise
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
describe "when the 'deploy' command is specified" do
|
|
474
|
+
before do
|
|
475
|
+
Object.send(:remove_const, :ARGV)
|
|
476
|
+
ARGV = ['deploy']
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
describe 'but no target is specified' do
|
|
480
|
+
it 'does not run rake tasks' do
|
|
481
|
+
Rake::Application.should.receive(:new).never
|
|
482
|
+
lambda { run_command }
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
it 'exits when a target is specified' do
|
|
486
|
+
lambda { run_command }.should.raise(SystemExit)
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
it 'exits with a failing status when a target is specified' do
|
|
490
|
+
begin
|
|
491
|
+
run_command
|
|
492
|
+
rescue SystemExit => e
|
|
493
|
+
e.success?.should == false
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
describe 'and a --to argument is specified' do
|
|
499
|
+
before do
|
|
500
|
+
ARGV.push '--to=foo'
|
|
501
|
+
@rake = Rake::Task['deploy:now']
|
|
502
|
+
@rake.stub!(:invoke)
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
it 'does not fail' do
|
|
506
|
+
lambda { run_command }.should.not.raise
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
it 'runs the deploy:now rake task' do
|
|
510
|
+
@rake.should.receive(:invoke)
|
|
511
|
+
run_command
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
it 'makes the specified target available as a "to" argument to the rake task' do
|
|
515
|
+
run_command
|
|
516
|
+
ENV['to'].should == 'foo'
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
describe 'and a --check argument is specified' do
|
|
520
|
+
before do
|
|
521
|
+
ARGV.push '--check'
|
|
522
|
+
@rake = Rake::Task['deploy:now']
|
|
523
|
+
@rake.stub!(:invoke)
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
it 'does not fail' do
|
|
527
|
+
lambda { run_command }.should.not.raise
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
it 'runs the deploy:now rake task' do
|
|
531
|
+
@rake.should.receive(:invoke)
|
|
532
|
+
run_command
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
it 'makes the specified target available as a "check" argument to the rake task' do
|
|
536
|
+
run_command
|
|
537
|
+
ENV['check'].should == 'true'
|
|
538
|
+
end
|
|
539
|
+
end
|
|
540
|
+
|
|
541
|
+
describe 'and a -c argument is specified' do
|
|
542
|
+
before do
|
|
543
|
+
ARGV.push '-c'
|
|
544
|
+
@rake = Rake::Task['deploy:now']
|
|
545
|
+
@rake.stub!(:invoke)
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
it 'does not fail' do
|
|
549
|
+
lambda { run_command }.should.not.raise
|
|
550
|
+
end
|
|
551
|
+
|
|
552
|
+
it 'runs the deploy:now rake task' do
|
|
553
|
+
@rake.should.receive(:invoke)
|
|
554
|
+
run_command
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
it 'makes the specified target available as a "check" argument to the rake task' do
|
|
558
|
+
run_command
|
|
559
|
+
ENV['check'].should == 'true'
|
|
560
|
+
end
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
describe 'and no --check or -c argument is specified' do
|
|
564
|
+
it 'does not make a "check" argument available to the rake task' do
|
|
565
|
+
run_command
|
|
566
|
+
ENV['check'].should.be.nil
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
it 'fails if the rake task fails' do
|
|
570
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
571
|
+
lambda { run_command }.should.raise
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
it 'does not fail if the rake task succeeds' do
|
|
575
|
+
@rake.stub!(:invoke).and_return(true)
|
|
576
|
+
lambda { run_command }.should.not.raise
|
|
577
|
+
end
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
describe 'and a --path argument is specified' do
|
|
581
|
+
before do
|
|
582
|
+
ARGV.push '--path=/path/to/foo'
|
|
583
|
+
end
|
|
584
|
+
|
|
585
|
+
it 'makes the specified path available as a "path" argument to the rake task' do
|
|
586
|
+
run_command
|
|
587
|
+
ENV['path'].should == '/path/to/foo'
|
|
588
|
+
end
|
|
589
|
+
|
|
590
|
+
it 'fails if the rake task fails' do
|
|
591
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
592
|
+
lambda { run_command }.should.raise
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
it 'does not fail if the rake task succeeds' do
|
|
596
|
+
@rake.stub!(:invoke).and_return(true)
|
|
597
|
+
lambda { run_command }.should.not.raise
|
|
598
|
+
end
|
|
599
|
+
end
|
|
600
|
+
|
|
601
|
+
describe 'and a -p argument is specified' do
|
|
602
|
+
before do
|
|
603
|
+
ARGV.push '-p'
|
|
604
|
+
ARGV.push '/path/to/foo'
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
it 'makes the specified path available as a "path" argument to the rake task' do
|
|
608
|
+
run_command
|
|
609
|
+
ENV['path'].should == '/path/to/foo'
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
it 'fails if the rake task fails' do
|
|
613
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
614
|
+
lambda { run_command }.should.raise
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
it 'does not fail if the rake task succeeds' do
|
|
618
|
+
@rake.stub!(:invoke).and_return(true)
|
|
619
|
+
lambda { run_command }.should.not.raise
|
|
620
|
+
end
|
|
621
|
+
end
|
|
622
|
+
|
|
623
|
+
describe 'and no --path or -p argument is specified' do
|
|
624
|
+
it 'does not make a "path" argument available to the rake task' do
|
|
625
|
+
run_command
|
|
626
|
+
ENV['path'].should.be.nil
|
|
627
|
+
end
|
|
628
|
+
|
|
629
|
+
it 'fails if the rake task fails' do
|
|
630
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
631
|
+
lambda { run_command }.should.raise
|
|
632
|
+
end
|
|
633
|
+
|
|
634
|
+
it 'does not fail if the rake task succeeds' do
|
|
635
|
+
@rake.stub!(:invoke).and_return(true)
|
|
636
|
+
lambda { run_command }.should.not.raise
|
|
637
|
+
end
|
|
638
|
+
end
|
|
639
|
+
|
|
640
|
+
describe 'and a --only argument is specified' do
|
|
641
|
+
before do
|
|
642
|
+
@domain = 'smeghost'
|
|
643
|
+
ARGV.push "--only=#{@domain}"
|
|
644
|
+
end
|
|
645
|
+
|
|
646
|
+
it 'makes the specified domain available as an "only" argument to the rake task' do
|
|
647
|
+
run_command
|
|
648
|
+
ENV['only'].should == @domain
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
it 'fails if the rake task fails' do
|
|
652
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
653
|
+
lambda { run_command }.should.raise
|
|
654
|
+
end
|
|
655
|
+
|
|
656
|
+
it 'does not fail if the rake task succeeds' do
|
|
657
|
+
@rake.stub!(:invoke).and_return(true)
|
|
658
|
+
lambda { run_command }.should.not.raise
|
|
659
|
+
end
|
|
660
|
+
end
|
|
661
|
+
|
|
662
|
+
describe 'and a -o argument is specified' do
|
|
663
|
+
before do
|
|
664
|
+
@domain = 'smeghost'
|
|
665
|
+
ARGV.push '-o'
|
|
666
|
+
ARGV.push @domain
|
|
667
|
+
end
|
|
668
|
+
|
|
669
|
+
it 'makes the specified domain available as an "only" argument to the rake task' do
|
|
670
|
+
run_command
|
|
671
|
+
ENV['only'].should == @domain
|
|
672
|
+
end
|
|
673
|
+
|
|
674
|
+
it 'fails if the rake task fails' do
|
|
675
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
676
|
+
lambda { run_command }.should.raise
|
|
677
|
+
end
|
|
678
|
+
|
|
679
|
+
it 'does not fail if the rake task succeeds' do
|
|
680
|
+
@rake.stub!(:invoke).and_return(true)
|
|
681
|
+
lambda { run_command }.should.not.raise
|
|
682
|
+
end
|
|
683
|
+
end
|
|
684
|
+
|
|
685
|
+
describe 'and no --only or -o argument is specified' do
|
|
686
|
+
it 'does not make an "only" argument available to the rake task' do
|
|
687
|
+
run_command
|
|
688
|
+
ENV['only'].should.be.nil
|
|
689
|
+
end
|
|
690
|
+
|
|
691
|
+
it 'fails if the rake task fails' do
|
|
692
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
693
|
+
lambda { run_command }.should.raise
|
|
694
|
+
end
|
|
695
|
+
|
|
696
|
+
it 'does not fail if the rake task succeeds' do
|
|
697
|
+
@rake.stub!(:invoke).and_return(true)
|
|
698
|
+
lambda { run_command }.should.not.raise
|
|
699
|
+
end
|
|
700
|
+
end
|
|
701
|
+
end
|
|
702
|
+
|
|
703
|
+
describe 'and a -t argument is specified' do
|
|
704
|
+
before do
|
|
705
|
+
ARGV.push '-t'
|
|
706
|
+
ARGV.push 'foo'
|
|
707
|
+
@rake = Rake::Task['deploy:now']
|
|
708
|
+
@rake.stub!(:invoke)
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
it 'does not fail' do
|
|
712
|
+
lambda { run_command }.should.not.raise
|
|
713
|
+
end
|
|
714
|
+
|
|
715
|
+
it 'runs the deploy:now rake task' do
|
|
716
|
+
@rake.should.receive(:invoke)
|
|
717
|
+
run_command
|
|
718
|
+
end
|
|
719
|
+
|
|
720
|
+
it 'makes the specified target available as a "to" argument to the rake task' do
|
|
721
|
+
run_command
|
|
722
|
+
ENV['to'].should == 'foo'
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
describe 'and a --check argument is specified' do
|
|
726
|
+
before do
|
|
727
|
+
ARGV.push '--check'
|
|
728
|
+
@rake = Rake::Task['deploy:now']
|
|
729
|
+
@rake.stub!(:invoke)
|
|
730
|
+
end
|
|
731
|
+
|
|
732
|
+
it 'does not fail' do
|
|
733
|
+
lambda { run_command }.should.not.raise
|
|
734
|
+
end
|
|
735
|
+
|
|
736
|
+
it 'runs the deploy:now rake task' do
|
|
737
|
+
@rake.should.receive(:invoke)
|
|
738
|
+
run_command
|
|
739
|
+
end
|
|
740
|
+
|
|
741
|
+
it 'makes the specified target available as a "check" argument to the rake task' do
|
|
742
|
+
run_command
|
|
743
|
+
ENV['check'].should == 'true'
|
|
744
|
+
end
|
|
745
|
+
end
|
|
746
|
+
|
|
747
|
+
describe 'and a -c argument is specified' do
|
|
748
|
+
before do
|
|
749
|
+
ARGV.push '-c'
|
|
750
|
+
@rake = Rake::Task['deploy:now']
|
|
751
|
+
@rake.stub!(:invoke)
|
|
752
|
+
end
|
|
753
|
+
|
|
754
|
+
it 'does not fail' do
|
|
755
|
+
lambda { run_command }.should.not.raise
|
|
756
|
+
end
|
|
757
|
+
|
|
758
|
+
it 'runs the deploy:now rake task' do
|
|
759
|
+
@rake.should.receive(:invoke)
|
|
760
|
+
run_command
|
|
761
|
+
end
|
|
762
|
+
|
|
763
|
+
it 'makes the specified target available as a "check" argument to the rake task' do
|
|
764
|
+
run_command
|
|
765
|
+
ENV['check'].should == 'true'
|
|
766
|
+
end
|
|
767
|
+
end
|
|
768
|
+
|
|
769
|
+
describe 'and no --check or -c argument is specified' do
|
|
770
|
+
it 'does not make a "check" argument available to the rake task' do
|
|
771
|
+
run_command
|
|
772
|
+
ENV['check'].should.be.nil
|
|
773
|
+
end
|
|
774
|
+
|
|
775
|
+
it 'fails if the rake task fails' do
|
|
776
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
777
|
+
lambda { run_command }.should.raise
|
|
778
|
+
end
|
|
779
|
+
|
|
780
|
+
it 'does not fail if the rake task succeeds' do
|
|
781
|
+
@rake.stub!(:invoke).and_return(true)
|
|
782
|
+
lambda { run_command }.should.not.raise
|
|
783
|
+
end
|
|
784
|
+
end
|
|
785
|
+
|
|
786
|
+
describe 'and a --path argument is specified' do
|
|
787
|
+
before do
|
|
788
|
+
ARGV.push '--path=/path/to/foo'
|
|
789
|
+
end
|
|
790
|
+
|
|
791
|
+
it 'makes the specified path available as a "path" argument to the rake task' do
|
|
792
|
+
run_command
|
|
793
|
+
ENV['path'].should == '/path/to/foo'
|
|
794
|
+
end
|
|
795
|
+
|
|
796
|
+
it 'fails if the rake task fails' do
|
|
797
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
798
|
+
lambda { run_command }.should.raise
|
|
799
|
+
end
|
|
800
|
+
|
|
801
|
+
it 'does not fail if the rake task succeeds' do
|
|
802
|
+
@rake.stub!(:invoke).and_return(true)
|
|
803
|
+
lambda { run_command }.should.not.raise
|
|
804
|
+
end
|
|
805
|
+
end
|
|
806
|
+
|
|
807
|
+
describe 'and a -p argument is specified' do
|
|
808
|
+
before do
|
|
809
|
+
ARGV.push '-p'
|
|
810
|
+
ARGV.push '/path/to/foo'
|
|
811
|
+
end
|
|
812
|
+
|
|
813
|
+
it 'makes the specified path available as a "path" argument to the rake task' do
|
|
814
|
+
run_command
|
|
815
|
+
ENV['path'].should == '/path/to/foo'
|
|
816
|
+
end
|
|
817
|
+
|
|
818
|
+
it 'fails if the rake task fails' do
|
|
819
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
820
|
+
lambda { run_command }.should.raise
|
|
821
|
+
end
|
|
822
|
+
|
|
823
|
+
it 'does not fail if the rake task succeeds' do
|
|
824
|
+
@rake.stub!(:invoke).and_return(true)
|
|
825
|
+
lambda { run_command }.should.not.raise
|
|
826
|
+
end
|
|
827
|
+
end
|
|
828
|
+
|
|
829
|
+
describe 'and no --path or -p argument is specified' do
|
|
830
|
+
it 'does not make a "path" argument available to the rake task' do
|
|
831
|
+
ENV['path'].should.be.nil
|
|
832
|
+
end
|
|
833
|
+
|
|
834
|
+
it 'fails if the rake task fails' do
|
|
835
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
836
|
+
lambda { run_command }.should.raise
|
|
837
|
+
end
|
|
838
|
+
|
|
839
|
+
it 'does not fail if the rake task succeeds' do
|
|
840
|
+
@rake.stub!(:invoke).and_return(true)
|
|
841
|
+
lambda { run_command }.should.not.raise
|
|
842
|
+
end
|
|
843
|
+
end
|
|
844
|
+
|
|
845
|
+
describe 'and a --only argument is specified' do
|
|
846
|
+
before do
|
|
847
|
+
@domain = 'smeghost'
|
|
848
|
+
ARGV.push "--only=#{@domain}"
|
|
849
|
+
end
|
|
850
|
+
|
|
851
|
+
it 'makes the specified domain available as an "only" argument to the rake task' do
|
|
852
|
+
run_command
|
|
853
|
+
ENV['only'].should == @domain
|
|
854
|
+
end
|
|
855
|
+
|
|
856
|
+
it 'fails if the rake task fails' do
|
|
857
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
858
|
+
lambda { run_command }.should.raise
|
|
859
|
+
end
|
|
860
|
+
|
|
861
|
+
it 'does not fail if the rake task succeeds' do
|
|
862
|
+
@rake.stub!(:invoke).and_return(true)
|
|
863
|
+
lambda { run_command }.should.not.raise
|
|
864
|
+
end
|
|
865
|
+
end
|
|
866
|
+
|
|
867
|
+
describe 'and a -o argument is specified' do
|
|
868
|
+
before do
|
|
869
|
+
@domain = 'smeghost'
|
|
870
|
+
ARGV.push '-o'
|
|
871
|
+
ARGV.push @domain
|
|
872
|
+
end
|
|
873
|
+
|
|
874
|
+
it 'makes the specified domain available as an "only" argument to the rake task' do
|
|
875
|
+
run_command
|
|
876
|
+
ENV['only'].should == @domain
|
|
877
|
+
end
|
|
878
|
+
|
|
879
|
+
it 'fails if the rake task fails' do
|
|
880
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
881
|
+
lambda { run_command }.should.raise
|
|
882
|
+
end
|
|
883
|
+
|
|
884
|
+
it 'does not fail if the rake task succeeds' do
|
|
885
|
+
@rake.stub!(:invoke).and_return(true)
|
|
886
|
+
lambda { run_command }.should.not.raise
|
|
887
|
+
end
|
|
888
|
+
end
|
|
889
|
+
|
|
890
|
+
describe 'and no --only or -o argument is specified' do
|
|
891
|
+
it 'does not make an "only" argument available to the rake task' do
|
|
892
|
+
run_command
|
|
893
|
+
ENV['only'].should.be.nil
|
|
894
|
+
end
|
|
895
|
+
|
|
896
|
+
it 'fails if the rake task fails' do
|
|
897
|
+
@rake.stub!(:invoke).and_raise(RuntimeError)
|
|
898
|
+
lambda { run_command }.should.raise
|
|
899
|
+
end
|
|
900
|
+
|
|
901
|
+
it 'does not fail if the rake task succeeds' do
|
|
902
|
+
@rake.stub!(:invoke).and_return(true)
|
|
903
|
+
lambda { run_command }.should.not.raise
|
|
904
|
+
end
|
|
905
|
+
end
|
|
906
|
+
end
|
|
907
|
+
end
|
|
908
|
+
|
|
909
|
+
describe 'and more than one command is specified' do
|
|
910
|
+
before do
|
|
911
|
+
Object.send(:remove_const, :ARGV)
|
|
912
|
+
ARGV = ['frazzlebazzle', 'shizzlebizzle']
|
|
913
|
+
end
|
|
914
|
+
|
|
915
|
+
describe 'when no target is specified' do
|
|
916
|
+
it 'exits when a target is specified' do
|
|
917
|
+
lambda { run_command }.should.raise(SystemExit)
|
|
918
|
+
end
|
|
919
|
+
|
|
920
|
+
it 'exits with a failing status when a target is specified' do
|
|
921
|
+
begin
|
|
922
|
+
run_command
|
|
923
|
+
rescue SystemExit => e
|
|
924
|
+
e.success?.should == false
|
|
925
|
+
end
|
|
926
|
+
end
|
|
927
|
+
end
|
|
928
|
+
|
|
929
|
+
describe 'when a target is specified' do
|
|
930
|
+
before do
|
|
931
|
+
ARGV.push('--to=foo')
|
|
932
|
+
end
|
|
933
|
+
|
|
934
|
+
it 'exits when a target is specified' do
|
|
935
|
+
lambda { run_command }.should.raise(SystemExit)
|
|
936
|
+
end
|
|
937
|
+
|
|
938
|
+
it 'exits with a failing status when a target is specified' do
|
|
939
|
+
begin
|
|
940
|
+
run_command
|
|
941
|
+
rescue SystemExit => e
|
|
942
|
+
e.success?.should == false
|
|
943
|
+
end
|
|
944
|
+
end
|
|
945
|
+
end
|
|
946
|
+
end
|
|
947
|
+
|
|
948
|
+
describe 'and an unknown command is specified' do
|
|
949
|
+
before do
|
|
950
|
+
Object.send(:remove_const, :ARGV)
|
|
951
|
+
ARGV = ['frazzlebazzle']
|
|
952
|
+
end
|
|
953
|
+
|
|
954
|
+
describe 'when no target is specified' do
|
|
955
|
+
it 'exits when a target is specified' do
|
|
956
|
+
lambda { run_command }.should.raise(SystemExit)
|
|
957
|
+
end
|
|
958
|
+
|
|
959
|
+
it 'exits with a failing status when a target is specified' do
|
|
960
|
+
begin
|
|
961
|
+
run_command
|
|
962
|
+
rescue SystemExit => e
|
|
963
|
+
e.success?.should == false
|
|
964
|
+
end
|
|
965
|
+
end
|
|
966
|
+
end
|
|
967
|
+
|
|
968
|
+
describe 'when a target is specified' do
|
|
969
|
+
before do
|
|
970
|
+
ARGV.push('--to=foo')
|
|
971
|
+
end
|
|
972
|
+
|
|
973
|
+
it 'exits when a target is specified' do
|
|
974
|
+
lambda { run_command }.should.raise(SystemExit)
|
|
975
|
+
end
|
|
976
|
+
|
|
977
|
+
it 'exits with a failing status when a target is specified' do
|
|
978
|
+
begin
|
|
979
|
+
run_command
|
|
980
|
+
rescue SystemExit => e
|
|
981
|
+
e.success?.should == false
|
|
982
|
+
end
|
|
983
|
+
end
|
|
984
|
+
end
|
|
985
|
+
end
|
|
986
|
+
end
|