whiskey_disk 0.6.22 → 0.6.23
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +25 -15
- data/README.integration_specs +24 -36
- data/README.markdown +112 -96
- data/Rakefile +79 -5
- data/VERSION +1 -1
- data/lib/whiskey_disk.rb +297 -294
- data/lib/whiskey_disk/config.rb +99 -168
- 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 +1 -1
- data/lib/whiskey_disk/rake.rb +25 -22
- 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/init_spec.rb +1 -1
- data/spec/install_spec.rb +4 -4
- 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 +30 -2
- data/spec/wd_command_spec.rb +136 -136
- data/spec/wd_role_command_spec.rb +5 -5
- 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 +259 -446
- data/spec/whiskey_disk/helpers_spec.rb +51 -51
- data/spec/whiskey_disk/rake_spec.rb +80 -80
- data/spec/whiskey_disk_spec.rb +591 -562
- data/whiskey_disk.gemspec +151 -20
- metadata +151 -18
@@ -2,40 +2,40 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper.rb
|
|
2
2
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'whiskey_disk', 'helpers'))
|
3
3
|
|
4
4
|
describe 'when checking for a role during setup or deployment' do
|
5
|
-
it '
|
5
|
+
it 'accepts a role string' do
|
6
6
|
lambda { role?('web') }.should.not.raise(ArgumentError)
|
7
7
|
end
|
8
8
|
|
9
|
-
it '
|
9
|
+
it 'requires a role string' do
|
10
10
|
lambda { role? }.should.raise(ArgumentError)
|
11
11
|
end
|
12
12
|
|
13
|
-
it '
|
13
|
+
it 'returns false if the WD_ROLES environment variable is unset' do
|
14
14
|
ENV['WD_ROLES'] = nil
|
15
15
|
role?(:web).should.be.false
|
16
16
|
end
|
17
17
|
|
18
|
-
it '
|
18
|
+
it 'returns false if the WD_ROLES environment variable is empty' do
|
19
19
|
ENV['WD_ROLES'] = ''
|
20
20
|
role?(:web).should.be.false
|
21
21
|
end
|
22
22
|
|
23
|
-
it '
|
23
|
+
it 'returns true if the role, as a symbol is among the roles in the WD_ROLES env variable' do
|
24
24
|
ENV['WD_ROLES'] = 'db:web'
|
25
25
|
role?(:db).should.be.true
|
26
26
|
end
|
27
27
|
|
28
|
-
it '
|
28
|
+
it 'returns true if the role, as a string is among the roles in the WD_ROLES env variable' do
|
29
29
|
ENV['WD_ROLES'] = 'db:web'
|
30
30
|
role?('db').should.be.true
|
31
31
|
end
|
32
32
|
|
33
|
-
it '
|
33
|
+
it 'returns false if the role, as a symbol is not among the roles in the WD_ROLES env variable' do
|
34
34
|
ENV['WD_ROLES'] = 'db:web'
|
35
35
|
role?(:app).should.be.false
|
36
36
|
end
|
37
37
|
|
38
|
-
it '
|
38
|
+
it 'returns false if the role, as a string is not among the roles in the WD_ROLES env variable' do
|
39
39
|
ENV['WD_ROLES'] = 'db:web'
|
40
40
|
role?('app').should.be.false
|
41
41
|
end
|
@@ -61,70 +61,70 @@ describe 'when determining if certain files changed when a deployment was run' d
|
|
61
61
|
set_rsync_changes([])
|
62
62
|
end
|
63
63
|
|
64
|
-
it '
|
64
|
+
it 'accepts a path' do
|
65
65
|
lambda { changed?('foo') }.should.not.raise(ArgumentError)
|
66
66
|
end
|
67
67
|
|
68
|
-
it '
|
68
|
+
it 'requires a path' do
|
69
69
|
lambda { changed? }.should.raise(ArgumentError)
|
70
70
|
end
|
71
71
|
|
72
|
-
it '
|
72
|
+
it 'returns true when the specified file is in the list of git changes' do
|
73
73
|
set_git_changes([ @matching_file, @random_file])
|
74
74
|
changed?(@matching_file).should.be.true
|
75
75
|
end
|
76
76
|
|
77
|
-
it '
|
77
|
+
it 'ignores trailing "/"s in the provided path when doing an exact git change match' do
|
78
78
|
set_git_changes([ @matching_file, @random_file])
|
79
79
|
changed?(@matching_file + '///').should.be.true
|
80
80
|
end
|
81
81
|
|
82
|
-
it '
|
82
|
+
it 'returns true when the specified path is a full path prefix in the list of git changes' do
|
83
83
|
set_git_changes([ @matching_file , @random_file])
|
84
84
|
changed?(@matching_path).should.be.true
|
85
85
|
end
|
86
86
|
|
87
|
-
it '
|
87
|
+
it 'ignores trailing "/"s in the provided path when doing a path git change match' do
|
88
88
|
set_git_changes([ @matching_file , @random_file])
|
89
89
|
changed?(@matching_path + '///').should.be.true
|
90
90
|
end
|
91
91
|
|
92
|
-
it '
|
92
|
+
it 'returns true when the specified file is in the list of rsync changes' do
|
93
93
|
set_rsync_changes([ @matching_file, @random_file])
|
94
94
|
changed?(@matching_file).should.be.true
|
95
95
|
end
|
96
96
|
|
97
|
-
it '
|
97
|
+
it 'ignores trailing "/"s in the provided path when doing an exact rsync change match' do
|
98
98
|
set_rsync_changes([ @matching_file, @random_file])
|
99
99
|
changed?(@matching_file + "///").should.be.true
|
100
100
|
end
|
101
101
|
|
102
|
-
it '
|
102
|
+
it 'returnes true when the specified path is a full path prefix in the list of git changes' do
|
103
103
|
set_rsync_changes([ @matching_file , @random_file])
|
104
104
|
changed?(@matching_path).should.be.true
|
105
105
|
end
|
106
106
|
|
107
|
-
it '
|
107
|
+
it 'ignores trailing "/"s in the provided path when doing a path rsync change match' do
|
108
108
|
set_rsync_changes([ @matching_file , @random_file])
|
109
109
|
changed?(@matching_path + '///').should.be.true
|
110
110
|
end
|
111
111
|
|
112
|
-
it '
|
112
|
+
it 'ignores regex metacharacters when looking for a git match' do
|
113
113
|
set_git_changes([ '/path/to/somestring'])
|
114
114
|
changed?('/path/to/some.*').should.be.false
|
115
115
|
end
|
116
116
|
|
117
|
-
it '
|
117
|
+
it 'ignores regex metacharacters when looking for an rsync match' do
|
118
118
|
set_rsync_changes([ '/path/to/somestring'])
|
119
119
|
changed?('/path/to/some.*').should.be.false
|
120
120
|
end
|
121
121
|
|
122
|
-
it '
|
122
|
+
it 'returns true when the git changes file cannot be found' do
|
123
123
|
set_git_changes(nil)
|
124
124
|
changed?(@matching_file).should.be.true
|
125
125
|
end
|
126
126
|
|
127
|
-
it '
|
127
|
+
it 'returns false if not path or file matches the specified file' do
|
128
128
|
set_git_changes([@matching_file, @matching_path, @random_file, @substring_file])
|
129
129
|
set_rsync_changes([@matching_file, @matching_path, @random_file, @substring_file])
|
130
130
|
changed?(@non_matching_file).should.be.false
|
@@ -156,30 +156,30 @@ whiskey_disk.gemspec
|
|
156
156
|
'
|
157
157
|
end
|
158
158
|
|
159
|
-
it '
|
159
|
+
it 'works without arguments' do
|
160
160
|
lambda { git_changes }.should.not.raise(ArgumentError)
|
161
161
|
end
|
162
162
|
|
163
|
-
it '
|
163
|
+
it 'does not allow arguments' do
|
164
164
|
lambda { git_changes(:foo) }.should.raise(ArgumentError)
|
165
165
|
end
|
166
166
|
|
167
|
-
it '
|
167
|
+
it 'returns nil when a git changes file cannot be found' do
|
168
168
|
self.stub!(:read_git_changes_file).and_raise
|
169
169
|
git_changes.should.be.nil
|
170
170
|
end
|
171
171
|
|
172
|
-
it '
|
172
|
+
it 'returns an empty list if no files are found in the git changes file' do
|
173
173
|
self.stub!(:read_git_changes_file).and_return('')
|
174
174
|
git_changes.should == []
|
175
175
|
end
|
176
176
|
|
177
|
-
it '
|
177
|
+
it 'returns a list of all filenames mentioned in the git changes file' do
|
178
178
|
self.stub!(:read_git_changes_file).and_return(@contents)
|
179
179
|
git_changes.should == @contents.split("\n")
|
180
180
|
end
|
181
181
|
|
182
|
-
it '
|
182
|
+
it 'strips duplicates from filenames mentioned in the git changes file' do
|
183
183
|
lines = @contents.split("\n")
|
184
184
|
duplicates = @contents + lines.first + "\n" + lines.last + "\n"
|
185
185
|
self.stub!(:read_git_changes_file).and_return(duplicates)
|
@@ -298,25 +298,25 @@ describe "when finding files changed by rsync in a deployment" do
|
|
298
298
|
]
|
299
299
|
end
|
300
300
|
|
301
|
-
it '
|
301
|
+
it 'works without arguments' do
|
302
302
|
lambda { rsync_changes }.should.not.raise(ArgumentError)
|
303
303
|
end
|
304
304
|
|
305
|
-
it '
|
305
|
+
it 'does not allow arguments' do
|
306
306
|
lambda { rsync_changes(:foo) }.should.raise(ArgumentError)
|
307
307
|
end
|
308
308
|
|
309
|
-
it '
|
309
|
+
it 'returns nil when an rsync changes file cannot be found' do
|
310
310
|
self.stub!(:read_rsync_changes_file).and_raise
|
311
311
|
rsync_changes.should.be.nil
|
312
312
|
end
|
313
313
|
|
314
|
-
it '
|
314
|
+
it 'returns an empty list if no files are found in the rsync changes file' do
|
315
315
|
self.stub!(:read_rsync_changes_file).and_return('')
|
316
316
|
rsync_changes.should == []
|
317
317
|
end
|
318
318
|
|
319
|
-
it '
|
319
|
+
it 'returns a list of all changed filenames mentioned in the rsync changes file, excluding "."' do
|
320
320
|
self.stub!(:read_rsync_changes_file).and_return(@contents)
|
321
321
|
rsync_changes.sort.first.should == @changes.sort.first
|
322
322
|
end
|
@@ -330,15 +330,15 @@ describe 'when reading the git-related changes for a deployment' do
|
|
330
330
|
File.stub!(:read).with(@changes_path).and_return(@contents)
|
331
331
|
end
|
332
332
|
|
333
|
-
it '
|
333
|
+
it 'works without arguments' do
|
334
334
|
lambda { read_git_changes_file }.should.not.raise(ArgumentError)
|
335
335
|
end
|
336
336
|
|
337
|
-
it '
|
337
|
+
it 'does not allow arguments' do
|
338
338
|
lambda { read_git_changes_file(:foo) }.should.raise(ArgumentError)
|
339
339
|
end
|
340
340
|
|
341
|
-
it '
|
341
|
+
it 'reads the git changes file' do
|
342
342
|
File.should.receive(:read) do |arg|
|
343
343
|
arg.should == @changes_path
|
344
344
|
@contents
|
@@ -346,11 +346,11 @@ describe 'when reading the git-related changes for a deployment' do
|
|
346
346
|
read_git_changes_file
|
347
347
|
end
|
348
348
|
|
349
|
-
it '
|
349
|
+
it 'returns the contents of the git changes file' do
|
350
350
|
read_git_changes_file.should == @contents
|
351
351
|
end
|
352
352
|
|
353
|
-
it '
|
353
|
+
it 'fails if the git changes file cannot be read' do
|
354
354
|
File.stub!(:read).with(@changes_path).and_raise(Errno::ENOENT)
|
355
355
|
lambda { read_git_changes_file }.should.raise(Errno::ENOENT)
|
356
356
|
end
|
@@ -364,15 +364,15 @@ describe 'when reading the rsync-related changes for a deployment' do
|
|
364
364
|
File.stub!(:read).with(@changes_path).and_return(@contents)
|
365
365
|
end
|
366
366
|
|
367
|
-
it '
|
367
|
+
it 'works without arguments' do
|
368
368
|
lambda { read_rsync_changes_file }.should.not.raise(ArgumentError)
|
369
369
|
end
|
370
370
|
|
371
|
-
it '
|
371
|
+
it 'does not allow arguments' do
|
372
372
|
lambda { read_rsync_changes_file(:foo) }.should.raise(ArgumentError)
|
373
373
|
end
|
374
374
|
|
375
|
-
it '
|
375
|
+
it 'reads the rsync changes file' do
|
376
376
|
File.should.receive(:read) do |arg|
|
377
377
|
arg.should == @changes_path
|
378
378
|
@contents
|
@@ -380,11 +380,11 @@ describe 'when reading the rsync-related changes for a deployment' do
|
|
380
380
|
read_rsync_changes_file
|
381
381
|
end
|
382
382
|
|
383
|
-
it '
|
383
|
+
it 'returns the contents of the rsync changes file' do
|
384
384
|
read_rsync_changes_file.should == @contents
|
385
385
|
end
|
386
386
|
|
387
|
-
it '
|
387
|
+
it 'fails if the rsync changes file cannot be read' do
|
388
388
|
File.stub!(:read).with(@changes_path).and_raise(Errno::ENOENT)
|
389
389
|
lambda { read_rsync_changes_file }.should.raise(Errno::ENOENT)
|
390
390
|
end
|
@@ -398,19 +398,19 @@ describe 'computing the path to the git changes file' do
|
|
398
398
|
@io_handle.stub!(:read).and_return(@git_path + "\n")
|
399
399
|
end
|
400
400
|
|
401
|
-
it '
|
401
|
+
it 'works without arguments' do
|
402
402
|
lambda { git_changes_path }.should.not.raise(ArgumentError)
|
403
403
|
end
|
404
404
|
|
405
|
-
it '
|
405
|
+
it 'does not allow arguments' do
|
406
406
|
lambda { git_changes_path(:foo) }.should.raise(ArgumentError)
|
407
407
|
end
|
408
408
|
|
409
|
-
it '
|
409
|
+
it 'returns the path to the .whiskey_disk_git_changes file in the git top-level path' do
|
410
410
|
git_changes_path.should == File.join(@git_path, '.whiskey_disk_git_changes')
|
411
411
|
end
|
412
412
|
|
413
|
-
it '
|
413
|
+
it 'returns the path to the .whiskey_disk_git_changes file in the current directory of the git top-level cannot be found' do
|
414
414
|
@io_handle.stub!(:read).and_return('')
|
415
415
|
git_changes_path.should == File.join(Dir.pwd, '.whiskey_disk_git_changes')
|
416
416
|
end
|
@@ -424,19 +424,19 @@ describe 'computing the path to the rsync changes file' do
|
|
424
424
|
@io_handle.stub!(:read).and_return(@rsync_path + "\n")
|
425
425
|
end
|
426
426
|
|
427
|
-
it '
|
427
|
+
it 'works without arguments' do
|
428
428
|
lambda { rsync_changes_path }.should.not.raise(ArgumentError)
|
429
429
|
end
|
430
430
|
|
431
|
-
it '
|
431
|
+
it 'does not allow arguments' do
|
432
432
|
lambda { rsync_changes_path(:foo) }.should.raise(ArgumentError)
|
433
433
|
end
|
434
434
|
|
435
|
-
it '
|
435
|
+
it 'returns the path to the .whiskey_disk_rsync_changes file in the git top-level path' do
|
436
436
|
rsync_changes_path.should == File.join(@rsync_path, '.whiskey_disk_rsync_changes')
|
437
437
|
end
|
438
438
|
|
439
|
-
it '
|
439
|
+
it 'returns the path to the .whiskey_disk_rsync_changes file in the current directory of the git top-level cannot be found' do
|
440
440
|
@io_handle.stub!(:read).and_return('')
|
441
441
|
rsync_changes_path.should == File.join(Dir.pwd, '.whiskey_disk_rsync_changes')
|
442
442
|
end
|
@@ -5,7 +5,8 @@ describe 'rake tasks' do
|
|
5
5
|
before do
|
6
6
|
Rake.application = @rake = Rake::Application.new
|
7
7
|
load File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'whiskey_disk', 'rake.rb'))
|
8
|
-
WhiskeyDisk.
|
8
|
+
@whiskey_disk = WhiskeyDisk.new
|
9
|
+
WhiskeyDisk.stub!(:new).and_return(@whiskey_disk)
|
9
10
|
end
|
10
11
|
|
11
12
|
after do
|
@@ -14,7 +15,7 @@ describe 'rake tasks' do
|
|
14
15
|
|
15
16
|
describe 'deploy:setup' do
|
16
17
|
before do
|
17
|
-
|
18
|
+
@whiskey_disk.configuration = {}
|
18
19
|
[
|
19
20
|
:ensure_main_parent_path_is_present,
|
20
21
|
:ensure_config_parent_path_is_present,
|
@@ -29,122 +30,121 @@ describe 'rake tasks' do
|
|
29
30
|
:flush,
|
30
31
|
:summarize
|
31
32
|
].each do |meth|
|
32
|
-
|
33
|
+
@whiskey_disk.stub!(meth)
|
33
34
|
end
|
34
35
|
|
35
|
-
|
36
|
+
@whiskey_disk.stub!(:success?).and_return(true)
|
36
37
|
end
|
37
38
|
|
38
|
-
it '
|
39
|
-
|
39
|
+
it 'ensures that the parent path for the main repository checkout is present' do
|
40
|
+
@whiskey_disk.should.receive(:ensure_main_parent_path_is_present)
|
40
41
|
@rake["deploy:setup"].invoke
|
41
42
|
end
|
42
43
|
|
43
44
|
describe 'when a configuration repo is specified' do
|
44
|
-
it '
|
45
|
-
|
46
|
-
|
45
|
+
it 'ensures that the parent path for the configuration repository checkout is present' do
|
46
|
+
@whiskey_disk.configuration = { 'config_repository' => 'foo' }
|
47
|
+
@whiskey_disk.should.receive(:ensure_config_parent_path_is_present)
|
47
48
|
@rake["deploy:setup"].invoke
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
51
52
|
describe 'when no configuration repo is specified' do
|
52
|
-
it '
|
53
|
-
|
53
|
+
it 'does not ensure that the path for the configuration repository checkout is present' do
|
54
|
+
@whiskey_disk.should.not.receive(:ensure_config_parent_path_is_present)
|
54
55
|
@rake["deploy:setup"].invoke
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
58
|
-
it '
|
59
|
-
|
59
|
+
it 'checks out the main repository' do
|
60
|
+
@whiskey_disk.should.receive(:checkout_main_repository)
|
60
61
|
@rake["deploy:setup"].invoke
|
61
62
|
end
|
62
63
|
|
63
64
|
describe 'when a configuration repository is specified' do
|
64
|
-
it '
|
65
|
-
|
66
|
-
|
65
|
+
it 'checks out the configuration repository' do
|
66
|
+
@whiskey_disk.configuration = { 'config_repository' => 'foo' }
|
67
|
+
@whiskey_disk.should.receive(:checkout_configuration_repository)
|
67
68
|
@rake["deploy:setup"].invoke
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
71
72
|
describe 'when no configuration repository is specified' do
|
72
|
-
it '
|
73
|
-
|
73
|
+
it 'does not check out the configuration repository' do
|
74
|
+
@whiskey_disk.should.not.receive(:checkout_configuration_repository)
|
74
75
|
@rake["deploy:setup"].invoke
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
78
|
-
it '
|
79
|
-
|
79
|
+
it 'updates the main repository checkout' do
|
80
|
+
@whiskey_disk.should.receive(:update_main_repository_checkout)
|
80
81
|
@rake["deploy:setup"].invoke
|
81
82
|
end
|
82
83
|
|
83
84
|
describe 'when a configuration repository is specified' do
|
84
|
-
it '
|
85
|
-
|
86
|
-
|
85
|
+
it 'updates the configuration repository checkout' do
|
86
|
+
@whiskey_disk.configuration = { 'config_repository' => 'foo' }
|
87
|
+
@whiskey_disk.should.receive(:update_configuration_repository_checkout)
|
87
88
|
@rake["deploy:setup"].invoke
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
|
-
it '
|
92
|
-
|
92
|
+
it 'clears any tracked git or rsync changes' do
|
93
|
+
@whiskey_disk.should.receive(:initialize_all_changes)
|
93
94
|
@rake["deploy:setup"].invoke
|
94
95
|
end
|
95
96
|
|
96
97
|
describe 'when no configuration repository is specified' do
|
97
|
-
it '
|
98
|
-
|
98
|
+
it 'updates the configuration repository checkout' do
|
99
|
+
@whiskey_disk.should.not.receive(:update_configuration_repository_checkout)
|
99
100
|
@rake["deploy:setup"].invoke
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
103
104
|
describe 'when a configuration repository is specified' do
|
104
|
-
it '
|
105
|
-
|
106
|
-
|
105
|
+
it 'refreshes the configuration' do
|
106
|
+
@whiskey_disk.configuration = { 'config_repository' => 'foo' }
|
107
|
+
@whiskey_disk.should.receive(:refresh_configuration)
|
107
108
|
@rake["deploy:setup"].invoke
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
111
112
|
describe 'when no configuration repository is specified' do
|
112
|
-
it '
|
113
|
-
|
113
|
+
it 'does not refresh the configuration' do
|
114
|
+
@whiskey_disk.should.not.receive(:refresh_configuration)
|
114
115
|
@rake["deploy:setup"].invoke
|
115
116
|
end
|
116
117
|
end
|
117
118
|
|
118
|
-
it '
|
119
|
-
|
119
|
+
it 'runs any post setup hooks' do
|
120
|
+
@whiskey_disk.should.receive(:run_post_setup_hooks)
|
120
121
|
@rake["deploy:setup"].invoke
|
121
122
|
end
|
122
123
|
|
123
|
-
it '
|
124
|
-
|
124
|
+
it 'flushes @whiskey_disk changes' do
|
125
|
+
@whiskey_disk.should.receive(:flush)
|
125
126
|
@rake["deploy:setup"].invoke
|
126
127
|
end
|
127
128
|
|
128
|
-
it '
|
129
|
-
|
129
|
+
it 'summarizes the results of the setup run' do
|
130
|
+
@whiskey_disk.should.receive(:summarize)
|
130
131
|
@rake["deploy:setup"].invoke
|
131
132
|
end
|
132
133
|
|
133
|
-
it '
|
134
|
+
it 'does not exit in error if all setup runs were successful' do
|
134
135
|
lambda { @rake["deploy:setup"].invoke }.should.not.raise(SystemExit)
|
135
136
|
end
|
136
137
|
|
137
|
-
it '
|
138
|
-
|
138
|
+
it 'exits in error if some setup run was unsuccessful' do
|
139
|
+
@whiskey_disk.stub!(:success?).and_return(false)
|
139
140
|
lambda { @rake["deploy:setup"].invoke }.should.raise(SystemExit)
|
140
141
|
end
|
141
142
|
end
|
142
143
|
|
143
144
|
describe 'deploy:now' do
|
144
145
|
before do
|
145
|
-
|
146
|
+
@whiskey_disk.configuration = { }
|
146
147
|
[
|
147
|
-
:enable_staleness_checks,
|
148
148
|
:update_main_repository_checkout,
|
149
149
|
:update_configuration_repository_checkout,
|
150
150
|
:refresh_configuration,
|
@@ -152,109 +152,109 @@ describe 'rake tasks' do
|
|
152
152
|
:flush,
|
153
153
|
:summarize
|
154
154
|
].each do |meth|
|
155
|
-
|
155
|
+
@whiskey_disk.stub!(meth)
|
156
156
|
end
|
157
157
|
|
158
|
-
|
158
|
+
@whiskey_disk.stub!(:success?).and_return(true)
|
159
159
|
end
|
160
160
|
|
161
|
-
it '
|
162
|
-
WhiskeyDisk.should.receive(:
|
161
|
+
it 'enables staleness checks' do
|
162
|
+
WhiskeyDisk.should.receive(:new).with(:staleness_checks => true).and_return(@whiskey_disk)
|
163
163
|
@rake["deploy:now"].invoke
|
164
164
|
end
|
165
165
|
|
166
|
-
it '
|
167
|
-
|
166
|
+
it 'updates the main repository checkout' do
|
167
|
+
@whiskey_disk.should.receive(:update_main_repository_checkout)
|
168
168
|
@rake["deploy:now"].invoke
|
169
169
|
end
|
170
170
|
|
171
171
|
describe 'when a configuration repository is specified' do
|
172
|
-
it '
|
173
|
-
|
174
|
-
|
172
|
+
it 'updates the configuration repository checkout' do
|
173
|
+
@whiskey_disk.configuration = { 'config_repository' => 'foo' }
|
174
|
+
@whiskey_disk.should.receive(:update_configuration_repository_checkout)
|
175
175
|
@rake["deploy:now"].invoke
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
179
|
describe 'when no configuration repository is specified' do
|
180
|
-
it '
|
181
|
-
|
180
|
+
it 'does not update the configuration repository checkout' do
|
181
|
+
@whiskey_disk.should.not.receive(:update_configuration_repository_checkout)
|
182
182
|
@rake["deploy:now"].invoke
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
186
|
describe 'when a configuration repository is specified' do
|
187
|
-
it '
|
188
|
-
|
189
|
-
|
187
|
+
it 'refreshes the configuration' do
|
188
|
+
@whiskey_disk.configuration = { 'config_repository' => 'foo' }
|
189
|
+
@whiskey_disk.should.receive(:refresh_configuration)
|
190
190
|
@rake["deploy:now"].invoke
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
194
|
describe 'when no configuration repository is specified' do
|
195
|
-
it '
|
196
|
-
|
195
|
+
it 'does not refresh the configuration' do
|
196
|
+
@whiskey_disk.should.not.receive(:refresh_configuration)
|
197
197
|
@rake["deploy:now"].invoke
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
201
|
-
it '
|
202
|
-
|
201
|
+
it 'runs any post deployment hooks' do
|
202
|
+
@whiskey_disk.should.receive(:run_post_deploy_hooks)
|
203
203
|
@rake["deploy:now"].invoke
|
204
204
|
end
|
205
205
|
|
206
|
-
it '
|
207
|
-
|
206
|
+
it 'flushes @whiskey_disk changes' do
|
207
|
+
@whiskey_disk.should.receive(:flush)
|
208
208
|
@rake["deploy:now"].invoke
|
209
209
|
end
|
210
210
|
|
211
|
-
it '
|
212
|
-
|
211
|
+
it 'summarizes the results of the deployment run' do
|
212
|
+
@whiskey_disk.should.receive(:summarize)
|
213
213
|
@rake["deploy:now"].invoke
|
214
214
|
end
|
215
215
|
|
216
|
-
it '
|
216
|
+
it 'does not exit in error if all deployment runs were successful' do
|
217
217
|
lambda { @rake["deploy:now"].invoke }.should.not.raise(SystemExit)
|
218
218
|
end
|
219
219
|
|
220
|
-
it '
|
221
|
-
|
220
|
+
it 'exits in error if some deployment run was unsuccessful' do
|
221
|
+
@whiskey_disk.stub!(:success?).and_return(false)
|
222
222
|
lambda { @rake["deploy:now"].invoke }.should.raise(SystemExit)
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
226
226
|
describe 'deploy:post_setup' do
|
227
|
-
it '
|
228
|
-
|
227
|
+
it 'runs the defined post_setup rake task when a post_setup rake task is defined for this environment' do
|
228
|
+
@whiskey_disk.configuration = { 'environment' => 'production'}
|
229
229
|
|
230
230
|
task "deploy:production:post_setup" do
|
231
|
-
|
231
|
+
@whiskey_disk.fake_method
|
232
232
|
end
|
233
233
|
|
234
|
-
|
234
|
+
@whiskey_disk.should.receive(:fake_method)
|
235
235
|
Rake::Task['deploy:post_setup'].invoke
|
236
236
|
end
|
237
237
|
|
238
|
-
it '
|
239
|
-
|
238
|
+
it 'does not fail when no post_setup rake task is defined for this environment' do
|
239
|
+
@whiskey_disk.configuration = { 'environment' => 'staging'}
|
240
240
|
lambda { Rake::Task['deploy:post_setup'].invoke }.should.not.raise
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
244
244
|
describe 'deploy:post_deploy' do
|
245
|
-
it '
|
246
|
-
|
245
|
+
it 'runs the defined post_deploy rake task when a post_deploy rake task is defined for this environment' do
|
246
|
+
@whiskey_disk.configuration = { 'environment' => 'production'}
|
247
247
|
|
248
248
|
task "deploy:production:post_deploy" do
|
249
|
-
|
249
|
+
@whiskey_disk.fake_method
|
250
250
|
end
|
251
251
|
|
252
|
-
|
252
|
+
@whiskey_disk.should.receive(:fake_method)
|
253
253
|
Rake::Task['deploy:post_deploy'].invoke
|
254
254
|
end
|
255
255
|
|
256
|
-
it '
|
257
|
-
|
256
|
+
it 'does not fail when no post_deploy rake task is defined for this environment' do
|
257
|
+
@whiskey_disk.configuration = { 'environment' => 'staging'}
|
258
258
|
lambda { Rake::Task['deploy:post_deploy'].invoke }.should.not.raise
|
259
259
|
end
|
260
260
|
end
|