dump 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +1 -0
- data/.travis.database.yml +14 -0
- data/.travis.yml +30 -0
- data/Gemfile +20 -0
- data/LICENSE.txt +1 -1
- data/README.markdown +5 -3
- data/dump.gemspec +1 -2
- data/lib/dump_rake/dump.rb +4 -0
- data/lib/dump_rake/dump_reader.rb +1 -1
- data/lib/dump_rake/dump_writer.rb +1 -1
- data/lib/dump_rake/table_manipulation.rb +1 -1
- data/spec/.gitignore +18 -0
- data/spec/cycle_spec.rb +22 -14
- data/spec/dummy-2.3/config/boot.rb +114 -0
- data/spec/dummy-2.3/config/database.yml +22 -0
- data/spec/dummy-2.3/config/environment.rb +41 -0
- data/spec/dummy-2.3/config/environments/development.rb +17 -0
- data/spec/dummy-2.3/config/environments/production.rb +28 -0
- data/spec/dummy-2.3/config/environments/test.rb +28 -0
- data/spec/dummy-2.3/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy-2.3/config/initializers/cookie_verification_secret.rb +7 -0
- data/spec/dummy-2.3/config/initializers/inflections.rb +10 -0
- data/spec/{dummy-3.1.3 → dummy-2.3}/config/initializers/mime_types.rb +0 -0
- data/spec/dummy-2.3/config/initializers/new_rails_defaults.rb +21 -0
- data/spec/dummy-2.3/config/initializers/session_store.rb +15 -0
- data/spec/dummy-2.3/config/locales/en.yml +5 -0
- data/spec/dummy-2.3/config/routes.rb +43 -0
- data/spec/dummy-2.3/db/seeds.rb +7 -0
- data/spec/dummy-3.0/.gitignore +4 -0
- data/spec/{dummy-3.1.3 → dummy-3.0}/config.ru +1 -1
- data/spec/dummy-3.0/config/application.rb +42 -0
- data/spec/{dummy-3.1.3 → dummy-3.0}/config/boot.rb +0 -0
- data/spec/dummy-3.0/config/database.yml +22 -0
- data/spec/{dummy-3.1.3 → dummy-3.0}/config/environment.rb +1 -1
- data/spec/dummy-3.0/config/environments/development.rb +26 -0
- data/spec/dummy-3.0/config/environments/production.rb +49 -0
- data/spec/dummy-3.0/config/environments/test.rb +35 -0
- data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/inflections.rb +0 -0
- data/spec/dummy-3.0/config/initializers/mime_types.rb +5 -0
- data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/secret_token.rb +1 -1
- data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/session_store.rb +2 -2
- data/spec/dummy-3.0/config/locales/en.yml +5 -0
- data/spec/dummy-3.0/config/routes.rb +58 -0
- data/spec/dummy-3.0/db/seeds.rb +7 -0
- data/spec/{dummy-3.1.3 → dummy-3.1}/.gitignore +0 -0
- data/spec/dummy-3.1/config.ru +4 -0
- data/spec/{dummy-3.1.3 → dummy-3.1}/config/application.rb +2 -7
- data/spec/dummy-3.1/config/boot.rb +6 -0
- data/spec/{dummy-3.1.3 → dummy-3.1}/config/database.yml +0 -0
- data/spec/dummy-3.1/config/environment.rb +5 -0
- data/spec/{dummy-3.1.3 → dummy-3.1}/config/environments/development.rb +1 -6
- data/spec/{dummy-3.1.3 → dummy-3.1}/config/environments/production.rb +1 -14
- data/spec/{dummy-3.1.3 → dummy-3.1}/config/environments/test.rb +1 -1
- data/spec/dummy-3.1/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy-3.1/config/initializers/inflections.rb +10 -0
- data/spec/dummy-3.1/config/initializers/mime_types.rb +5 -0
- data/spec/dummy-3.1/config/initializers/secret_token.rb +7 -0
- data/spec/dummy-3.1/config/initializers/session_store.rb +8 -0
- data/spec/{dummy-3.1.3 → dummy-3.1}/config/initializers/wrap_parameters.rb +0 -0
- data/spec/{dummy-3.1.3 → dummy-3.1}/config/locales/en.yml +0 -0
- data/spec/{dummy-3.1.3 → dummy-3.1}/config/routes.rb +1 -1
- data/spec/{dummy-3.1.3 → dummy-3.1}/db/seeds.rb +0 -0
- data/spec/{dummy-3.1.3/app/mailers → dummy-3.1/log}/.gitkeep +0 -0
- data/spec/dummy-3.2/.gitignore +15 -0
- data/spec/dummy-3.2/config.ru +4 -0
- data/spec/dummy-3.2/config/application.rb +63 -0
- data/spec/dummy-3.2/config/boot.rb +6 -0
- data/spec/dummy-3.2/config/database.yml +25 -0
- data/spec/dummy-3.2/config/environment.rb +5 -0
- data/spec/dummy-3.2/config/environments/development.rb +32 -0
- data/spec/dummy-3.2/config/environments/production.rb +54 -0
- data/spec/dummy-3.2/config/environments/test.rb +37 -0
- data/spec/dummy-3.2/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy-3.2/config/initializers/inflections.rb +15 -0
- data/spec/dummy-3.2/config/initializers/mime_types.rb +5 -0
- data/spec/dummy-3.2/config/initializers/secret_token.rb +7 -0
- data/spec/dummy-3.2/config/initializers/session_store.rb +8 -0
- data/spec/dummy-3.2/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy-3.2/config/locales/en.yml +5 -0
- data/spec/dummy-3.2/config/routes.rb +58 -0
- data/spec/dummy-3.2/db/seeds.rb +7 -0
- data/spec/{dummy-3.1.3/app/models → dummy-3.2/log}/.gitkeep +0 -0
- data/spec/dummy-4.0/.gitignore +16 -0
- data/spec/dummy-4.0/config.ru +4 -0
- data/spec/dummy-4.0/config/application.rb +31 -0
- data/spec/dummy-4.0/config/boot.rb +4 -0
- data/spec/dummy-4.0/config/database.yml +25 -0
- data/spec/dummy-4.0/config/environment.rb +5 -0
- data/spec/dummy-4.0/config/environments/development.rb +25 -0
- data/spec/dummy-4.0/config/environments/production.rb +65 -0
- data/spec/dummy-4.0/config/environments/test.rb +36 -0
- data/spec/dummy-4.0/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy-4.0/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy-4.0/config/initializers/inflections.rb +16 -0
- data/spec/dummy-4.0/config/initializers/mime_types.rb +5 -0
- data/spec/dummy-4.0/config/initializers/secret_token.rb +12 -0
- data/spec/dummy-4.0/config/initializers/session_store.rb +3 -0
- data/spec/dummy-4.0/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy-4.0/config/locales/en.yml +23 -0
- data/spec/dummy-4.0/config/routes.rb +56 -0
- data/spec/dummy-4.0/db/seeds.rb +7 -0
- data/spec/{dummy-3.1.3/lib/assets/.gitkeep → dummy-4.0/log/.keep} +0 -0
- data/spec/lib/dump_rake/dump_reader_spec.rb +90 -89
- data/spec/lib/dump_rake/dump_spec.rb +9 -9
- data/spec/lib/dump_rake/dump_writer_spec.rb +79 -78
- data/spec/lib/dump_rake/rails_root_spec.rb +2 -2
- data/spec/lib/dump_rake/table_manipulation_spec.rb +10 -10
- data/spec/lib/dump_rake_spec.rb +34 -34
- data/spec/recipes/dump_spec.rb +34 -34
- data/spec/spec_helper.rb +35 -10
- data/spec/tasks/assets_spec.rb +6 -6
- metadata +240 -183
- data/spec/dummy-3.1.3/.rspec +0 -1
- data/spec/dummy-3.1.3/Gemfile +0 -14
- data/spec/dummy-3.1.3/Gemfile.lock +0 -133
- data/spec/dummy-3.1.3/README +0 -261
- data/spec/dummy-3.1.3/Rakefile +0 -7
- data/spec/dummy-3.1.3/app/assets/images/rails.png +0 -0
- data/spec/dummy-3.1.3/app/assets/javascripts/application.js +0 -9
- data/spec/dummy-3.1.3/app/assets/stylesheets/application.css +0 -7
- data/spec/dummy-3.1.3/app/controllers/application_controller.rb +0 -3
- data/spec/dummy-3.1.3/app/helpers/application_helper.rb +0 -2
- data/spec/dummy-3.1.3/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy-3.1.3/doc/README_FOR_APP +0 -2
- data/spec/dummy-3.1.3/lib/tasks/.gitkeep +0 -0
- data/spec/dummy-3.1.3/log/.gitkeep +0 -0
- data/spec/dummy-3.1.3/public/404.html +0 -26
- data/spec/dummy-3.1.3/public/422.html +0 -26
- data/spec/dummy-3.1.3/public/500.html +0 -26
- data/spec/dummy-3.1.3/public/favicon.ico +0 -0
- data/spec/dummy-3.1.3/public/index.html +0 -241
- data/spec/dummy-3.1.3/public/robots.txt +0 -5
- data/spec/dummy-3.1.3/script/rails +0 -6
- data/spec/dummy-3.1.3/spec/spec_helper.rb +0 -32
- data/spec/dummy-3.1.3/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/dummy-3.1.3/vendor/plugins/.gitkeep +0 -0
data/spec/lib/dump_rake_spec.rb
CHANGED
|
@@ -21,7 +21,7 @@ describe DumpRake do
|
|
|
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
|
-
dump =
|
|
24
|
+
dump = double("dump_#{s}", :path => double("dump_#{s}_path"))
|
|
25
25
|
DumpRake::DumpReader.should_not_receive(:summary)
|
|
26
26
|
dump
|
|
27
27
|
end
|
|
@@ -35,7 +35,7 @@ describe DumpRake do
|
|
|
35
35
|
|
|
36
36
|
it "should show summary if asked for" do
|
|
37
37
|
dumps = %w[123.tgz 456.tgz].map do |s|
|
|
38
|
-
dump =
|
|
38
|
+
dump = double("dump_#{s}", :path => double("dump_#{s}_path"))
|
|
39
39
|
DumpRake::DumpReader.should_receive(:summary).with(dump.path)
|
|
40
40
|
dump
|
|
41
41
|
end
|
|
@@ -49,7 +49,7 @@ describe DumpRake do
|
|
|
49
49
|
|
|
50
50
|
it "should show summary with scmema if asked for" do
|
|
51
51
|
dumps = %w[123.tgz 456.tgz].map do |s|
|
|
52
|
-
dump =
|
|
52
|
+
dump = double("dump_#{s}", :path => double("dump_#{s}_path"))
|
|
53
53
|
DumpRake::DumpReader.should_receive(:summary).with(dump.path, :schema => true)
|
|
54
54
|
dump
|
|
55
55
|
end
|
|
@@ -62,15 +62,15 @@ describe DumpRake do
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it "should show output to stderr if summary raises error" do
|
|
65
|
-
DumpRake::DumpReader.stub
|
|
65
|
+
DumpRake::DumpReader.stub(: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
69
|
DumpRake::DumpReader.should_receive(:summary).with(dumps[1].path).and_raise('terrible error')
|
|
70
70
|
|
|
71
71
|
DumpRake::Dump.should_receive(:list).and_return(dumps)
|
|
72
72
|
grab_output{
|
|
73
|
-
$stderr.stub
|
|
73
|
+
$stderr.stub(:puts)
|
|
74
74
|
$stderr.should_receive(:puts) do |s|
|
|
75
75
|
s['terrible error'].should_not be_nil
|
|
76
76
|
end
|
|
@@ -82,7 +82,7 @@ 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
|
|
85
|
+
File.stub(:rename)
|
|
86
86
|
DumpRake::DumpWriter.should_receive(:create) do |path|
|
|
87
87
|
File.dirname(path).should == File.join(DumpRake::RailsRoot, 'dump')
|
|
88
88
|
end
|
|
@@ -92,7 +92,7 @@ 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
|
|
95
|
+
File.stub(:rename)
|
|
96
96
|
DumpRake::DumpWriter.should_receive(:create) do |path|
|
|
97
97
|
File.basename(path).should match(/^\d{14}\.tmp$/)
|
|
98
98
|
end
|
|
@@ -102,7 +102,7 @@ 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
|
|
105
|
+
File.stub(:rename)
|
|
106
106
|
DumpRake::DumpWriter.should_receive(:create) do |path|
|
|
107
107
|
File.basename(path).should match(/^\d{14}-Some text and _\.tmp$/)
|
|
108
108
|
end
|
|
@@ -112,7 +112,7 @@ 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
|
|
115
|
+
File.stub(:rename)
|
|
116
116
|
DumpRake::DumpWriter.should_receive(:create) do |path|
|
|
117
117
|
File.basename(path).should match(/^\d{14}-Some text and _\.tmp$/)
|
|
118
118
|
end
|
|
@@ -126,15 +126,15 @@ describe DumpRake do
|
|
|
126
126
|
File.basename(tmp_path).should match(/^\d{14}-Some text and _\.tmp$/)
|
|
127
127
|
File.basename(tgz_path).should match(/^\d{14}-Some text and _\.tgz$/)
|
|
128
128
|
end
|
|
129
|
-
DumpRake::DumpWriter.stub
|
|
129
|
+
DumpRake::DumpWriter.stub(: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
|
|
137
|
-
DumpRake::DumpWriter.stub
|
|
136
|
+
File.stub(:rename)
|
|
137
|
+
DumpRake::DumpWriter.stub(:create)
|
|
138
138
|
grab_output{
|
|
139
139
|
DumpRake.create(:desc => 'Some text and !@')
|
|
140
140
|
}[:stdout].should match(/^\d{14}-Some text and _\.tgz$/)
|
|
@@ -143,8 +143,8 @@ describe DumpRake do
|
|
|
143
143
|
|
|
144
144
|
describe "writing" do
|
|
145
145
|
it "should dump schema, tables, assets" do
|
|
146
|
-
File.stub
|
|
147
|
-
@dump =
|
|
146
|
+
File.stub(:rename)
|
|
147
|
+
@dump = double('dump')
|
|
148
148
|
DumpRake::DumpWriter.should_receive(:create)
|
|
149
149
|
|
|
150
150
|
grab_output{
|
|
@@ -157,7 +157,7 @@ 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
|
|
160
|
+
DumpRake::Dump.stub(:list)
|
|
161
161
|
DumpRake::Dump.should_receive(:list).and_return([])
|
|
162
162
|
grab_output{
|
|
163
163
|
DumpRake.restore
|
|
@@ -165,9 +165,9 @@ describe DumpRake do
|
|
|
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
|
|
168
|
+
DumpRake::Dump.stub(:list).and_return([])
|
|
169
169
|
DumpRake::DumpReader.should_not_receive(:restore)
|
|
170
|
-
all_dumps =
|
|
170
|
+
all_dumps = double('all_dumps')
|
|
171
171
|
DumpRake::Dump.should_receive(:list).with().and_return(all_dumps)
|
|
172
172
|
grab_output{
|
|
173
173
|
$stderr.should_receive(:puts).with(kind_of(String))
|
|
@@ -177,9 +177,9 @@ describe DumpRake do
|
|
|
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
|
|
180
|
+
DumpRake::Dump.stub(:list).and_return([])
|
|
181
181
|
DumpRake::DumpReader.should_not_receive(:restore)
|
|
182
|
-
all_dumps =
|
|
182
|
+
all_dumps = double('all_dumps')
|
|
183
183
|
DumpRake::Dump.should_receive(:list).with().and_return(all_dumps)
|
|
184
184
|
grab_output{
|
|
185
185
|
$stderr.should_receive(:puts).with(kind_of(String))
|
|
@@ -189,7 +189,7 @@ describe DumpRake do
|
|
|
189
189
|
end
|
|
190
190
|
|
|
191
191
|
it "should call DumpReader.restore if there are versions" do
|
|
192
|
-
@dump =
|
|
192
|
+
@dump = double('dump', :path => 'dump/213.tgz')
|
|
193
193
|
DumpRake::Dump.should_receive(:list).once.and_return([@dump])
|
|
194
194
|
DumpRake::DumpReader.should_receive(:restore).with('dump/213.tgz')
|
|
195
195
|
grab_output{
|
|
@@ -201,7 +201,7 @@ 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
|
|
204
|
+
DumpRake::Dump.stub(:list)
|
|
205
205
|
DumpRake::Dump.should_receive(:list).with(:like => '213').and_return([])
|
|
206
206
|
grab_output{
|
|
207
207
|
DumpRake.restore(:like => '213')
|
|
@@ -209,9 +209,9 @@ describe DumpRake do
|
|
|
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
|
|
212
|
+
DumpRake::Dump.stub(:list).and_return([])
|
|
213
213
|
DumpRake::DumpReader.should_not_receive(:restore)
|
|
214
|
-
all_dumps =
|
|
214
|
+
all_dumps = double('all_dumps')
|
|
215
215
|
DumpRake::Dump.should_receive(:list).with().and_return(all_dumps)
|
|
216
216
|
grab_output{
|
|
217
217
|
$stderr.should_receive(:puts).with(kind_of(String))
|
|
@@ -221,7 +221,7 @@ describe DumpRake do
|
|
|
221
221
|
end
|
|
222
222
|
|
|
223
223
|
it "should call DumpReader.restore if there is desired version" do
|
|
224
|
-
@dump =
|
|
224
|
+
@dump = double('dump', :path => 'dump/213.tgz')
|
|
225
225
|
DumpRake::Dump.should_receive(:list).once.and_return([@dump])
|
|
226
226
|
DumpRake::DumpReader.should_receive(:restore).with('dump/213.tgz')
|
|
227
227
|
DumpRake.should_not_receive(:versions)
|
|
@@ -232,8 +232,8 @@ describe DumpRake do
|
|
|
232
232
|
end
|
|
233
233
|
|
|
234
234
|
it "should call DumpReader.restore on last version if found multiple matching versions" do
|
|
235
|
-
@dump_a =
|
|
236
|
-
@dump_b =
|
|
235
|
+
@dump_a = double('dump_a', :path => 'dump/213-a.tgz')
|
|
236
|
+
@dump_b = double('dump_b', :path => 'dump/213-b.tgz')
|
|
237
237
|
DumpRake::Dump.should_receive(:list).once.and_return([@dump_a, @dump_b])
|
|
238
238
|
DumpRake::DumpReader.should_receive(:restore).with('dump/213-b.tgz')
|
|
239
239
|
grab_output{
|
|
@@ -268,10 +268,10 @@ describe DumpRake do
|
|
|
268
268
|
}.each do |options, ids|
|
|
269
269
|
it "should call delete #{ids} dumps when called with #{options}" do
|
|
270
270
|
dumps = %w[a b c d e f g h i j].map do |s|
|
|
271
|
-
|
|
271
|
+
double("dump_#{s}", :ext => 'tgz', :path => double("dump_#{s}_path"))
|
|
272
272
|
end
|
|
273
273
|
tmp_dumps = %w[a b c].map do |s|
|
|
274
|
-
|
|
274
|
+
double("tmp_dump_#{s}", :ext => 'tmp', :path => double("tmp_dump_#{s}_path"))
|
|
275
275
|
end
|
|
276
276
|
all_dumps = tmp_dumps[0, 1] + dumps[0, 5] + tmp_dumps[1, 1] + dumps[5, 5] + tmp_dumps[2, 1]
|
|
277
277
|
|
|
@@ -298,17 +298,17 @@ describe DumpRake do
|
|
|
298
298
|
|
|
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
|
-
dump =
|
|
302
|
-
dump.stub
|
|
303
|
-
dump.path.stub
|
|
301
|
+
dump = double("dump_#{s}", :ext => 'tgz', :path => double("dump_#{s}_path"))
|
|
302
|
+
dump.stub(:lock).and_yield
|
|
303
|
+
dump.path.stub(:unlink)
|
|
304
304
|
dump
|
|
305
305
|
end
|
|
306
306
|
|
|
307
307
|
dumps[3].path.should_receive(:unlink).and_raise('Horrible error')
|
|
308
308
|
|
|
309
|
-
DumpRake::Dump.stub
|
|
309
|
+
DumpRake::Dump.stub(:list).and_return(dumps)
|
|
310
310
|
grab_output{
|
|
311
|
-
$stderr.stub
|
|
311
|
+
$stderr.stub(:puts)
|
|
312
312
|
$stderr.should_receive(:puts) do |s|
|
|
313
313
|
s[dumps[3].path.to_s].should_not be_nil
|
|
314
314
|
s['Horrible error'].should_not be_nil
|
data/spec/recipes/dump_spec.rb
CHANGED
|
@@ -47,7 +47,7 @@ describe "cap dump" do
|
|
|
47
47
|
|
|
48
48
|
describe "do_transfer" do
|
|
49
49
|
before do
|
|
50
|
-
@cap.dump.stub
|
|
50
|
+
@cap.dump.stub(:do_transfer_via)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
[:up, :down].each do |direction|
|
|
@@ -61,13 +61,13 @@ describe "cap dump" do
|
|
|
61
61
|
|
|
62
62
|
describe "if got_rsync?" do
|
|
63
63
|
it "should use rsync" do
|
|
64
|
-
@cap.dump.stub
|
|
64
|
+
@cap.dump.stub(:got_rsync?).and_return(true)
|
|
65
65
|
@cap.dump.should_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
|
|
70
|
+
@cap.dump.stub(:got_rsync?).and_return(true)
|
|
71
71
|
@cap.dump.should_receive(:do_transfer_via).with(:rsync, direction, 'a.tgz', 'b.tgz').and_raise('problem using rsync')
|
|
72
72
|
proc{
|
|
73
73
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
|
@@ -77,20 +77,20 @@ describe "cap dump" do
|
|
|
77
77
|
|
|
78
78
|
describe "unless got_rsync?" do
|
|
79
79
|
it "should try sftp" do
|
|
80
|
-
@cap.dump.stub
|
|
80
|
+
@cap.dump.stub(:got_rsync?).and_return(false)
|
|
81
81
|
@cap.dump.should_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
|
|
86
|
+
@cap.dump.stub(:got_rsync?).and_return(false)
|
|
87
87
|
@cap.dump.should_receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz').and_raise('problem using sftp')
|
|
88
88
|
@cap.dump.should_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
|
|
93
|
+
@cap.dump.stub(:got_rsync?).and_return(false)
|
|
94
94
|
@cap.dump.should_receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz').and_raise('problem using sftp')
|
|
95
95
|
@cap.dump.should_receive(:do_transfer_via).with(:scp, direction, 'a.tgz', 'b.tgz').and_raise('problem using scp')
|
|
96
96
|
proc{
|
|
@@ -117,7 +117,7 @@ describe "cap dump" do
|
|
|
117
117
|
})
|
|
118
118
|
|
|
119
119
|
it "should print result of rake task" do
|
|
120
|
-
@cap.dump.stub
|
|
120
|
+
@cap.dump.stub(:run_local).and_return(" 123M\t123123.tgz\n")
|
|
121
121
|
grab_output{
|
|
122
122
|
@cap.find_and_execute_task("dump:local:versions")
|
|
123
123
|
}[:stdout].should == " 123M\t123123.tgz\n"
|
|
@@ -137,7 +137,7 @@ describe "cap dump" do
|
|
|
137
137
|
})
|
|
138
138
|
|
|
139
139
|
it "should print result of rake task" do
|
|
140
|
-
@cap.dump.stub
|
|
140
|
+
@cap.dump.stub(:run_local).and_return("123123.tgz\n")
|
|
141
141
|
grab_output{
|
|
142
142
|
@cap.find_and_execute_task("dump:local:cleanup")
|
|
143
143
|
}[:stdout].should == "123123.tgz\n"
|
|
@@ -176,14 +176,14 @@ 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
|
|
179
|
+
@cap.dump.stub(:run_local).and_return("123123.tgz\n")
|
|
180
180
|
grab_output{
|
|
181
181
|
@cap.find_and_execute_task("dump:local:create")
|
|
182
182
|
}[:stdout].should == "123123.tgz\n"
|
|
183
183
|
end
|
|
184
184
|
|
|
185
185
|
it "should return stripped result of rake task" do
|
|
186
|
-
@cap.dump.stub
|
|
186
|
+
@cap.dump.stub(:run_local).and_return("123123.tgz\n")
|
|
187
187
|
grab_output{
|
|
188
188
|
@cap.find_and_execute_task("dump:local:create").should == "123123.tgz"
|
|
189
189
|
}
|
|
@@ -220,19 +220,19 @@ 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
|
|
223
|
+
@cap.dump.stub(:run_local).and_return('')
|
|
224
224
|
@cap.dump.should_not_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
|
|
229
|
+
@cap.dump.stub(:run_local).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
|
230
230
|
@cap.dump.should_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
|
|
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
236
|
@cap.dump.should_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
|
|
@@ -253,7 +253,7 @@ describe "cap dump" do
|
|
|
253
253
|
})
|
|
254
254
|
|
|
255
255
|
it "should print result of rake task" do
|
|
256
|
-
@cap.dump.stub
|
|
256
|
+
@cap.dump.stub(:run_remote).and_return(" 123M\t123123.tgz\n")
|
|
257
257
|
grab_output{
|
|
258
258
|
@cap.find_and_execute_task("dump:remote:versions")
|
|
259
259
|
}[:stdout].should == " 123M\t123123.tgz\n"
|
|
@@ -279,7 +279,7 @@ describe "cap dump" do
|
|
|
279
279
|
})
|
|
280
280
|
|
|
281
281
|
it "should print result of rake task" do
|
|
282
|
-
@cap.dump.stub
|
|
282
|
+
@cap.dump.stub(:run_remote).and_return("123123.tgz\n")
|
|
283
283
|
grab_output{
|
|
284
284
|
@cap.find_and_execute_task("dump:remote:cleanup")
|
|
285
285
|
}[:stdout].should == "123123.tgz\n"
|
|
@@ -332,14 +332,14 @@ 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
|
|
335
|
+
@cap.dump.stub(:run_remote).and_return("123123.tgz\n")
|
|
336
336
|
grab_output{
|
|
337
337
|
@cap.find_and_execute_task("dump:remote:create")
|
|
338
338
|
}[:stdout].should == "123123.tgz\n"
|
|
339
339
|
end
|
|
340
340
|
|
|
341
341
|
it "should return stripped result of rake task" do
|
|
342
|
-
@cap.dump.stub
|
|
342
|
+
@cap.dump.stub(:run_remote).and_return("123123.tgz\n")
|
|
343
343
|
grab_output{
|
|
344
344
|
@cap.find_and_execute_task("dump:remote:create").should == "123123.tgz"
|
|
345
345
|
}
|
|
@@ -405,28 +405,28 @@ 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
|
|
408
|
+
@cap.dump.stub(:run_remote).and_return('')
|
|
409
409
|
@cap.dump.should_not_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
|
|
414
|
+
@cap.dump.stub(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
|
415
415
|
@cap.dump.should_receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", "dump/300.tgz")
|
|
416
|
-
FileUtils.stub
|
|
416
|
+
FileUtils.stub(: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
|
|
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
422
|
@cap.dump.should_receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", "dump/300.tgz")
|
|
423
|
-
FileUtils.stub
|
|
423
|
+
FileUtils.stub(: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
|
|
429
|
-
@cap.dump.stub
|
|
428
|
+
@cap.dump.stub(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
|
429
|
+
@cap.dump.stub(:do_transfer)
|
|
430
430
|
FileUtils.should_receive(:mkpath).with('dump')
|
|
431
431
|
@cap.find_and_execute_task("dump:remote:download")
|
|
432
432
|
end
|
|
@@ -457,19 +457,19 @@ describe "cap dump" do
|
|
|
457
457
|
end
|
|
458
458
|
|
|
459
459
|
it "should not call local:create if auto-backup fails" do
|
|
460
|
-
@cap.dump.namespaces[dst].stub
|
|
460
|
+
@cap.dump.namespaces[dst].stub(:create).and_return('')
|
|
461
461
|
@cap.dump.namespaces[src].should_not_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
|
|
466
|
+
@cap.dump.namespaces[dst].stub(:create).and_return('123.tgz')
|
|
467
467
|
@cap.dump.namespaces[src].should_receive(:create){ DumpRake::Env[:tags].should == "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
|
|
472
|
+
@cap.dump.namespaces[dst].stub(:create).and_return('123.tgz')
|
|
473
473
|
@cap.dump.namespaces[src].should_receive(:create){ DumpRake::Env[:tags].should == "mirror,photos"; '' }
|
|
474
474
|
DumpRake::Env.with_env :tags => 'photos' do
|
|
475
475
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
|
@@ -477,16 +477,16 @@ describe "cap dump" do
|
|
|
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
|
|
481
|
-
@cap.dump.namespaces[src].stub
|
|
480
|
+
@cap.dump.namespaces[dst].stub(:create).and_return('123.tgz')
|
|
481
|
+
@cap.dump.namespaces[src].stub(:create).and_return('')
|
|
482
482
|
@cap.dump.namespaces[src].should_not_receive(:upload)
|
|
483
483
|
@cap.dump.namespaces[dst].should_not_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
|
|
489
|
-
@cap.dump.namespaces[src].stub
|
|
488
|
+
@cap.dump.namespaces[dst].stub(:create).and_return('123.tgz')
|
|
489
|
+
@cap.dump.namespaces[src].stub(:create).and_return('123.tgz')
|
|
490
490
|
test_env = proc{
|
|
491
491
|
DumpRake::Env[:like].should == '123.tgz'
|
|
492
492
|
DumpRake::Env[:tags].should == nil
|
|
@@ -509,13 +509,13 @@ describe "cap dump" do
|
|
|
509
509
|
end
|
|
510
510
|
|
|
511
511
|
it "should not call remote:download if remote:create returns blank" do
|
|
512
|
-
@cap.dump.remote.stub
|
|
512
|
+
@cap.dump.remote.stub(:create).and_return('')
|
|
513
513
|
@cap.dump.remote.should_not_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
|
|
518
|
+
@cap.dump.remote.stub(:create).and_return('123.tgz')
|
|
519
519
|
@cap.dump.remote.should_receive(:download).ordered
|
|
520
520
|
@cap.find_and_execute_task("dump:backup")
|
|
521
521
|
end
|
|
@@ -549,7 +549,7 @@ describe "cap dump" do
|
|
|
549
549
|
end
|
|
550
550
|
|
|
551
551
|
it "should send only ver variable" do
|
|
552
|
-
@cap.dump.remote.stub
|
|
552
|
+
@cap.dump.remote.stub(:create).and_return('123.tgz')
|
|
553
553
|
def (@cap.dump.remote).download
|
|
554
554
|
DumpRake::Env[:like].should == '123.tgz'
|
|
555
555
|
DumpRake::Env[:tags].should == nil
|