dump 1.0.4 → 1.0.5

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