dump 1.0.3 → 1.0.4
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.
- checksums.yaml +9 -9
- data/.travis.yml +9 -6
- data/Gemfile +5 -1
- data/LICENSE.txt +1 -1
- data/README.markdown +7 -5
- data/dump.gemspec +2 -2
- data/lib/dump_rake/dump_reader.rb +2 -0
- data/spec/.tmignore +1 -0
- data/spec/cycle_spec.rb +22 -16
- data/spec/dummy-4.1/.gitignore +16 -0
- data/spec/dummy-4.1/config.ru +4 -0
- data/spec/dummy-4.1/config/application.rb +30 -0
- data/spec/dummy-4.1/config/boot.rb +4 -0
- data/spec/dummy-4.1/config/database.yml +25 -0
- data/spec/dummy-4.1/config/environment.rb +5 -0
- data/spec/dummy-4.1/config/environments/development.rb +28 -0
- data/spec/dummy-4.1/config/environments/production.rb +67 -0
- data/spec/dummy-4.1/config/environments/test.rb +39 -0
- data/spec/dummy-4.1/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy-4.1/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy-4.1/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy-4.1/config/initializers/inflections.rb +16 -0
- data/spec/dummy-4.1/config/initializers/mime_types.rb +4 -0
- data/spec/dummy-4.1/config/initializers/session_store.rb +3 -0
- data/spec/dummy-4.1/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy-4.1/config/locales/en.yml +23 -0
- data/spec/dummy-4.1/config/routes.rb +56 -0
- data/spec/dummy-4.1/config/secrets.yml +22 -0
- data/spec/dummy-4.1/db/seeds.rb +7 -0
- data/spec/dummy-4.1/log/.keep +0 -0
- data/spec/lib/dump_rake/dump_reader_spec.rb +223 -181
- data/spec/lib/dump_rake/dump_spec.rb +78 -78
- data/spec/lib/dump_rake/dump_writer_spec.rb +110 -110
- data/spec/lib/dump_rake/env/filter_spec.rb +24 -24
- data/spec/lib/dump_rake/env_spec.rb +33 -33
- data/spec/lib/dump_rake/rails_root_spec.rb +6 -6
- data/spec/lib/dump_rake/table_manipulation_spec.rb +60 -60
- data/spec/lib/dump_rake_spec.rb +93 -93
- data/spec/recipes/dump_spec.rb +128 -128
- data/spec/tasks/assets_spec.rb +18 -18
- data/spec/tasks/dump_spec.rb +9 -9
- metadata +49 -7
data/spec/lib/dump_rake_spec.rb
CHANGED
@@ -3,32 +3,32 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
3
3
|
describe DumpRake do
|
4
4
|
describe "versions" do
|
5
5
|
it "should call Dump.list if called without version" do
|
6
|
-
DumpRake::Dump.
|
6
|
+
expect(DumpRake::Dump).to receive(:list).and_return([])
|
7
7
|
DumpRake.versions
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should call Dump.list with options if called with version" do
|
11
|
-
DumpRake::Dump.
|
11
|
+
expect(DumpRake::Dump).to receive(:list).with(:like => '123').and_return([])
|
12
12
|
DumpRake.versions(:like => '123')
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should print versions" do
|
16
|
-
DumpRake::Dump.
|
17
|
-
grab_output{
|
16
|
+
expect(DumpRake::Dump).to receive(:list).and_return(%w[123.tgz 456.tgz])
|
17
|
+
expect(grab_output{
|
18
18
|
DumpRake.versions
|
19
|
-
}[:stdout].
|
19
|
+
}[:stdout]).to eq("123.tgz\n456.tgz\n")
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should not show summary if not asked for" do
|
23
23
|
dumps = %w[123.tgz 456.tgz].map do |s|
|
24
24
|
dump = double("dump_#{s}", :path => double("dump_#{s}_path"))
|
25
|
-
DumpRake::DumpReader.
|
25
|
+
expect(DumpRake::DumpReader).not_to receive(:summary)
|
26
26
|
dump
|
27
27
|
end
|
28
28
|
|
29
|
-
DumpRake::Dump.
|
29
|
+
expect(DumpRake::Dump).to receive(:list).and_return(dumps)
|
30
30
|
grab_output{
|
31
|
-
$stderr.
|
31
|
+
expect($stderr).not_to receive(:puts)
|
32
32
|
DumpRake.versions
|
33
33
|
}
|
34
34
|
end
|
@@ -36,13 +36,13 @@ describe DumpRake do
|
|
36
36
|
it "should show summary if asked for" do
|
37
37
|
dumps = %w[123.tgz 456.tgz].map do |s|
|
38
38
|
dump = double("dump_#{s}", :path => double("dump_#{s}_path"))
|
39
|
-
DumpRake::DumpReader.
|
39
|
+
expect(DumpRake::DumpReader).to receive(:summary).with(dump.path)
|
40
40
|
dump
|
41
41
|
end
|
42
42
|
|
43
|
-
DumpRake::Dump.
|
43
|
+
expect(DumpRake::Dump).to receive(:list).and_return(dumps)
|
44
44
|
grab_output{
|
45
|
-
$stderr.
|
45
|
+
expect($stderr).not_to receive(:puts)
|
46
46
|
DumpRake.versions(:summary => '1')
|
47
47
|
}
|
48
48
|
end
|
@@ -50,29 +50,29 @@ describe DumpRake do
|
|
50
50
|
it "should show summary with scmema if asked for" do
|
51
51
|
dumps = %w[123.tgz 456.tgz].map do |s|
|
52
52
|
dump = double("dump_#{s}", :path => double("dump_#{s}_path"))
|
53
|
-
DumpRake::DumpReader.
|
53
|
+
expect(DumpRake::DumpReader).to receive(:summary).with(dump.path, :schema => true)
|
54
54
|
dump
|
55
55
|
end
|
56
56
|
|
57
|
-
DumpRake::Dump.
|
57
|
+
expect(DumpRake::Dump).to receive(:list).and_return(dumps)
|
58
58
|
grab_output{
|
59
|
-
$stderr.
|
59
|
+
expect($stderr).not_to receive(:puts)
|
60
60
|
DumpRake.versions(:summary => '2')
|
61
61
|
}
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should show output to stderr if summary raises error" do
|
65
|
-
DumpRake::DumpReader.
|
65
|
+
allow(DumpRake::DumpReader).to receive(:summary)
|
66
66
|
dumps = %w[123.tgz 456.tgz].map do |s|
|
67
67
|
double("dump_#{s}", :path => double("dump_#{s}_path"))
|
68
68
|
end
|
69
|
-
DumpRake::DumpReader.
|
69
|
+
expect(DumpRake::DumpReader).to receive(:summary).with(dumps[1].path).and_raise('terrible error')
|
70
70
|
|
71
|
-
DumpRake::Dump.
|
71
|
+
expect(DumpRake::Dump).to receive(:list).and_return(dumps)
|
72
72
|
grab_output{
|
73
|
-
$stderr.
|
74
|
-
$stderr.
|
75
|
-
s['terrible error'].
|
73
|
+
allow($stderr).to receive(:puts)
|
74
|
+
expect($stderr).to receive(:puts) do |s|
|
75
|
+
expect(s['terrible error']).not_to be_nil
|
76
76
|
end
|
77
77
|
DumpRake.versions(:summary => 'true')
|
78
78
|
}
|
@@ -82,9 +82,9 @@ describe DumpRake do
|
|
82
82
|
describe "create" do
|
83
83
|
describe "naming" do
|
84
84
|
it "should create file in 'rails app root'/dump" do
|
85
|
-
File.
|
86
|
-
DumpRake::DumpWriter.
|
87
|
-
File.dirname(path).
|
85
|
+
allow(File).to receive(:rename)
|
86
|
+
expect(DumpRake::DumpWriter).to receive(:create) do |path|
|
87
|
+
expect(File.dirname(path)).to eq(File.join(DumpRake::RailsRoot, 'dump'))
|
88
88
|
end
|
89
89
|
grab_output{
|
90
90
|
DumpRake.create
|
@@ -92,9 +92,9 @@ describe DumpRake do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should create file with name like 'yyyymmddhhmmss.tmp' when called without description" do
|
95
|
-
File.
|
96
|
-
DumpRake::DumpWriter.
|
97
|
-
File.basename(path).
|
95
|
+
allow(File).to receive(:rename)
|
96
|
+
expect(DumpRake::DumpWriter).to receive(:create) do |path|
|
97
|
+
expect(File.basename(path)).to match(/^\d{14}\.tmp$/)
|
98
98
|
end
|
99
99
|
grab_output{
|
100
100
|
DumpRake.create
|
@@ -102,9 +102,9 @@ describe DumpRake do
|
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should create file with name like 'yyyymmddhhmmss-Some text and _.tmp' when called with description 'Some text and !@'" do
|
105
|
-
File.
|
106
|
-
DumpRake::DumpWriter.
|
107
|
-
File.basename(path).
|
105
|
+
allow(File).to receive(:rename)
|
106
|
+
expect(DumpRake::DumpWriter).to receive(:create) do |path|
|
107
|
+
expect(File.basename(path)).to match(/^\d{14}-Some text and _\.tmp$/)
|
108
108
|
end
|
109
109
|
grab_output{
|
110
110
|
DumpRake.create(:desc => 'Some text and !@')
|
@@ -112,9 +112,9 @@ describe DumpRake do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
it "should create file with name like 'yyyymmddhhmmss@super tag,second.tmp' when called with description 'Some text and !@'" do
|
115
|
-
File.
|
116
|
-
DumpRake::DumpWriter.
|
117
|
-
File.basename(path).
|
115
|
+
allow(File).to receive(:rename)
|
116
|
+
expect(DumpRake::DumpWriter).to receive(:create) do |path|
|
117
|
+
expect(File.basename(path)).to match(/^\d{14}-Some text and _\.tmp$/)
|
118
118
|
end
|
119
119
|
grab_output{
|
120
120
|
DumpRake.create(:desc => 'Some text and !@')
|
@@ -122,30 +122,30 @@ describe DumpRake do
|
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should rename file after creating" do
|
125
|
-
File.
|
126
|
-
File.basename(tmp_path).
|
127
|
-
File.basename(tgz_path).
|
125
|
+
expect(File).to receive(:rename) do |tmp_path, tgz_path|
|
126
|
+
expect(File.basename(tmp_path)).to match(/^\d{14}-Some text and _\.tmp$/)
|
127
|
+
expect(File.basename(tgz_path)).to match(/^\d{14}-Some text and _\.tgz$/)
|
128
128
|
end
|
129
|
-
DumpRake::DumpWriter.
|
129
|
+
allow(DumpRake::DumpWriter).to receive(:create)
|
130
130
|
grab_output{
|
131
131
|
DumpRake.create(:desc => 'Some text and !@')
|
132
132
|
}
|
133
133
|
end
|
134
134
|
|
135
135
|
it "should output file name" do
|
136
|
-
File.
|
137
|
-
DumpRake::DumpWriter.
|
138
|
-
grab_output{
|
136
|
+
allow(File).to receive(:rename)
|
137
|
+
allow(DumpRake::DumpWriter).to receive(:create)
|
138
|
+
expect(grab_output{
|
139
139
|
DumpRake.create(:desc => 'Some text and !@')
|
140
|
-
}[:stdout].
|
140
|
+
}[:stdout]).to match(/^\d{14}-Some text and _\.tgz$/)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
144
|
describe "writing" do
|
145
145
|
it "should dump schema, tables, assets" do
|
146
|
-
File.
|
146
|
+
allow(File).to receive(:rename)
|
147
147
|
@dump = double('dump')
|
148
|
-
DumpRake::DumpWriter.
|
148
|
+
expect(DumpRake::DumpWriter).to receive(:create)
|
149
149
|
|
150
150
|
grab_output{
|
151
151
|
DumpRake.create
|
@@ -157,43 +157,43 @@ describe DumpRake do
|
|
157
157
|
describe "restore" do
|
158
158
|
describe "without version" do
|
159
159
|
it "should call Dump.list" do
|
160
|
-
DumpRake::Dump.
|
161
|
-
DumpRake::Dump.
|
160
|
+
allow(DumpRake::Dump).to receive(:list)
|
161
|
+
expect(DumpRake::Dump).to receive(:list).and_return([])
|
162
162
|
grab_output{
|
163
163
|
DumpRake.restore
|
164
164
|
}
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should not call DumpReader.restore and should call Dump.list and output it to $stderr if there are no versions at all" do
|
168
|
-
DumpRake::Dump.
|
169
|
-
DumpRake::DumpReader.
|
168
|
+
allow(DumpRake::Dump).to receive(:list).and_return([])
|
169
|
+
expect(DumpRake::DumpReader).not_to receive(:restore)
|
170
170
|
all_dumps = double('all_dumps')
|
171
|
-
DumpRake::Dump.
|
171
|
+
expect(DumpRake::Dump).to receive(:list).with(no_args).and_return(all_dumps)
|
172
172
|
grab_output{
|
173
|
-
$stderr.
|
174
|
-
$stderr.
|
173
|
+
expect($stderr).to receive(:puts).with(kind_of(String))
|
174
|
+
expect($stderr).to receive(:puts).with(all_dumps)
|
175
175
|
DumpRake.restore
|
176
176
|
}
|
177
177
|
end
|
178
178
|
|
179
179
|
it "should not call DumpReader.restore and should call Dump.list and output it to $stderr if there are no versions at all" do
|
180
|
-
DumpRake::Dump.
|
181
|
-
DumpRake::DumpReader.
|
180
|
+
allow(DumpRake::Dump).to receive(:list).and_return([])
|
181
|
+
expect(DumpRake::DumpReader).not_to receive(:restore)
|
182
182
|
all_dumps = double('all_dumps')
|
183
|
-
DumpRake::Dump.
|
183
|
+
expect(DumpRake::Dump).to receive(:list).with(no_args).and_return(all_dumps)
|
184
184
|
grab_output{
|
185
|
-
$stderr.
|
186
|
-
$stderr.
|
185
|
+
expect($stderr).to receive(:puts).with(kind_of(String))
|
186
|
+
expect($stderr).to receive(:puts).with(all_dumps)
|
187
187
|
DumpRake.restore('213')
|
188
188
|
}
|
189
189
|
end
|
190
190
|
|
191
191
|
it "should call DumpReader.restore if there are versions" do
|
192
192
|
@dump = double('dump', :path => 'dump/213.tgz')
|
193
|
-
DumpRake::Dump.
|
194
|
-
DumpRake::DumpReader.
|
193
|
+
expect(DumpRake::Dump).to receive(:list).once.and_return([@dump])
|
194
|
+
expect(DumpRake::DumpReader).to receive(:restore).with('dump/213.tgz')
|
195
195
|
grab_output{
|
196
|
-
$stderr.
|
196
|
+
expect($stderr).not_to receive(:puts)
|
197
197
|
DumpRake.restore
|
198
198
|
}
|
199
199
|
end
|
@@ -201,32 +201,32 @@ describe DumpRake do
|
|
201
201
|
|
202
202
|
describe "with version" do
|
203
203
|
it "should call Dump.list with options" do
|
204
|
-
DumpRake::Dump.
|
205
|
-
DumpRake::Dump.
|
204
|
+
allow(DumpRake::Dump).to receive(:list)
|
205
|
+
expect(DumpRake::Dump).to receive(:list).with(:like => '213').and_return([])
|
206
206
|
grab_output{
|
207
207
|
DumpRake.restore(:like => '213')
|
208
208
|
}
|
209
209
|
end
|
210
210
|
|
211
211
|
it "should not call DumpReader.restore and should call versions if desired version not found" do
|
212
|
-
DumpRake::Dump.
|
213
|
-
DumpRake::DumpReader.
|
212
|
+
allow(DumpRake::Dump).to receive(:list).and_return([])
|
213
|
+
expect(DumpRake::DumpReader).not_to receive(:restore)
|
214
214
|
all_dumps = double('all_dumps')
|
215
|
-
DumpRake::Dump.
|
215
|
+
expect(DumpRake::Dump).to receive(:list).with(no_args).and_return(all_dumps)
|
216
216
|
grab_output{
|
217
|
-
$stderr.
|
218
|
-
$stderr.
|
217
|
+
expect($stderr).to receive(:puts).with(kind_of(String))
|
218
|
+
expect($stderr).to receive(:puts).with(all_dumps)
|
219
219
|
DumpRake.restore('213')
|
220
220
|
}
|
221
221
|
end
|
222
222
|
|
223
223
|
it "should call DumpReader.restore if there is desired version" do
|
224
224
|
@dump = double('dump', :path => 'dump/213.tgz')
|
225
|
-
DumpRake::Dump.
|
226
|
-
DumpRake::DumpReader.
|
227
|
-
DumpRake.
|
225
|
+
expect(DumpRake::Dump).to receive(:list).once.and_return([@dump])
|
226
|
+
expect(DumpRake::DumpReader).to receive(:restore).with('dump/213.tgz')
|
227
|
+
expect(DumpRake).not_to receive(:versions)
|
228
228
|
grab_output{
|
229
|
-
$stderr.
|
229
|
+
expect($stderr).not_to receive(:puts)
|
230
230
|
DumpRake.restore(:like => '213')
|
231
231
|
}
|
232
232
|
end
|
@@ -234,10 +234,10 @@ describe DumpRake do
|
|
234
234
|
it "should call DumpReader.restore on last version if found multiple matching versions" do
|
235
235
|
@dump_a = double('dump_a', :path => 'dump/213-a.tgz')
|
236
236
|
@dump_b = double('dump_b', :path => 'dump/213-b.tgz')
|
237
|
-
DumpRake::Dump.
|
238
|
-
DumpRake::DumpReader.
|
237
|
+
expect(DumpRake::Dump).to receive(:list).once.and_return([@dump_a, @dump_b])
|
238
|
+
expect(DumpRake::DumpReader).to receive(:restore).with('dump/213-b.tgz')
|
239
239
|
grab_output{
|
240
|
-
$stderr.
|
240
|
+
expect($stderr).not_to receive(:puts)
|
241
241
|
DumpRake.restore(:like => '213')
|
242
242
|
}
|
243
243
|
end
|
@@ -246,14 +246,14 @@ describe DumpRake do
|
|
246
246
|
|
247
247
|
describe "cleanup" do
|
248
248
|
it "should call ask for all files in dump dir and for dumps" do
|
249
|
-
DumpRake::Dump.
|
250
|
-
DumpRake::Dump.
|
249
|
+
expect(DumpRake::Dump).to receive(:list).with(:all => true).and_return([])
|
250
|
+
expect(DumpRake::Dump).to receive(:list).with({}).and_return([])
|
251
251
|
DumpRake.cleanup
|
252
252
|
end
|
253
253
|
|
254
254
|
it "should call Dump.list with options if called with version and tags" do
|
255
|
-
DumpRake::Dump.
|
256
|
-
DumpRake::Dump.
|
255
|
+
expect(DumpRake::Dump).to receive(:list).with(:like => '123', :tags => 'a,b,c', :all => true).and_return([])
|
256
|
+
expect(DumpRake::Dump).to receive(:list).with(:like => '123', :tags => 'a,b,c').and_return([])
|
257
257
|
DumpRake.cleanup(:like => '123', :tags => 'a,b,c')
|
258
258
|
end
|
259
259
|
|
@@ -276,20 +276,20 @@ describe DumpRake do
|
|
276
276
|
all_dumps = tmp_dumps[0, 1] + dumps[0, 5] + tmp_dumps[1, 1] + dumps[5, 5] + tmp_dumps[2, 1]
|
277
277
|
|
278
278
|
(dumps.values_at(*ids) + [tmp_dumps[0], tmp_dumps[2]]).each do |dump|
|
279
|
-
dump.
|
280
|
-
dump.path.
|
279
|
+
expect(dump).to receive(:lock).and_yield
|
280
|
+
expect(dump.path).to receive(:unlink)
|
281
281
|
end
|
282
282
|
[tmp_dumps[1]].each do |dump|
|
283
|
-
dump.
|
284
|
-
dump.path.
|
283
|
+
expect(dump).to receive(:lock)
|
284
|
+
expect(dump.path).not_to receive(:unlink)
|
285
285
|
end
|
286
286
|
(dumps - dumps.values_at(*ids)).each do |dump|
|
287
|
-
dump.
|
288
|
-
dump.path.
|
287
|
+
expect(dump).not_to receive(:lock)
|
288
|
+
expect(dump.path).not_to receive(:unlink)
|
289
289
|
end
|
290
290
|
|
291
|
-
DumpRake::Dump.
|
292
|
-
DumpRake::Dump.
|
291
|
+
expect(DumpRake::Dump).to receive(:list).with(hash_including(:all => true)).and_return(all_dumps)
|
292
|
+
expect(DumpRake::Dump).to receive(:list).with(hash_not_including(:all => true)).and_return(dumps)
|
293
293
|
grab_output{
|
294
294
|
DumpRake.cleanup({:like => '123', :tags => 'a,b,c'}.merge(options))
|
295
295
|
}
|
@@ -299,28 +299,28 @@ describe DumpRake do
|
|
299
299
|
it "should print to stderr if can not delete dump" do
|
300
300
|
dumps = %w[a b c d e f g h i j].map do |s|
|
301
301
|
dump = double("dump_#{s}", :ext => 'tgz', :path => double("dump_#{s}_path"))
|
302
|
-
dump.
|
303
|
-
dump.path.
|
302
|
+
allow(dump).to receive(:lock).and_yield
|
303
|
+
allow(dump.path).to receive(:unlink)
|
304
304
|
dump
|
305
305
|
end
|
306
306
|
|
307
|
-
dumps[3].path.
|
307
|
+
expect(dumps[3].path).to receive(:unlink).and_raise('Horrible error')
|
308
308
|
|
309
|
-
DumpRake::Dump.
|
309
|
+
allow(DumpRake::Dump).to receive(:list).and_return(dumps)
|
310
310
|
grab_output{
|
311
|
-
$stderr.
|
312
|
-
$stderr.
|
313
|
-
s[dumps[3].path.to_s].
|
314
|
-
s['Horrible error'].
|
311
|
+
allow($stderr).to receive(:puts)
|
312
|
+
expect($stderr).to receive(:puts) do |s|
|
313
|
+
expect(s[dumps[3].path.to_s]).not_to be_nil
|
314
|
+
expect(s['Horrible error']).not_to be_nil
|
315
315
|
end
|
316
316
|
DumpRake.cleanup
|
317
317
|
}
|
318
318
|
end
|
319
319
|
|
320
320
|
it "should raise if called with :leave which is not a number or 'none'" do
|
321
|
-
|
321
|
+
expect{
|
322
322
|
DumpRake.cleanup(:leave => 'nothing')
|
323
|
-
}.
|
323
|
+
}.to raise_error
|
324
324
|
end
|
325
325
|
end
|
326
326
|
end
|
data/spec/recipes/dump_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe "cap dump" do
|
|
24
24
|
violated "command_string not specified" unless command_string
|
25
25
|
full_command_string = command_string
|
26
26
|
full_command_string = "cd #{@remote_path}; #{command_string}" if place == :remote
|
27
|
-
@cap.dump.
|
27
|
+
expect(@cap.dump).to receive(:"run_#{place}").with(full_command_string).and_return(options[:return_value] || '')
|
28
28
|
DumpRake::Env.with_env name => options[:value] || 'some data' do
|
29
29
|
cap_task = options[:cap_task] || "dump:#{place}:#{command}"
|
30
30
|
grab_output{ @cap.find_and_execute_task(cap_task) }
|
@@ -37,17 +37,17 @@ describe "cap dump" do
|
|
37
37
|
describe :dump_command do
|
38
38
|
|
39
39
|
it "should return escaped string" do
|
40
|
-
@cap.dump.dump_command(:hello, :rake => 'rake', 'x x' => 'a b').
|
40
|
+
expect(@cap.dump.dump_command(:hello, :rake => 'rake', 'x x' => 'a b')).to eq('rake -s dump:hello x\\ x\\=a\\ b')
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should return escaped string for complex rake invocation command" do
|
44
|
-
@cap.dump.dump_command(:hello, :rake => 'bundler exec rake', 'x x' => 'a b').
|
44
|
+
expect(@cap.dump.dump_command(:hello, :rake => 'bundler exec rake', 'x x' => 'a b')).to eq('bundler exec rake -s dump:hello x\\ x\\=a\\ b')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "do_transfer" do
|
49
49
|
before do
|
50
|
-
@cap.dump.
|
50
|
+
allow(@cap.dump).to receive(:do_transfer_via)
|
51
51
|
end
|
52
52
|
|
53
53
|
[:up, :down].each do |direction|
|
@@ -55,47 +55,47 @@ describe "cap dump" do
|
|
55
55
|
describe "if method not set" do
|
56
56
|
|
57
57
|
it "should call got_rsync?" do
|
58
|
-
@cap.dump.
|
58
|
+
expect(@cap.dump).to receive(:got_rsync?)
|
59
59
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
60
60
|
end
|
61
61
|
|
62
62
|
describe "if got_rsync?" do
|
63
63
|
it "should use rsync" do
|
64
|
-
@cap.dump.
|
65
|
-
@cap.dump.
|
64
|
+
allow(@cap.dump).to receive(:got_rsync?).and_return(true)
|
65
|
+
expect(@cap.dump).to receive(:do_transfer_via).with(:rsync, direction, 'a.tgz', 'b.tgz')
|
66
66
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should raise if rsync fails" do
|
70
|
-
@cap.dump.
|
71
|
-
@cap.dump.
|
72
|
-
|
70
|
+
allow(@cap.dump).to receive(:got_rsync?).and_return(true)
|
71
|
+
expect(@cap.dump).to receive(:do_transfer_via).with(:rsync, direction, 'a.tgz', 'b.tgz').and_raise('problem using rsync')
|
72
|
+
expect{
|
73
73
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
74
|
-
}.
|
74
|
+
}.to raise_error('problem using rsync')
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
describe "unless got_rsync?" do
|
79
79
|
it "should try sftp" do
|
80
|
-
@cap.dump.
|
81
|
-
@cap.dump.
|
80
|
+
allow(@cap.dump).to receive(:got_rsync?).and_return(false)
|
81
|
+
expect(@cap.dump).to receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz')
|
82
82
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should try scp after sftp" do
|
86
|
-
@cap.dump.
|
87
|
-
@cap.dump.
|
88
|
-
@cap.dump.
|
86
|
+
allow(@cap.dump).to receive(:got_rsync?).and_return(false)
|
87
|
+
expect(@cap.dump).to receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz').and_raise('problem using sftp')
|
88
|
+
expect(@cap.dump).to receive(:do_transfer_via).with(:scp, direction, 'a.tgz', 'b.tgz')
|
89
89
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should not rescue if scp also fails" do
|
93
|
-
@cap.dump.
|
94
|
-
@cap.dump.
|
95
|
-
@cap.dump.
|
96
|
-
|
93
|
+
allow(@cap.dump).to receive(:got_rsync?).and_return(false)
|
94
|
+
expect(@cap.dump).to receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz').and_raise('problem using sftp')
|
95
|
+
expect(@cap.dump).to receive(:do_transfer_via).with(:scp, direction, 'a.tgz', 'b.tgz').and_raise('problem using scp')
|
96
|
+
expect{
|
97
97
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
98
|
-
}.
|
98
|
+
}.to raise_error('problem using scp')
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -106,7 +106,7 @@ describe "cap dump" do
|
|
106
106
|
describe "local" do
|
107
107
|
describe "versions" do
|
108
108
|
it "should call local rake task" do
|
109
|
-
@cap.dump.
|
109
|
+
expect(@cap.dump).to receive(:run_local).with("rake -s dump:versions SHOW_SIZE\\=true").and_return('')
|
110
110
|
@cap.find_and_execute_task("dump:local:versions")
|
111
111
|
end
|
112
112
|
|
@@ -117,16 +117,16 @@ describe "cap dump" do
|
|
117
117
|
})
|
118
118
|
|
119
119
|
it "should print result of rake task" do
|
120
|
-
@cap.dump.
|
121
|
-
grab_output{
|
120
|
+
allow(@cap.dump).to receive(:run_local).and_return(" 123M\t123123.tgz\n")
|
121
|
+
expect(grab_output{
|
122
122
|
@cap.find_and_execute_task("dump:local:versions")
|
123
|
-
}[:stdout].
|
123
|
+
}[:stdout]).to eq(" 123M\t123123.tgz\n")
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
describe "cleanup" do
|
128
128
|
it "should call local rake task" do
|
129
|
-
@cap.dump.
|
129
|
+
expect(@cap.dump).to receive(:run_local).with("rake -s dump:cleanup").and_return('')
|
130
130
|
@cap.find_and_execute_task("dump:local:cleanup")
|
131
131
|
end
|
132
132
|
|
@@ -137,30 +137,30 @@ describe "cap dump" do
|
|
137
137
|
})
|
138
138
|
|
139
139
|
it "should print result of rake task" do
|
140
|
-
@cap.dump.
|
141
|
-
grab_output{
|
140
|
+
allow(@cap.dump).to receive(:run_local).and_return("123123.tgz\n")
|
141
|
+
expect(grab_output{
|
142
142
|
@cap.find_and_execute_task("dump:local:cleanup")
|
143
|
-
}[:stdout].
|
143
|
+
}[:stdout]).to eq("123123.tgz\n")
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
147
|
describe "create" do
|
148
148
|
it "should raise if dump creation fails" do
|
149
|
-
@cap.dump.
|
150
|
-
|
149
|
+
expect(@cap.dump).to receive(:run_local).with("rake -s dump:create TAGS\\=local").and_return('')
|
150
|
+
expect{
|
151
151
|
@cap.find_and_execute_task("dump:local:create")
|
152
|
-
}.
|
152
|
+
}.to raise_error('Failed creating dump')
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should call local rake task with tag local" do
|
156
|
-
@cap.dump.
|
156
|
+
expect(@cap.dump).to receive(:run_local).with("rake -s dump:create TAGS\\=local").and_return('123.tgz')
|
157
157
|
grab_output{
|
158
158
|
@cap.find_and_execute_task("dump:local:create")
|
159
159
|
}
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should call local rake task with additional tag local" do
|
163
|
-
@cap.dump.
|
163
|
+
expect(@cap.dump).to receive(:run_local).with("rake -s dump:create TAGS\\=local,photos").and_return('123.tgz')
|
164
164
|
grab_output{
|
165
165
|
DumpRake::Env.with_env :tags => 'photos' do
|
166
166
|
@cap.find_and_execute_task("dump:local:create")
|
@@ -176,23 +176,23 @@ describe "cap dump" do
|
|
176
176
|
}, :return_value => '123.tgz')
|
177
177
|
|
178
178
|
it "should print result of rake task" do
|
179
|
-
@cap.dump.
|
180
|
-
grab_output{
|
179
|
+
allow(@cap.dump).to receive(:run_local).and_return("123123.tgz\n")
|
180
|
+
expect(grab_output{
|
181
181
|
@cap.find_and_execute_task("dump:local:create")
|
182
|
-
}[:stdout].
|
182
|
+
}[:stdout]).to eq("123123.tgz\n")
|
183
183
|
end
|
184
184
|
|
185
185
|
it "should return stripped result of rake task" do
|
186
|
-
@cap.dump.
|
186
|
+
allow(@cap.dump).to receive(:run_local).and_return("123123.tgz\n")
|
187
187
|
grab_output{
|
188
|
-
@cap.find_and_execute_task("dump:local:create").
|
188
|
+
expect(@cap.find_and_execute_task("dump:local:create")).to eq("123123.tgz")
|
189
189
|
}
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
193
|
describe "restore" do
|
194
194
|
it "should call local rake task" do
|
195
|
-
@cap.dump.
|
195
|
+
expect(@cap.dump).to receive(:run_local).with("rake -s dump:restore")
|
196
196
|
@cap.find_and_execute_task("dump:local:restore")
|
197
197
|
end
|
198
198
|
|
@@ -208,7 +208,7 @@ describe "cap dump" do
|
|
208
208
|
|
209
209
|
describe "upload" do
|
210
210
|
it "should run rake versions to get avaliable versions" do
|
211
|
-
@cap.dump.
|
211
|
+
expect(@cap.dump).to receive(:run_local).with("rake -s dump:versions").and_return('')
|
212
212
|
@cap.find_and_execute_task("dump:local:upload")
|
213
213
|
end
|
214
214
|
|
@@ -220,20 +220,20 @@ describe "cap dump" do
|
|
220
220
|
}, :cap_task => 'dump:local:upload')
|
221
221
|
|
222
222
|
it "should not upload anything if there are no versions avaliable" do
|
223
|
-
@cap.dump.
|
224
|
-
@cap.dump.
|
223
|
+
allow(@cap.dump).to receive(:run_local).and_return('')
|
224
|
+
expect(@cap.dump).not_to receive(:do_transfer)
|
225
225
|
@cap.find_and_execute_task("dump:local:upload")
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should transfer latest version dump" do
|
229
|
-
@cap.dump.
|
230
|
-
@cap.dump.
|
229
|
+
allow(@cap.dump).to receive(:run_local).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
230
|
+
expect(@cap.dump).to receive(:do_transfer).with(:up, "dump/300.tgz", "#{@remote_path}/dump/300.tgz")
|
231
231
|
@cap.find_and_execute_task("dump:local:upload")
|
232
232
|
end
|
233
233
|
|
234
234
|
it "should handle extra spaces around file names" do
|
235
|
-
@cap.dump.
|
236
|
-
@cap.dump.
|
235
|
+
allow(@cap.dump).to receive(:run_local).and_return("\r\n\r\n\r 100.tgz \r\n\r\n\r 200.tgz \r\n\r\n\r 300.tgz \r\n\r\n\r ")
|
236
|
+
expect(@cap.dump).to receive(:do_transfer).with(:up, "dump/300.tgz", "#{@remote_path}/dump/300.tgz")
|
237
237
|
@cap.find_and_execute_task("dump:local:upload")
|
238
238
|
end
|
239
239
|
end
|
@@ -242,7 +242,7 @@ describe "cap dump" do
|
|
242
242
|
describe "remote" do
|
243
243
|
describe "versions" do
|
244
244
|
it "should call remote rake task" do
|
245
|
-
@cap.dump.
|
245
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production SHOW_SIZE\\=true").and_return('')
|
246
246
|
@cap.find_and_execute_task("dump:remote:versions")
|
247
247
|
end
|
248
248
|
|
@@ -253,22 +253,22 @@ describe "cap dump" do
|
|
253
253
|
})
|
254
254
|
|
255
255
|
it "should print result of rake task" do
|
256
|
-
@cap.dump.
|
257
|
-
grab_output{
|
256
|
+
allow(@cap.dump).to receive(:run_remote).and_return(" 123M\t123123.tgz\n")
|
257
|
+
expect(grab_output{
|
258
258
|
@cap.find_and_execute_task("dump:remote:versions")
|
259
|
-
}[:stdout].
|
259
|
+
}[:stdout]).to eq(" 123M\t123123.tgz\n")
|
260
260
|
end
|
261
261
|
|
262
262
|
it "should use custom rake binary" do
|
263
|
-
@cap.dump.
|
264
|
-
@cap.dump.
|
263
|
+
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
264
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production SHOW_SIZE\\=true").and_return('')
|
265
265
|
@cap.find_and_execute_task("dump:remote:versions")
|
266
266
|
end
|
267
267
|
end
|
268
268
|
|
269
269
|
describe "cleanup" do
|
270
270
|
it "should call remote rake task" do
|
271
|
-
@cap.dump.
|
271
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:cleanup PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
|
272
272
|
@cap.find_and_execute_task("dump:remote:cleanup")
|
273
273
|
end
|
274
274
|
|
@@ -279,36 +279,36 @@ describe "cap dump" do
|
|
279
279
|
})
|
280
280
|
|
281
281
|
it "should print result of rake task" do
|
282
|
-
@cap.dump.
|
283
|
-
grab_output{
|
282
|
+
allow(@cap.dump).to receive(:run_remote).and_return("123123.tgz\n")
|
283
|
+
expect(grab_output{
|
284
284
|
@cap.find_and_execute_task("dump:remote:cleanup")
|
285
|
-
}[:stdout].
|
285
|
+
}[:stdout]).to eq("123123.tgz\n")
|
286
286
|
end
|
287
287
|
|
288
288
|
it "should use custom rake binary" do
|
289
|
-
@cap.dump.
|
290
|
-
@cap.dump.
|
289
|
+
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
290
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:cleanup PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
|
291
291
|
@cap.find_and_execute_task("dump:remote:cleanup")
|
292
292
|
end
|
293
293
|
end
|
294
294
|
|
295
295
|
describe "create" do
|
296
296
|
it "should raise if dump creation fails" do
|
297
|
-
@cap.dump.
|
298
|
-
|
297
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote").and_return('')
|
298
|
+
expect{
|
299
299
|
@cap.find_and_execute_task("dump:remote:create")
|
300
|
-
}.
|
300
|
+
}.to raise_error('Failed creating dump')
|
301
301
|
end
|
302
302
|
|
303
303
|
it "should call remote rake task with default rails_env and tag remote" do
|
304
|
-
@cap.dump.
|
304
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote").and_return('123.tgz')
|
305
305
|
grab_output{
|
306
306
|
@cap.find_and_execute_task("dump:remote:create")
|
307
307
|
}
|
308
308
|
end
|
309
309
|
|
310
310
|
it "should call remote rake task with default rails_env and additional tag remote" do
|
311
|
-
@cap.dump.
|
311
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote,photos").and_return('123.tgz')
|
312
312
|
grab_output{
|
313
313
|
DumpRake::Env.with_env :tags => 'photos' do
|
314
314
|
@cap.find_and_execute_task("dump:remote:create")
|
@@ -317,8 +317,8 @@ describe "cap dump" do
|
|
317
317
|
end
|
318
318
|
|
319
319
|
it "should call remote rake task with fetched rails_env and default DESC remote" do
|
320
|
-
@cap.dump.
|
321
|
-
@cap.dump.
|
320
|
+
expect(@cap.dump).to receive(:fetch_rails_env).and_return('dev')
|
321
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=dev TAGS\\=remote").and_return('123.tgz')
|
322
322
|
grab_output{
|
323
323
|
@cap.find_and_execute_task("dump:remote:create")
|
324
324
|
}
|
@@ -332,22 +332,22 @@ describe "cap dump" do
|
|
332
332
|
}, :return_value => '123.tgz')
|
333
333
|
|
334
334
|
it "should print result of rake task" do
|
335
|
-
@cap.dump.
|
336
|
-
grab_output{
|
335
|
+
allow(@cap.dump).to receive(:run_remote).and_return("123123.tgz\n")
|
336
|
+
expect(grab_output{
|
337
337
|
@cap.find_and_execute_task("dump:remote:create")
|
338
|
-
}[:stdout].
|
338
|
+
}[:stdout]).to eq("123123.tgz\n")
|
339
339
|
end
|
340
340
|
|
341
341
|
it "should return stripped result of rake task" do
|
342
|
-
@cap.dump.
|
342
|
+
allow(@cap.dump).to receive(:run_remote).and_return("123123.tgz\n")
|
343
343
|
grab_output{
|
344
|
-
@cap.find_and_execute_task("dump:remote:create").
|
344
|
+
expect(@cap.find_and_execute_task("dump:remote:create")).to eq("123123.tgz")
|
345
345
|
}
|
346
346
|
end
|
347
347
|
|
348
348
|
it "should use custom rake binary" do
|
349
|
-
@cap.dump.
|
350
|
-
@cap.dump.
|
349
|
+
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
350
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote").and_return('123.tgz')
|
351
351
|
grab_output{
|
352
352
|
@cap.find_and_execute_task("dump:remote:create")
|
353
353
|
}
|
@@ -356,13 +356,13 @@ describe "cap dump" do
|
|
356
356
|
|
357
357
|
describe "restore" do
|
358
358
|
it "should call remote rake task with default rails_env" do
|
359
|
-
@cap.dump.
|
359
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production")
|
360
360
|
@cap.find_and_execute_task("dump:remote:restore")
|
361
361
|
end
|
362
362
|
|
363
363
|
it "should call remote rake task with fetched rails_env" do
|
364
|
-
@cap.dump.
|
365
|
-
@cap.dump.
|
364
|
+
expect(@cap.dump).to receive(:fetch_rails_env).and_return('dev')
|
365
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=dev")
|
366
366
|
@cap.find_and_execute_task("dump:remote:restore")
|
367
367
|
end
|
368
368
|
|
@@ -376,20 +376,20 @@ describe "cap dump" do
|
|
376
376
|
})
|
377
377
|
|
378
378
|
it "should use custom rake binary" do
|
379
|
-
@cap.dump.
|
380
|
-
@cap.dump.
|
379
|
+
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
380
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production")
|
381
381
|
@cap.find_and_execute_task("dump:remote:restore")
|
382
382
|
end
|
383
383
|
end
|
384
384
|
|
385
385
|
describe "download" do
|
386
386
|
it "should run rake versions to get avaliable versions" do
|
387
|
-
@cap.dump.
|
387
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
|
388
388
|
@cap.find_and_execute_task("dump:remote:download")
|
389
389
|
end
|
390
390
|
|
391
391
|
it "should block sending summary to versions" do
|
392
|
-
@cap.dump.
|
392
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
|
393
393
|
DumpRake::Env::DICTIONARY[:summary].each do |name|
|
394
394
|
DumpRake::Env.with_env name => 'true' do
|
395
395
|
@cap.find_and_execute_task("dump:remote:download")
|
@@ -405,35 +405,35 @@ describe "cap dump" do
|
|
405
405
|
}, :cap_task => "dump:remote:download")
|
406
406
|
|
407
407
|
it "should not download anything if there are no versions avaliable" do
|
408
|
-
@cap.dump.
|
409
|
-
@cap.dump.
|
408
|
+
allow(@cap.dump).to receive(:run_remote).and_return('')
|
409
|
+
expect(@cap.dump).not_to receive(:do_transfer)
|
410
410
|
@cap.find_and_execute_task("dump:remote:download")
|
411
411
|
end
|
412
412
|
|
413
413
|
it "should transfer latest version dump" do
|
414
|
-
@cap.dump.
|
415
|
-
@cap.dump.
|
416
|
-
FileUtils.
|
414
|
+
allow(@cap.dump).to receive(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
415
|
+
expect(@cap.dump).to receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", "dump/300.tgz")
|
416
|
+
allow(FileUtils).to receive(:mkpath)
|
417
417
|
@cap.find_and_execute_task("dump:remote:download")
|
418
418
|
end
|
419
419
|
|
420
420
|
it "should handle extra spaces around file names" do
|
421
|
-
@cap.dump.
|
422
|
-
@cap.dump.
|
423
|
-
FileUtils.
|
421
|
+
allow(@cap.dump).to receive(:run_remote).and_return("\r\n\r\n\r 100.tgz \r\n\r\n\r 200.tgz \r\n\r\n\r 300.tgz \r\n\r\n\r ")
|
422
|
+
expect(@cap.dump).to receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", "dump/300.tgz")
|
423
|
+
allow(FileUtils).to receive(:mkpath)
|
424
424
|
@cap.find_and_execute_task("dump:remote:download")
|
425
425
|
end
|
426
426
|
|
427
427
|
it "should create local dump dir" do
|
428
|
-
@cap.dump.
|
429
|
-
@cap.dump.
|
430
|
-
FileUtils.
|
428
|
+
allow(@cap.dump).to receive(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
429
|
+
allow(@cap.dump).to receive(:do_transfer)
|
430
|
+
expect(FileUtils).to receive(:mkpath).with('dump')
|
431
431
|
@cap.find_and_execute_task("dump:remote:download")
|
432
432
|
end
|
433
433
|
|
434
434
|
it "should run rake versions use custom rake binary" do
|
435
|
-
@cap.dump.
|
436
|
-
@cap.dump.
|
435
|
+
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
436
|
+
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
|
437
437
|
@cap.find_and_execute_task("dump:remote:download")
|
438
438
|
end
|
439
439
|
end
|
@@ -445,55 +445,55 @@ describe "cap dump" do
|
|
445
445
|
dst = way[1]
|
446
446
|
describe name do
|
447
447
|
it "should create auto-backup with tag auto-backup" do
|
448
|
-
@cap.dump.namespaces[dst].
|
448
|
+
expect(@cap.dump.namespaces[dst]).to receive(:create){ expect(DumpRake::Env[:tags]).to eq('auto-backup'); '' }
|
449
449
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
450
450
|
end
|
451
451
|
|
452
452
|
it "should create auto-backup with additional tag auto-backup" do
|
453
|
-
@cap.dump.namespaces[dst].
|
453
|
+
expect(@cap.dump.namespaces[dst]).to receive(:create){ expect(DumpRake::Env[:tags]).to eq('auto-backup,photos'); '' }
|
454
454
|
DumpRake::Env.with_env :tags => 'photos' do
|
455
455
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
456
456
|
end
|
457
457
|
end
|
458
458
|
|
459
459
|
it "should not call local:create if auto-backup fails" do
|
460
|
-
@cap.dump.namespaces[dst].
|
461
|
-
@cap.dump.namespaces[src].
|
460
|
+
allow(@cap.dump.namespaces[dst]).to receive(:create).and_return('')
|
461
|
+
expect(@cap.dump.namespaces[src]).not_to receive(:create)
|
462
462
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
463
463
|
end
|
464
464
|
|
465
465
|
it "should call local:create if auto-backup succeedes with tags mirror and mirror-#{dir}" do
|
466
|
-
@cap.dump.namespaces[dst].
|
467
|
-
@cap.dump.namespaces[src].
|
466
|
+
allow(@cap.dump.namespaces[dst]).to receive(:create).and_return('123.tgz')
|
467
|
+
expect(@cap.dump.namespaces[src]).to receive(:create){ expect(DumpRake::Env[:tags]).to eq("mirror"); '' }
|
468
468
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
469
469
|
end
|
470
470
|
|
471
471
|
it "should call local:create if auto-backup succeedes with additional tags mirror and mirror-#{dir}" do
|
472
|
-
@cap.dump.namespaces[dst].
|
473
|
-
@cap.dump.namespaces[src].
|
472
|
+
allow(@cap.dump.namespaces[dst]).to receive(:create).and_return('123.tgz')
|
473
|
+
expect(@cap.dump.namespaces[src]).to receive(:create){ expect(DumpRake::Env[:tags]).to eq("mirror,photos"); '' }
|
474
474
|
DumpRake::Env.with_env :tags => 'photos' do
|
475
475
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
476
476
|
end
|
477
477
|
end
|
478
478
|
|
479
479
|
it "should not call local:upload or remote:restore if local:create fails" do
|
480
|
-
@cap.dump.namespaces[dst].
|
481
|
-
@cap.dump.namespaces[src].
|
482
|
-
@cap.dump.namespaces[src].
|
483
|
-
@cap.dump.namespaces[dst].
|
480
|
+
allow(@cap.dump.namespaces[dst]).to receive(:create).and_return('123.tgz')
|
481
|
+
allow(@cap.dump.namespaces[src]).to receive(:create).and_return('')
|
482
|
+
expect(@cap.dump.namespaces[src]).not_to receive(:upload)
|
483
|
+
expect(@cap.dump.namespaces[dst]).not_to receive(:restore)
|
484
484
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
485
485
|
end
|
486
486
|
|
487
487
|
it "should call local:upload and remote:restore with only varibale ver set to file name if local:create returns file name" do
|
488
|
-
@cap.dump.namespaces[dst].
|
489
|
-
@cap.dump.namespaces[src].
|
488
|
+
allow(@cap.dump.namespaces[dst]).to receive(:create).and_return('123.tgz')
|
489
|
+
allow(@cap.dump.namespaces[src]).to receive(:create).and_return('123.tgz')
|
490
490
|
test_env = proc{
|
491
|
-
DumpRake::Env[:like].
|
492
|
-
DumpRake::Env[:tags].
|
493
|
-
DumpRake::Env[:desc].
|
491
|
+
expect(DumpRake::Env[:like]).to eq('123.tgz')
|
492
|
+
expect(DumpRake::Env[:tags]).to eq(nil)
|
493
|
+
expect(DumpRake::Env[:desc]).to eq(nil)
|
494
494
|
}
|
495
|
-
@cap.dump.namespaces[src].
|
496
|
-
@cap.dump.namespaces[dst].
|
495
|
+
expect(@cap.dump.namespaces[src]).to receive(:"#{dir}load").ordered(&test_env)
|
496
|
+
expect(@cap.dump.namespaces[dst]).to receive(:restore).ordered(&test_env)
|
497
497
|
DumpRake::Env.with_env all_dictionary_variables do
|
498
498
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
499
499
|
end
|
@@ -504,33 +504,33 @@ describe "cap dump" do
|
|
504
504
|
|
505
505
|
describe "backup" do
|
506
506
|
it "should call remote:create" do
|
507
|
-
@cap.dump.remote.
|
507
|
+
expect(@cap.dump.remote).to receive(:create).and_return('')
|
508
508
|
@cap.find_and_execute_task("dump:backup")
|
509
509
|
end
|
510
510
|
|
511
511
|
it "should not call remote:download if remote:create returns blank" do
|
512
|
-
@cap.dump.remote.
|
513
|
-
@cap.dump.remote.
|
512
|
+
allow(@cap.dump.remote).to receive(:create).and_return('')
|
513
|
+
expect(@cap.dump.remote).not_to receive(:download)
|
514
514
|
@cap.find_and_execute_task("dump:backup")
|
515
515
|
end
|
516
516
|
|
517
517
|
it "should call remote:download if remote:create returns file name" do
|
518
|
-
@cap.dump.remote.
|
519
|
-
@cap.dump.remote.
|
518
|
+
allow(@cap.dump.remote).to receive(:create).and_return('123.tgz')
|
519
|
+
expect(@cap.dump.remote).to receive(:download).ordered
|
520
520
|
@cap.find_and_execute_task("dump:backup")
|
521
521
|
end
|
522
522
|
|
523
523
|
it "should call remote:create with tag backup" do
|
524
|
-
|
525
|
-
DumpRake::Env[:tags].
|
524
|
+
expect(@cap.dump.remote).to receive(:create) do
|
525
|
+
expect(DumpRake::Env[:tags]).to eq('backup')
|
526
526
|
''
|
527
527
|
end
|
528
528
|
@cap.find_and_execute_task("dump:backup")
|
529
529
|
end
|
530
530
|
|
531
531
|
it "should call remote:create with additional tag backup" do
|
532
|
-
|
533
|
-
DumpRake::Env[:tags].
|
532
|
+
expect(@cap.dump.remote).to receive(:create) do
|
533
|
+
expect(DumpRake::Env[:tags]).to eq('backup,photos')
|
534
534
|
''
|
535
535
|
end
|
536
536
|
DumpRake::Env.with_env :tags => 'photos' do
|
@@ -539,8 +539,8 @@ describe "cap dump" do
|
|
539
539
|
end
|
540
540
|
|
541
541
|
it "should pass description if it is set" do
|
542
|
-
|
543
|
-
DumpRake::Env[:desc].
|
542
|
+
expect(@cap.dump.remote).to receive(:create) do
|
543
|
+
expect(DumpRake::Env[:desc]).to eq('remote dump')
|
544
544
|
''
|
545
545
|
end
|
546
546
|
DumpRake::Env.with_env :desc => 'remote dump' do
|
@@ -549,11 +549,11 @@ describe "cap dump" do
|
|
549
549
|
end
|
550
550
|
|
551
551
|
it "should send only ver variable" do
|
552
|
-
@cap.dump.remote.
|
553
|
-
|
554
|
-
DumpRake::Env[:like].
|
555
|
-
DumpRake::Env[:tags].
|
556
|
-
DumpRake::Env[:desc].
|
552
|
+
allow(@cap.dump.remote).to receive(:create).and_return('123.tgz')
|
553
|
+
expect(@cap.dump.remote).to receive(:download) do
|
554
|
+
expect(DumpRake::Env[:like]).to eq('123.tgz')
|
555
|
+
expect(DumpRake::Env[:tags]).to eq(nil)
|
556
|
+
expect(DumpRake::Env[:desc]).to eq(nil)
|
557
557
|
''
|
558
558
|
end
|
559
559
|
DumpRake::Env.with_env all_dictionary_variables do
|