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.
Files changed (42) hide show
  1. checksums.yaml +9 -9
  2. data/.travis.yml +9 -6
  3. data/Gemfile +5 -1
  4. data/LICENSE.txt +1 -1
  5. data/README.markdown +7 -5
  6. data/dump.gemspec +2 -2
  7. data/lib/dump_rake/dump_reader.rb +2 -0
  8. data/spec/.tmignore +1 -0
  9. data/spec/cycle_spec.rb +22 -16
  10. data/spec/dummy-4.1/.gitignore +16 -0
  11. data/spec/dummy-4.1/config.ru +4 -0
  12. data/spec/dummy-4.1/config/application.rb +30 -0
  13. data/spec/dummy-4.1/config/boot.rb +4 -0
  14. data/spec/dummy-4.1/config/database.yml +25 -0
  15. data/spec/dummy-4.1/config/environment.rb +5 -0
  16. data/spec/dummy-4.1/config/environments/development.rb +28 -0
  17. data/spec/dummy-4.1/config/environments/production.rb +67 -0
  18. data/spec/dummy-4.1/config/environments/test.rb +39 -0
  19. data/spec/dummy-4.1/config/initializers/backtrace_silencers.rb +7 -0
  20. data/spec/dummy-4.1/config/initializers/cookies_serializer.rb +3 -0
  21. data/spec/dummy-4.1/config/initializers/filter_parameter_logging.rb +4 -0
  22. data/spec/dummy-4.1/config/initializers/inflections.rb +16 -0
  23. data/spec/dummy-4.1/config/initializers/mime_types.rb +4 -0
  24. data/spec/dummy-4.1/config/initializers/session_store.rb +3 -0
  25. data/spec/dummy-4.1/config/initializers/wrap_parameters.rb +14 -0
  26. data/spec/dummy-4.1/config/locales/en.yml +23 -0
  27. data/spec/dummy-4.1/config/routes.rb +56 -0
  28. data/spec/dummy-4.1/config/secrets.yml +22 -0
  29. data/spec/dummy-4.1/db/seeds.rb +7 -0
  30. data/spec/dummy-4.1/log/.keep +0 -0
  31. data/spec/lib/dump_rake/dump_reader_spec.rb +223 -181
  32. data/spec/lib/dump_rake/dump_spec.rb +78 -78
  33. data/spec/lib/dump_rake/dump_writer_spec.rb +110 -110
  34. data/spec/lib/dump_rake/env/filter_spec.rb +24 -24
  35. data/spec/lib/dump_rake/env_spec.rb +33 -33
  36. data/spec/lib/dump_rake/rails_root_spec.rb +6 -6
  37. data/spec/lib/dump_rake/table_manipulation_spec.rb +60 -60
  38. data/spec/lib/dump_rake_spec.rb +93 -93
  39. data/spec/recipes/dump_spec.rb +128 -128
  40. data/spec/tasks/assets_spec.rb +18 -18
  41. data/spec/tasks/dump_spec.rb +9 -9
  42. metadata +49 -7
@@ -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.should_receive(:list).and_return([])
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.should_receive(:list).with(:like => '123').and_return([])
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.should_receive(:list).and_return(%w[123.tgz 456.tgz])
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].should == "123.tgz\n456.tgz\n"
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.should_not_receive(:summary)
25
+ expect(DumpRake::DumpReader).not_to receive(:summary)
26
26
  dump
27
27
  end
28
28
 
29
- DumpRake::Dump.should_receive(:list).and_return(dumps)
29
+ expect(DumpRake::Dump).to receive(:list).and_return(dumps)
30
30
  grab_output{
31
- $stderr.should_not_receive(:puts)
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.should_receive(:summary).with(dump.path)
39
+ expect(DumpRake::DumpReader).to receive(:summary).with(dump.path)
40
40
  dump
41
41
  end
42
42
 
43
- DumpRake::Dump.should_receive(:list).and_return(dumps)
43
+ expect(DumpRake::Dump).to receive(:list).and_return(dumps)
44
44
  grab_output{
45
- $stderr.should_not_receive(:puts)
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.should_receive(:summary).with(dump.path, :schema => true)
53
+ expect(DumpRake::DumpReader).to receive(:summary).with(dump.path, :schema => true)
54
54
  dump
55
55
  end
56
56
 
57
- DumpRake::Dump.should_receive(:list).and_return(dumps)
57
+ expect(DumpRake::Dump).to receive(:list).and_return(dumps)
58
58
  grab_output{
59
- $stderr.should_not_receive(:puts)
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.stub(:summary)
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.should_receive(:summary).with(dumps[1].path).and_raise('terrible error')
69
+ expect(DumpRake::DumpReader).to receive(:summary).with(dumps[1].path).and_raise('terrible error')
70
70
 
71
- DumpRake::Dump.should_receive(:list).and_return(dumps)
71
+ expect(DumpRake::Dump).to receive(:list).and_return(dumps)
72
72
  grab_output{
73
- $stderr.stub(:puts)
74
- $stderr.should_receive(:puts) do |s|
75
- s['terrible error'].should_not be_nil
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.stub(:rename)
86
- DumpRake::DumpWriter.should_receive(:create) do |path|
87
- File.dirname(path).should == File.join(DumpRake::RailsRoot, 'dump')
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.stub(:rename)
96
- DumpRake::DumpWriter.should_receive(:create) do |path|
97
- File.basename(path).should match(/^\d{14}\.tmp$/)
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.stub(:rename)
106
- DumpRake::DumpWriter.should_receive(:create) do |path|
107
- File.basename(path).should match(/^\d{14}-Some text and _\.tmp$/)
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.stub(:rename)
116
- DumpRake::DumpWriter.should_receive(:create) do |path|
117
- File.basename(path).should match(/^\d{14}-Some text and _\.tmp$/)
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.should_receive(:rename) do |tmp_path, tgz_path|
126
- File.basename(tmp_path).should match(/^\d{14}-Some text and _\.tmp$/)
127
- File.basename(tgz_path).should match(/^\d{14}-Some text and _\.tgz$/)
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.stub(:create)
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.stub(:rename)
137
- DumpRake::DumpWriter.stub(:create)
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].should match(/^\d{14}-Some text and _\.tgz$/)
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.stub(:rename)
146
+ allow(File).to receive(:rename)
147
147
  @dump = double('dump')
148
- DumpRake::DumpWriter.should_receive(:create)
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.stub(:list)
161
- DumpRake::Dump.should_receive(:list).and_return([])
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.stub(:list).and_return([])
169
- DumpRake::DumpReader.should_not_receive(:restore)
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.should_receive(:list).with().and_return(all_dumps)
171
+ expect(DumpRake::Dump).to receive(:list).with(no_args).and_return(all_dumps)
172
172
  grab_output{
173
- $stderr.should_receive(:puts).with(kind_of(String))
174
- $stderr.should_receive(:puts).with(all_dumps)
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.stub(:list).and_return([])
181
- DumpRake::DumpReader.should_not_receive(:restore)
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.should_receive(:list).with().and_return(all_dumps)
183
+ expect(DumpRake::Dump).to receive(:list).with(no_args).and_return(all_dumps)
184
184
  grab_output{
185
- $stderr.should_receive(:puts).with(kind_of(String))
186
- $stderr.should_receive(:puts).with(all_dumps)
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.should_receive(:list).once.and_return([@dump])
194
- DumpRake::DumpReader.should_receive(:restore).with('dump/213.tgz')
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.should_not_receive(:puts)
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.stub(:list)
205
- DumpRake::Dump.should_receive(:list).with(:like => '213').and_return([])
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.stub(:list).and_return([])
213
- DumpRake::DumpReader.should_not_receive(:restore)
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.should_receive(:list).with().and_return(all_dumps)
215
+ expect(DumpRake::Dump).to receive(:list).with(no_args).and_return(all_dumps)
216
216
  grab_output{
217
- $stderr.should_receive(:puts).with(kind_of(String))
218
- $stderr.should_receive(:puts).with(all_dumps)
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.should_receive(:list).once.and_return([@dump])
226
- DumpRake::DumpReader.should_receive(:restore).with('dump/213.tgz')
227
- DumpRake.should_not_receive(:versions)
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.should_not_receive(:puts)
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.should_receive(:list).once.and_return([@dump_a, @dump_b])
238
- DumpRake::DumpReader.should_receive(:restore).with('dump/213-b.tgz')
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.should_not_receive(:puts)
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.should_receive(:list).with(:all => true).and_return([])
250
- DumpRake::Dump.should_receive(:list).with({}).and_return([])
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.should_receive(:list).with(:like => '123', :tags => 'a,b,c', :all => true).and_return([])
256
- DumpRake::Dump.should_receive(:list).with(:like => '123', :tags => 'a,b,c').and_return([])
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.should_receive(:lock).and_yield
280
- dump.path.should_receive(:unlink)
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.should_receive(:lock)
284
- dump.path.should_not_receive(:unlink)
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.should_not_receive(:lock)
288
- dump.path.should_not_receive(:unlink)
287
+ expect(dump).not_to receive(:lock)
288
+ expect(dump.path).not_to receive(:unlink)
289
289
  end
290
290
 
291
- DumpRake::Dump.should_receive(:list).with(hash_including(:all => true)).and_return(all_dumps)
292
- DumpRake::Dump.should_receive(:list).with(hash_not_including(:all => true)).and_return(dumps)
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.stub(:lock).and_yield
303
- dump.path.stub(:unlink)
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.should_receive(:unlink).and_raise('Horrible error')
307
+ expect(dumps[3].path).to receive(:unlink).and_raise('Horrible error')
308
308
 
309
- DumpRake::Dump.stub(:list).and_return(dumps)
309
+ allow(DumpRake::Dump).to receive(:list).and_return(dumps)
310
310
  grab_output{
311
- $stderr.stub(:puts)
312
- $stderr.should_receive(:puts) do |s|
313
- s[dumps[3].path.to_s].should_not be_nil
314
- s['Horrible error'].should_not be_nil
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
- proc{
321
+ expect{
322
322
  DumpRake.cleanup(:leave => 'nothing')
323
- }.should raise_error
323
+ }.to raise_error
324
324
  end
325
325
  end
326
326
  end
@@ -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.should_receive(:"run_#{place}").with(full_command_string).and_return(options[:return_value] || '')
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').should == 'rake -s dump:hello 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').should == 'bundler exec rake -s dump:hello 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.stub(:do_transfer_via)
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.should_receive(:got_rsync?)
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.stub(:got_rsync?).and_return(true)
65
- @cap.dump.should_receive(:do_transfer_via).with(:rsync, direction, 'a.tgz', 'b.tgz')
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.stub(:got_rsync?).and_return(true)
71
- @cap.dump.should_receive(:do_transfer_via).with(:rsync, direction, 'a.tgz', 'b.tgz').and_raise('problem using rsync')
72
- proc{
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
- }.should raise_error('problem using rsync')
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.stub(:got_rsync?).and_return(false)
81
- @cap.dump.should_receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz')
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.stub(:got_rsync?).and_return(false)
87
- @cap.dump.should_receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz').and_raise('problem using sftp')
88
- @cap.dump.should_receive(:do_transfer_via).with(:scp, direction, 'a.tgz', 'b.tgz')
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.stub(:got_rsync?).and_return(false)
94
- @cap.dump.should_receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz').and_raise('problem using sftp')
95
- @cap.dump.should_receive(:do_transfer_via).with(:scp, direction, 'a.tgz', 'b.tgz').and_raise('problem using scp')
96
- proc{
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
- }.should raise_error('problem using scp')
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.should_receive(:run_local).with("rake -s dump:versions SHOW_SIZE\\=true").and_return('')
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.stub(:run_local).and_return(" 123M\t123123.tgz\n")
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].should == " 123M\t123123.tgz\n"
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.should_receive(:run_local).with("rake -s dump:cleanup").and_return('')
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.stub(:run_local).and_return("123123.tgz\n")
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].should == "123123.tgz\n"
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.should_receive(:run_local).with("rake -s dump:create TAGS\\=local").and_return('')
150
- proc{
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
- }.should raise_error('Failed creating dump')
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.should_receive(:run_local).with("rake -s dump:create TAGS\\=local").and_return('123.tgz')
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.should_receive(:run_local).with("rake -s dump:create TAGS\\=local,photos").and_return('123.tgz')
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.stub(:run_local).and_return("123123.tgz\n")
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].should == "123123.tgz\n"
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.stub(:run_local).and_return("123123.tgz\n")
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").should == "123123.tgz"
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.should_receive(:run_local).with("rake -s dump:restore")
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.should_receive(:run_local).with("rake -s dump:versions").and_return('')
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.stub(:run_local).and_return('')
224
- @cap.dump.should_not_receive(:do_transfer)
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.stub(:run_local).and_return("100.tgz\n200.tgz\n300.tgz\n")
230
- @cap.dump.should_receive(:do_transfer).with(:up, "dump/300.tgz", "#{@remote_path}/dump/300.tgz")
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.stub(: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
- @cap.dump.should_receive(:do_transfer).with(:up, "dump/300.tgz", "#{@remote_path}/dump/300.tgz")
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.should_receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production SHOW_SIZE\\=true").and_return('')
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.stub(:run_remote).and_return(" 123M\t123123.tgz\n")
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].should == " 123M\t123123.tgz\n"
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.should_receive(:fetch_rake).and_return('/custom/rake')
264
- @cap.dump.should_receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production SHOW_SIZE\\=true").and_return('')
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.should_receive(:run_remote).with("cd #{@remote_path}; rake -s dump:cleanup PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
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.stub(:run_remote).and_return("123123.tgz\n")
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].should == "123123.tgz\n"
285
+ }[:stdout]).to eq("123123.tgz\n")
286
286
  end
287
287
 
288
288
  it "should use custom rake binary" do
289
- @cap.dump.should_receive(:fetch_rake).and_return('/custom/rake')
290
- @cap.dump.should_receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:cleanup PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
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.should_receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote").and_return('')
298
- proc{
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
- }.should raise_error('Failed creating dump')
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.should_receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote").and_return('123.tgz')
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.should_receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote,photos").and_return('123.tgz')
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.should_receive(:fetch_rails_env).and_return('dev')
321
- @cap.dump.should_receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=dev TAGS\\=remote").and_return('123.tgz')
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.stub(:run_remote).and_return("123123.tgz\n")
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].should == "123123.tgz\n"
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.stub(:run_remote).and_return("123123.tgz\n")
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").should == "123123.tgz"
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.should_receive(:fetch_rake).and_return('/custom/rake')
350
- @cap.dump.should_receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote").and_return('123.tgz')
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.should_receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production")
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.should_receive(:fetch_rails_env).and_return('dev')
365
- @cap.dump.should_receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=dev")
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.should_receive(:fetch_rake).and_return('/custom/rake')
380
- @cap.dump.should_receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production")
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.should_receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
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.should_receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
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.stub(:run_remote).and_return('')
409
- @cap.dump.should_not_receive(:do_transfer)
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.stub(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
415
- @cap.dump.should_receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", "dump/300.tgz")
416
- FileUtils.stub(:mkpath)
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.stub(: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
- @cap.dump.should_receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", "dump/300.tgz")
423
- FileUtils.stub(:mkpath)
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.stub(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
429
- @cap.dump.stub(:do_transfer)
430
- FileUtils.should_receive(:mkpath).with('dump')
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.should_receive(:fetch_rake).and_return('/custom/rake')
436
- @cap.dump.should_receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
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].should_receive(:create){ DumpRake::Env[:tags].should == 'auto-backup'; '' }
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].should_receive(:create){ DumpRake::Env[:tags].should == 'auto-backup,photos'; '' }
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].stub(:create).and_return('')
461
- @cap.dump.namespaces[src].should_not_receive(:create)
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].stub(:create).and_return('123.tgz')
467
- @cap.dump.namespaces[src].should_receive(:create){ DumpRake::Env[:tags].should == "mirror"; '' }
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].stub(:create).and_return('123.tgz')
473
- @cap.dump.namespaces[src].should_receive(:create){ DumpRake::Env[:tags].should == "mirror,photos"; '' }
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].stub(:create).and_return('123.tgz')
481
- @cap.dump.namespaces[src].stub(:create).and_return('')
482
- @cap.dump.namespaces[src].should_not_receive(:upload)
483
- @cap.dump.namespaces[dst].should_not_receive(:restore)
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].stub(:create).and_return('123.tgz')
489
- @cap.dump.namespaces[src].stub(:create).and_return('123.tgz')
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].should == '123.tgz'
492
- DumpRake::Env[:tags].should == nil
493
- DumpRake::Env[:desc].should == nil
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].should_receive(:"#{dir}load").ordered(&test_env)
496
- @cap.dump.namespaces[dst].should_receive(:restore).ordered(&test_env)
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.should_receive(:create).and_return('')
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.stub(:create).and_return('')
513
- @cap.dump.remote.should_not_receive(:download)
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.stub(:create).and_return('123.tgz')
519
- @cap.dump.remote.should_receive(:download).ordered
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
- def (@cap.dump.remote).create
525
- DumpRake::Env[:tags].should == 'backup'
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
- def (@cap.dump.remote).create
533
- DumpRake::Env[:tags].should == 'backup,photos'
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
- def (@cap.dump.remote).create
543
- DumpRake::Env[:desc].should == 'remote dump'
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.stub(:create).and_return('123.tgz')
553
- def (@cap.dump.remote).download
554
- DumpRake::Env[:like].should == '123.tgz'
555
- DumpRake::Env[:tags].should == nil
556
- DumpRake::Env[:desc].should == nil
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