dump 1.2.2 → 1.3.0

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 (232) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +6 -0
  3. data/.github/workflows/check.yml +102 -0
  4. data/.github/workflows/rubocop.yml +16 -0
  5. data/.rubocop.yml +24 -1
  6. data/.rubocop_todo.yml +27 -29
  7. data/Appraisals +59 -21
  8. data/Gemfile +6 -4
  9. data/LICENSE.txt +1 -1
  10. data/README.markdown +6 -6
  11. data/dump.gemspec +7 -4
  12. data/lib/dump/capistrano/v2.rb +21 -23
  13. data/lib/dump/continious_timeout.rb +4 -6
  14. data/lib/dump/env/filter.rb +1 -0
  15. data/lib/dump/env.rb +7 -7
  16. data/lib/dump/reader.rb +3 -5
  17. data/lib/dump/snapshot.rb +24 -31
  18. data/lib/dump/table_manipulation.rb +7 -7
  19. data/lib/dump/writer.rb +40 -27
  20. data/lib/tasks/assets.rake +1 -1
  21. data/lib/tasks/dump.rake +5 -5
  22. data/spec/.gitignore +2 -0
  23. data/spec/cycle_spec.rb +14 -22
  24. data/spec/dummy-2.3/config/initializers/abstract_mysql2_adapter.rb +4 -0
  25. data/spec/dummy-3.1/config/initializers/abstract_mysql2_adapter.rb +4 -0
  26. data/spec/dummy-3.2/config/initializers/abstract_mysql2_adapter.rb +4 -0
  27. data/spec/dummy-4.0/config/initializers/abstract_mysql2_adapter.rb +4 -0
  28. data/spec/dummy-4.1/config/initializers/abstract_mysql2_adapter.rb +4 -0
  29. data/spec/dummy-4.2/config/initializers/abstract_mysql2_adapter.rb +4 -0
  30. data/spec/dummy-6.0/.gitignore +28 -0
  31. data/spec/dummy-6.0/config/application.rb +35 -0
  32. data/spec/dummy-6.0/config/boot.rb +5 -0
  33. data/spec/dummy-6.0/config/cable.yml +10 -0
  34. data/spec/{dummy-3.0 → dummy-6.0}/config/database.yml +13 -10
  35. data/spec/dummy-6.0/config/environment.rb +5 -0
  36. data/spec/dummy-6.0/config/environments/development.rb +55 -0
  37. data/spec/dummy-6.0/config/environments/production.rb +106 -0
  38. data/spec/dummy-6.0/config/environments/test.rb +48 -0
  39. data/spec/dummy-6.0/config/initializers/application_controller_renderer.rb +8 -0
  40. data/spec/dummy-6.0/config/initializers/content_security_policy.rb +28 -0
  41. data/spec/dummy-6.0/config/initializers/cookies_serializer.rb +5 -0
  42. data/spec/dummy-6.0/config/initializers/filter_parameter_logging.rb +4 -0
  43. data/spec/dummy-6.0/config/initializers/inflections.rb +16 -0
  44. data/spec/{dummy-3.0 → dummy-6.0}/config/initializers/mime_types.rb +0 -1
  45. data/spec/dummy-6.0/config/initializers/wrap_parameters.rb +14 -0
  46. data/spec/dummy-6.0/config/locales/en.yml +33 -0
  47. data/spec/dummy-6.0/config/puma.rb +38 -0
  48. data/spec/dummy-6.0/config/routes.rb +3 -0
  49. data/spec/dummy-6.0/config/spring.rb +6 -0
  50. data/spec/dummy-6.0/config/storage.yml +34 -0
  51. data/spec/dummy-6.0/config.ru +5 -0
  52. data/spec/dummy-6.0/db/seeds.rb +7 -0
  53. data/spec/dummy-6.0/log/.keep +0 -0
  54. data/spec/dummy-6.0/storage/.keep +0 -0
  55. data/spec/dummy-6.1/.gitattributes +8 -0
  56. data/spec/dummy-6.1/.gitignore +33 -0
  57. data/spec/dummy-6.1/config/application.rb +38 -0
  58. data/spec/dummy-6.1/config/boot.rb +5 -0
  59. data/spec/dummy-6.1/config/cable.yml +10 -0
  60. data/spec/dummy-6.1/config/database.yml +25 -0
  61. data/spec/dummy-6.1/config/environment.rb +5 -0
  62. data/spec/dummy-6.1/config/environments/development.rb +69 -0
  63. data/spec/dummy-6.1/config/environments/production.rb +114 -0
  64. data/spec/dummy-6.1/config/environments/test.rb +60 -0
  65. data/spec/dummy-6.1/config/initializers/application_controller_renderer.rb +8 -0
  66. data/spec/dummy-6.1/config/initializers/backtrace_silencers.rb +8 -0
  67. data/spec/dummy-6.1/config/initializers/content_security_policy.rb +28 -0
  68. data/spec/dummy-6.1/config/initializers/cookies_serializer.rb +5 -0
  69. data/spec/dummy-6.1/config/initializers/filter_parameter_logging.rb +6 -0
  70. data/spec/dummy-6.1/config/initializers/inflections.rb +16 -0
  71. data/spec/dummy-6.1/config/initializers/mime_types.rb +4 -0
  72. data/spec/dummy-6.1/config/initializers/permissions_policy.rb +11 -0
  73. data/spec/dummy-6.1/config/initializers/wrap_parameters.rb +14 -0
  74. data/spec/dummy-6.1/config/locales/en.yml +33 -0
  75. data/spec/dummy-6.1/config/puma.rb +43 -0
  76. data/spec/dummy-6.1/config/routes.rb +3 -0
  77. data/spec/dummy-6.1/config/spring.rb +6 -0
  78. data/spec/dummy-6.1/config/storage.yml +34 -0
  79. data/spec/dummy-6.1/config.ru +6 -0
  80. data/spec/dummy-6.1/db/seeds.rb +7 -0
  81. data/spec/dummy-6.1/log/.keep +0 -0
  82. data/spec/dummy-6.1/storage/.keep +0 -0
  83. data/spec/dummy-7.0/.gitattributes +7 -0
  84. data/spec/dummy-7.0/.gitignore +35 -0
  85. data/spec/dummy-7.0/config/application.rb +37 -0
  86. data/spec/dummy-7.0/config/boot.rb +3 -0
  87. data/spec/dummy-7.0/config/cable.yml +10 -0
  88. data/spec/dummy-7.0/config/database.yml +25 -0
  89. data/spec/dummy-7.0/config/environment.rb +5 -0
  90. data/spec/dummy-7.0/config/environments/development.rb +70 -0
  91. data/spec/dummy-7.0/config/environments/production.rb +93 -0
  92. data/spec/dummy-7.0/config/environments/test.rb +60 -0
  93. data/spec/dummy-7.0/config/initializers/assets.rb +12 -0
  94. data/spec/dummy-7.0/config/initializers/content_security_policy.rb +25 -0
  95. data/spec/dummy-7.0/config/initializers/filter_parameter_logging.rb +8 -0
  96. data/spec/dummy-7.0/config/initializers/inflections.rb +16 -0
  97. data/spec/dummy-7.0/config/initializers/permissions_policy.rb +11 -0
  98. data/spec/dummy-7.0/config/locales/en.yml +33 -0
  99. data/spec/dummy-7.0/config/puma.rb +43 -0
  100. data/spec/dummy-7.0/config/routes.rb +6 -0
  101. data/spec/dummy-7.0/config/storage.yml +34 -0
  102. data/spec/dummy-7.0/config.ru +6 -0
  103. data/spec/dummy-7.0/db/seeds.rb +7 -0
  104. data/spec/dummy-7.0/log/.keep +0 -0
  105. data/spec/dummy-7.0/storage/.keep +0 -0
  106. data/spec/dummy-7.1/.gitattributes +9 -0
  107. data/spec/dummy-7.1/.gitignore +35 -0
  108. data/spec/dummy-7.1/Dockerfile +58 -0
  109. data/spec/dummy-7.1/config/application.rb +42 -0
  110. data/spec/dummy-7.1/config/boot.rb +3 -0
  111. data/spec/dummy-7.1/config/cable.yml +10 -0
  112. data/spec/dummy-7.1/config/database.yml +25 -0
  113. data/spec/dummy-7.1/config/environment.rb +5 -0
  114. data/spec/dummy-7.1/config/environments/development.rb +76 -0
  115. data/spec/dummy-7.1/config/environments/production.rb +97 -0
  116. data/spec/dummy-7.1/config/environments/test.rb +64 -0
  117. data/spec/dummy-7.1/config/initializers/assets.rb +12 -0
  118. data/spec/dummy-7.1/config/initializers/content_security_policy.rb +25 -0
  119. data/spec/dummy-7.1/config/initializers/filter_parameter_logging.rb +8 -0
  120. data/spec/dummy-7.1/config/initializers/inflections.rb +16 -0
  121. data/spec/dummy-7.1/config/initializers/permissions_policy.rb +13 -0
  122. data/spec/dummy-7.1/config/locales/en.yml +31 -0
  123. data/spec/dummy-7.1/config/puma.rb +44 -0
  124. data/spec/dummy-7.1/config/routes.rb +10 -0
  125. data/spec/dummy-7.1/config/storage.yml +34 -0
  126. data/spec/dummy-7.1/config.ru +6 -0
  127. data/spec/dummy-7.1/db/seeds.rb +9 -0
  128. data/spec/dummy-7.1/log/.keep +0 -0
  129. data/spec/dummy-7.1/storage/.keep +0 -0
  130. data/spec/dummy-7.2/.gitattributes +9 -0
  131. data/spec/dummy-7.2/.gitignore +35 -0
  132. data/spec/dummy-7.2/.rubocop.yml +8 -0
  133. data/spec/dummy-7.2/Dockerfile +65 -0
  134. data/spec/dummy-7.2/config/application.rb +42 -0
  135. data/spec/dummy-7.2/config/boot.rb +3 -0
  136. data/spec/dummy-7.2/config/cable.yml +10 -0
  137. data/spec/dummy-7.2/config/database.yml +32 -0
  138. data/spec/dummy-7.2/config/environment.rb +5 -0
  139. data/spec/dummy-7.2/config/environments/development.rb +81 -0
  140. data/spec/dummy-7.2/config/environments/production.rb +105 -0
  141. data/spec/dummy-7.2/config/environments/test.rb +67 -0
  142. data/spec/dummy-7.2/config/initializers/assets.rb +12 -0
  143. data/spec/dummy-7.2/config/initializers/content_security_policy.rb +25 -0
  144. data/spec/dummy-7.2/config/initializers/filter_parameter_logging.rb +8 -0
  145. data/spec/dummy-7.2/config/initializers/inflections.rb +16 -0
  146. data/spec/dummy-7.2/config/initializers/permissions_policy.rb +13 -0
  147. data/spec/dummy-7.2/config/locales/en.yml +31 -0
  148. data/spec/dummy-7.2/config/puma.rb +34 -0
  149. data/spec/dummy-7.2/config/routes.rb +14 -0
  150. data/spec/dummy-7.2/config/storage.yml +34 -0
  151. data/spec/dummy-7.2/config.ru +6 -0
  152. data/spec/dummy-7.2/db/seeds.rb +9 -0
  153. data/spec/dummy-7.2/log/.keep +0 -0
  154. data/spec/dummy-7.2/storage/.keep +0 -0
  155. data/spec/dummy-8.0/.gitattributes +9 -0
  156. data/spec/dummy-8.0/.gitignore +34 -0
  157. data/spec/dummy-8.0/.rubocop.yml +8 -0
  158. data/spec/dummy-8.0/Dockerfile +68 -0
  159. data/spec/dummy-8.0/config/application.rb +42 -0
  160. data/spec/dummy-8.0/config/boot.rb +3 -0
  161. data/spec/dummy-8.0/config/cable.yml +10 -0
  162. data/spec/dummy-8.0/config/database.yml +41 -0
  163. data/spec/dummy-8.0/config/environment.rb +5 -0
  164. data/spec/dummy-8.0/config/environments/development.rb +72 -0
  165. data/spec/dummy-8.0/config/environments/production.rb +89 -0
  166. data/spec/dummy-8.0/config/environments/test.rb +53 -0
  167. data/spec/dummy-8.0/config/initializers/assets.rb +7 -0
  168. data/spec/dummy-8.0/config/initializers/content_security_policy.rb +25 -0
  169. data/spec/dummy-8.0/config/initializers/filter_parameter_logging.rb +8 -0
  170. data/spec/dummy-8.0/config/initializers/inflections.rb +16 -0
  171. data/spec/dummy-8.0/config/locales/en.yml +31 -0
  172. data/spec/dummy-8.0/config/puma.rb +41 -0
  173. data/spec/dummy-8.0/config/routes.rb +14 -0
  174. data/spec/dummy-8.0/config/storage.yml +34 -0
  175. data/spec/dummy-8.0/config.ru +6 -0
  176. data/spec/dummy-8.0/db/seeds.rb +9 -0
  177. data/spec/dummy-8.0/log/.keep +0 -0
  178. data/spec/dummy-8.0/storage/.keep +0 -0
  179. data/spec/dummy-8.1/.gitattributes +9 -0
  180. data/spec/dummy-8.1/.gitignore +35 -0
  181. data/spec/dummy-8.1/.rubocop.yml +8 -0
  182. data/spec/dummy-8.1/Dockerfile +71 -0
  183. data/spec/dummy-8.1/config/application.rb +42 -0
  184. data/spec/dummy-8.1/config/boot.rb +3 -0
  185. data/spec/dummy-8.1/config/bundler-audit.yml +5 -0
  186. data/spec/dummy-8.1/config/cable.yml +10 -0
  187. data/spec/dummy-8.1/config/ci.rb +19 -0
  188. data/spec/dummy-8.1/config/database.yml +40 -0
  189. data/spec/dummy-8.1/config/environment.rb +5 -0
  190. data/spec/dummy-8.1/config/environments/development.rb +78 -0
  191. data/spec/dummy-8.1/config/environments/production.rb +89 -0
  192. data/spec/dummy-8.1/config/environments/test.rb +53 -0
  193. data/spec/dummy-8.1/config/initializers/assets.rb +7 -0
  194. data/spec/dummy-8.1/config/initializers/content_security_policy.rb +29 -0
  195. data/spec/dummy-8.1/config/initializers/filter_parameter_logging.rb +8 -0
  196. data/spec/dummy-8.1/config/initializers/inflections.rb +16 -0
  197. data/spec/dummy-8.1/config/locales/en.yml +31 -0
  198. data/spec/dummy-8.1/config/puma.rb +42 -0
  199. data/spec/dummy-8.1/config/routes.rb +14 -0
  200. data/spec/dummy-8.1/config/storage.yml +27 -0
  201. data/spec/dummy-8.1/config.ru +6 -0
  202. data/spec/dummy-8.1/db/seeds.rb +9 -0
  203. data/spec/dummy-8.1/log/.keep +0 -0
  204. data/spec/dummy-8.1/storage/.keep +0 -0
  205. data/spec/dummy_rails_app.rb +1 -1
  206. data/spec/dump/env_spec.rb +8 -23
  207. data/spec/dump/reader_spec.rb +12 -14
  208. data/spec/dump/snapshot_spec.rb +9 -13
  209. data/spec/dump/table_manipulation_spec.rb +3 -3
  210. data/spec/dump/writer_spec.rb +7 -4
  211. data/spec/dump_spec.rb +5 -5
  212. data/spec/recipes/dump_spec.rb +40 -38
  213. data/spec/tasks/assets_spec.rb +3 -3
  214. metadata +395 -50
  215. data/.travis.database.yml +0 -14
  216. data/.travis.yml +0 -34
  217. data/.travis_check_rubies.yml +0 -1
  218. data/spec/dummy-3.0/.gitignore +0 -4
  219. data/spec/dummy-3.0/config/application.rb +0 -42
  220. data/spec/dummy-3.0/config/boot.rb +0 -6
  221. data/spec/dummy-3.0/config/environment.rb +0 -5
  222. data/spec/dummy-3.0/config/environments/development.rb +0 -26
  223. data/spec/dummy-3.0/config/environments/production.rb +0 -49
  224. data/spec/dummy-3.0/config/environments/test.rb +0 -35
  225. data/spec/dummy-3.0/config/initializers/inflections.rb +0 -10
  226. data/spec/dummy-3.0/config/initializers/secret_token.rb +0 -7
  227. data/spec/dummy-3.0/config/initializers/session_store.rb +0 -8
  228. data/spec/dummy-3.0/config/locales/en.yml +0 -5
  229. data/spec/dummy-3.0/config/routes.rb +0 -58
  230. data/spec/dummy-3.0/config.ru +0 -4
  231. data/spec/dummy-3.0/db/seeds.rb +0 -7
  232. /data/spec/{dummy-3.0 → dummy-6.0}/config/initializers/backtrace_silencers.rb +0 -0
@@ -30,9 +30,7 @@ describe Dump::Snapshot do
30
30
 
31
31
  @file = double('file')
32
32
  expect(@file).to receive(:flock).with(File::LOCK_EX | File::LOCK_NB).and_return(nil)
33
- expect(@file).to receive(:flock).with(File::LOCK_UN)
34
- expect(@file).to receive(:close)
35
- expect(File).to receive(:open).and_return(@file)
33
+ expect(File).to receive(:open).and_yield(@file)
36
34
 
37
35
  described_class.new('hello').lock do
38
36
  @yield_receiver.fire
@@ -44,9 +42,7 @@ describe Dump::Snapshot do
44
42
 
45
43
  @file = double('file')
46
44
  expect(@file).to receive(:flock).with(File::LOCK_EX | File::LOCK_NB).and_return(true)
47
- expect(@file).to receive(:flock).with(File::LOCK_UN)
48
- expect(@file).to receive(:close)
49
- expect(File).to receive(:open).and_return(@file)
45
+ expect(File).to receive(:open).and_yield(@file)
50
46
 
51
47
  described_class.new('hello').lock do
52
48
  @yield_receiver.fire
@@ -125,7 +121,7 @@ describe Dump::Snapshot do
125
121
  # 0 1 2 3 4 5 6 7 8 9 10 11 12 131415 16
126
122
  dumps_tags = [''] + %w[a a,d a,d,o a,d,s a,d,s,o a,o a,s a,s,o d d,o d,s d,s,o o s s,o z]
127
123
  paths = dumps_tags.each_with_index.map do |dump_tags, i|
128
- path = dump_path("196504140659#{10 + i}@#{dump_tags}.tgz")
124
+ path = dump_path("196504140659#{i + 10}@#{dump_tags}.tgz")
129
125
  expect(File).to receive(:file?).with(path).at_least(1).and_return(true)
130
126
  path
131
127
  end
@@ -264,18 +260,18 @@ describe Dump::Snapshot do
264
260
 
265
261
  describe 'get_filter_tags' do
266
262
  it 'splits string and returns uniq non blank sorted tags' do
267
- expect(described_class.new('').send(:get_filter_tags, 'a,+b,+c,-d')).to eq(:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d])
268
- expect(described_class.new('').send(:get_filter_tags, ' a , + b , + c , - d ')).to eq(:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d])
269
- expect(described_class.new('').send(:get_filter_tags, ' a , + c , + b , - d ')).to eq(:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d])
270
- expect(described_class.new('').send(:get_filter_tags, ' a , + b , + , - ')).to eq(:simple => %w[a], :mandatory => %w[b], :forbidden => [])
271
- expect(described_class.new('').send(:get_filter_tags, ' a , a , + b , + b , - d , - d ')).to eq(:simple => %w[a], :mandatory => %w[b], :forbidden => %w[d])
263
+ expect(described_class.new('').send(:get_filter_tags, 'a,+b,+c,-d')).to eq(:any => %w[a].to_set, :all => %w[b c].to_set, :none => %w[d].to_set)
264
+ expect(described_class.new('').send(:get_filter_tags, ' a , + b , + c , - d ')).to eq(:any => %w[a].to_set, :all => %w[b c].to_set, :none => %w[d].to_set)
265
+ expect(described_class.new('').send(:get_filter_tags, ' a , + c , + b , - d ')).to eq(:any => %w[a].to_set, :all => %w[b c].to_set, :none => %w[d].to_set)
266
+ expect(described_class.new('').send(:get_filter_tags, ' a , + b , + , - ')).to eq(:any => %w[a].to_set, :all => %w[b].to_set, :none => [].to_set)
267
+ expect(described_class.new('').send(:get_filter_tags, ' a , a , + b , + b , - d , - d ')).to eq(:any => %w[a].to_set, :all => %w[b].to_set, :none => %w[d].to_set)
272
268
  expect{ described_class.new('').send(:get_filter_tags, 'a,+a') }.not_to raise_error
273
269
  expect{ described_class.new('').send(:get_filter_tags, 'a,-a') }.to raise_error ArgumentError, /clashes/
274
270
  expect{ described_class.new('').send(:get_filter_tags, '+a,-a') }.to raise_error ArgumentError, /clashes/
275
271
  end
276
272
 
277
273
  it 'accepts non string' do
278
- expect(described_class.new('').send(:get_filter_tags, nil)).to eq(:simple => [], :mandatory => [], :forbidden => [])
274
+ expect(described_class.new('').send(:get_filter_tags, nil)).to eq(:any => Set.new, :all => Set.new, :none => Set.new)
279
275
  end
280
276
  end
281
277
 
@@ -141,8 +141,8 @@ describe Dump::TableManipulation do
141
141
  describe 'table_chunk_size' do
142
142
  it 'returns chunk_size based on estimated average for row size' do
143
143
  expect(self).to receive(:table_columns).with('first').and_return(
144
- [double(:column, :type => :integer, :limit => nil)] * 3 +
145
- [double(:column, :type => :string, :limit => nil)] * 3 +
144
+ ([double(:column, :type => :integer, :limit => nil)] * 3) +
145
+ ([double(:column, :type => :string, :limit => nil)] * 3) +
146
146
  [double(:column, :type => :text, :limit => nil)]
147
147
  )
148
148
  expect(table_chunk_size('first')).to satisfy{ |n|
@@ -228,7 +228,7 @@ describe Dump::TableManipulation do
228
228
 
229
229
  expect(self).to receive(:select_all_by_sql).with(sql % '>= 0').and_return(@rows[0, 100])
230
230
  5.times do |i|
231
- last_primary_key = 100 + i * 100
231
+ last_primary_key = (i * 100) + 100
232
232
  expect(self).to receive(:select_all_by_sql).with(sql % "> #{last_primary_key}").and_return(@rows[last_primary_key, 100])
233
233
  end
234
234
 
@@ -30,16 +30,19 @@ describe Writer do
30
30
 
31
31
  describe 'open' do
32
32
  it 'creates dir for dump' do
33
- allow(Zlib::GzipWriter).to receive(:open)
34
- expect(FileUtils).to receive(:mkpath).with('/abc/def/ghi')
33
+ @gzip = double('gzip', :mtime= => nil)
34
+ allow(Zlib::GzipWriter).to receive(:open).and_return(@gzip)
35
+ allow(Dir).to receive(:mkdir).with('/abc')
36
+ allow(Dir).to receive(:mkdir).with('/abc/def')
37
+ allow(Dir).to receive(:mkdir).with('/abc/def/ghi')
35
38
  described_class.new('/abc/def/ghi/123.tgz').open
36
39
  end
37
40
 
38
41
  it 'sets stream to gzipped tar writer' do
39
- allow(FileUtils).to receive(:mkpath)
42
+ allow(Dir).to receive(:mkdir)
40
43
  @gzip = double('gzip')
41
44
  @stream = double('stream')
42
- expect(Zlib::GzipWriter).to receive(:open).with(Pathname('123.tgz')).and_yield(@gzip)
45
+ expect(Zlib::GzipWriter).to receive(:open).with(Pathname('123.tgz')).and_return(@gzip)
43
46
  expect(Archive::Tar::Minitar::Output).to receive(:open).with(@gzip).and_yield(@stream)
44
47
  expect(@gzip).to receive(:mtime=).with(Time.utc(2000))
45
48
 
data/spec/dump_spec.rb CHANGED
@@ -11,7 +11,7 @@ describe Dump do
11
11
  end
12
12
 
13
13
  it 'calls Snapshot.list with options if called with version' do
14
- expect(Dump::Snapshot).to receive(:list).with(:like => '123').and_return([])
14
+ expect(Dump::Snapshot).to receive(:list).with({:like => '123'}).and_return([])
15
15
  described_class.versions(:like => '123')
16
16
  end
17
17
 
@@ -205,7 +205,7 @@ describe Dump do
205
205
  describe 'with version' do
206
206
  it 'calls Snapshot.list with options' do
207
207
  allow(Dump::Snapshot).to receive(:list)
208
- expect(Dump::Snapshot).to receive(:list).with(:like => '213').and_return([])
208
+ expect(Dump::Snapshot).to receive(:list).with({:like => '213'}).and_return([])
209
209
  grab_output do
210
210
  described_class.restore(:like => '213')
211
211
  end
@@ -249,14 +249,14 @@ describe Dump do
249
249
 
250
250
  describe 'cleanup' do
251
251
  it 'calls ask for all files in dump dir and for dumps' do
252
- expect(Dump::Snapshot).to receive(:list).with(:all => true).and_return([])
252
+ expect(Dump::Snapshot).to receive(:list).with({:all => true}).and_return([])
253
253
  expect(Dump::Snapshot).to receive(:list).with({}).and_return([])
254
254
  described_class.cleanup
255
255
  end
256
256
 
257
257
  it 'calls Snapshot.list with options if called with version and tags' do
258
- expect(Dump::Snapshot).to receive(:list).with(:like => '123', :tags => 'a,b,c', :all => true).and_return([])
259
- expect(Dump::Snapshot).to receive(:list).with(:like => '123', :tags => 'a,b,c').and_return([])
258
+ expect(Dump::Snapshot).to receive(:list).with({:like => '123', :tags => 'a,b,c', :all => true}).and_return([])
259
+ expect(Dump::Snapshot).to receive(:list).with({:like => '123', :tags => 'a,b,c'}).and_return([])
260
260
  described_class.cleanup(:like => '123', :tags => 'a,b,c')
261
261
  end
262
262
 
@@ -5,6 +5,8 @@ require 'dump'
5
5
  require 'capistrano'
6
6
 
7
7
  describe 'cap dump' do
8
+ plus = '+'.shellescape
9
+
8
10
  before do
9
11
  @cap = Capistrano::Configuration.new
10
12
  Capistrano::Configuration.instance = @cap
@@ -253,14 +255,14 @@ describe 'cap dump' do
253
255
 
254
256
  describe 'versions' do
255
257
  it 'calls remote rake task' do
256
- 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('')
258
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production SHOW_SIZE\\=true").and_return('')
257
259
  @cap.find_and_execute_task('dump:remote:versions')
258
260
  end
259
261
 
260
262
  test_passing_environment_variables(:remote, :versions, {
261
- :like => 'rake -s dump:versions LIKE\\=some\\ data PROGRESS_TTY\\=\\+ RAILS_ENV\\=production SHOW_SIZE\\=true',
262
- :tags => 'rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production SHOW_SIZE\\=true TAGS\\=some\\ data',
263
- :summary => 'rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production SHOW_SIZE\\=true SUMMARY\\=some\\ data',
263
+ :like => "rake -s dump:versions LIKE\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production SHOW_SIZE\\=true",
264
+ :tags => "rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production SHOW_SIZE\\=true TAGS\\=some\\ data",
265
+ :summary => "rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production SHOW_SIZE\\=true SUMMARY\\=some\\ data",
264
266
  })
265
267
 
266
268
  it 'prints result of rake task' do
@@ -272,21 +274,21 @@ describe 'cap dump' do
272
274
 
273
275
  it 'uses custom rake binary' do
274
276
  expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
275
- 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('')
277
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production SHOW_SIZE\\=true").and_return('')
276
278
  @cap.find_and_execute_task('dump:remote:versions')
277
279
  end
278
280
  end
279
281
 
280
282
  describe 'cleanup' do
281
283
  it 'calls remote rake task' do
282
- expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:cleanup PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
284
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:cleanup PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production").and_return('')
283
285
  @cap.find_and_execute_task('dump:remote:cleanup')
284
286
  end
285
287
 
286
288
  test_passing_environment_variables(:remote, :cleanup, {
287
- :like => 'rake -s dump:cleanup LIKE\\=some\\ data PROGRESS_TTY\\=\\+ RAILS_ENV\\=production',
288
- :tags => 'rake -s dump:cleanup PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=some\\ data',
289
- :leave => 'rake -s dump:cleanup LEAVE\\=some\\ data PROGRESS_TTY\\=\\+ RAILS_ENV\\=production',
289
+ :like => "rake -s dump:cleanup LIKE\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production",
290
+ :tags => "rake -s dump:cleanup PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=some\\ data",
291
+ :leave => "rake -s dump:cleanup LEAVE\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production",
290
292
  })
291
293
 
292
294
  it 'prints result of rake task' do
@@ -298,28 +300,28 @@ describe 'cap dump' do
298
300
 
299
301
  it 'uses custom rake binary' do
300
302
  expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
301
- expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:cleanup PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
303
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:cleanup PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production").and_return('')
302
304
  @cap.find_and_execute_task('dump:remote:cleanup')
303
305
  end
304
306
  end
305
307
 
306
308
  describe 'create' do
307
309
  it 'raises if dump creation fails' do
308
- expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote").and_return('')
310
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote").and_return('')
309
311
  expect do
310
312
  @cap.find_and_execute_task('dump:remote:create')
311
313
  end.to raise_error('Failed creating dump')
312
314
  end
313
315
 
314
316
  it 'calls remote rake task with default rails_env and tag remote' do
315
- 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')
317
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote").and_return('123.tgz')
316
318
  grab_output do
317
319
  @cap.find_and_execute_task('dump:remote:create')
318
320
  end
319
321
  end
320
322
 
321
323
  it 'calls remote rake task with default rails_env and additional tag remote' do
322
- 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')
324
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote,photos").and_return('123.tgz')
323
325
  grab_output do
324
326
  Dump::Env.with_env :tags => 'photos' do
325
327
  @cap.find_and_execute_task('dump:remote:create')
@@ -329,17 +331,17 @@ describe 'cap dump' do
329
331
 
330
332
  it 'calls remote rake task with fetched rails_env and default DESC remote' do
331
333
  expect(@cap.dump).to receive(:fetch_rails_env).and_return('dev')
332
- 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')
334
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=dev TAGS\\=remote").and_return('123.tgz')
333
335
  grab_output do
334
336
  @cap.find_and_execute_task('dump:remote:create')
335
337
  end
336
338
  end
337
339
 
338
340
  test_passing_environment_variables(:remote, :create, {
339
- :desc => 'rake -s dump:create DESC\\=some\\ data PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote',
340
- :tags => 'rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote,some\\ data',
341
- :assets => 'rake -s dump:create ASSETS\\=some\\ data PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote',
342
- :tables => 'rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TABLES\\=some\\ data TAGS\\=remote',
341
+ :desc => "rake -s dump:create DESC\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote",
342
+ :tags => "rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote,some\\ data",
343
+ :assets => "rake -s dump:create ASSETS\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote",
344
+ :tables => "rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TABLES\\=some\\ data TAGS\\=remote",
343
345
  }, :return_value => '123.tgz')
344
346
 
345
347
  it 'prints result of rake task' do
@@ -358,7 +360,7 @@ describe 'cap dump' do
358
360
 
359
361
  it 'uses custom rake binary' do
360
362
  expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
361
- 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')
363
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:create PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=remote").and_return('123.tgz')
362
364
  grab_output do
363
365
  @cap.find_and_execute_task('dump:remote:create')
364
366
  end
@@ -367,40 +369,40 @@ describe 'cap dump' do
367
369
 
368
370
  describe 'restore' do
369
371
  it 'calls remote rake task with default rails_env' do
370
- expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production")
372
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production")
371
373
  @cap.find_and_execute_task('dump:remote:restore')
372
374
  end
373
375
 
374
376
  it 'calls remote rake task with fetched rails_env' do
375
377
  expect(@cap.dump).to receive(:fetch_rails_env).and_return('dev')
376
- expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=dev")
378
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=dev")
377
379
  @cap.find_and_execute_task('dump:remote:restore')
378
380
  end
379
381
 
380
382
  test_passing_environment_variables(:remote, :restore, {
381
- :like => 'rake -s dump:restore LIKE\\=some\\ data PROGRESS_TTY\\=\\+ RAILS_ENV\\=production',
382
- :tags => 'rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=some\\ data',
383
- :migrate_down => 'rake -s dump:restore MIGRATE_DOWN\\=some\\ data PROGRESS_TTY\\=\\+ RAILS_ENV\\=production',
384
- :restore_schema => 'rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production RESTORE_SCHEMA\\=some\\ data',
385
- :restore_tables => 'rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production RESTORE_TABLES\\=some\\ data',
386
- :restore_assets => 'rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production RESTORE_ASSETS\\=some\\ data',
383
+ :like => "rake -s dump:restore LIKE\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production",
384
+ :tags => "rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=some\\ data",
385
+ :migrate_down => "rake -s dump:restore MIGRATE_DOWN\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production",
386
+ :restore_schema => "rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production RESTORE_SCHEMA\\=some\\ data",
387
+ :restore_tables => "rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production RESTORE_TABLES\\=some\\ data",
388
+ :restore_assets => "rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production RESTORE_ASSETS\\=some\\ data",
387
389
  })
388
390
 
389
391
  it 'uses custom rake binary' do
390
392
  expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
391
- expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production")
393
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:restore PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production")
392
394
  @cap.find_and_execute_task('dump:remote:restore')
393
395
  end
394
396
  end
395
397
 
396
398
  describe 'download' do
397
399
  it 'runs rake versions to get avaliable versions' do
398
- expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
400
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production").and_return('')
399
401
  @cap.find_and_execute_task('dump:remote:download')
400
402
  end
401
403
 
402
404
  it 'blocks sending summary to versions' do
403
- expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
405
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production").and_return('')
404
406
  Dump::Env::DICTIONARY[:summary].each do |name|
405
407
  Dump::Env.with_env name => 'true' do
406
408
  @cap.find_and_execute_task('dump:remote:download')
@@ -409,10 +411,10 @@ describe 'cap dump' do
409
411
  end
410
412
 
411
413
  test_passing_environment_variables(:remote, :transfer, {
412
- :like => 'rake -s dump:versions LIKE\\=some\\ data PROGRESS_TTY\\=\\+ RAILS_ENV\\=production',
413
- :tags => 'rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=some\\ data',
414
- :summary => 'rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production', # block sending summary to versions
415
- :transfer_via => 'rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production', # tranfer_via is used internally
414
+ :like => "rake -s dump:versions LIKE\\=some\\ data PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production",
415
+ :tags => "rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production TAGS\\=some\\ data",
416
+ :summary => "rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production", # block sending summary to versions
417
+ :transfer_via => "rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production", # tranfer_via is used internally
416
418
  }, :cap_task => 'dump:remote:download')
417
419
 
418
420
  it 'does not download anything if there are no versions avaliable' do
@@ -424,27 +426,27 @@ describe 'cap dump' do
424
426
  it 'transfers latest version dump' do
425
427
  allow(@cap.dump).to receive(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
426
428
  expect(@cap.dump).to receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", 'dump/300.tgz')
427
- allow(FileUtils).to receive(:mkpath)
429
+ allow(Dir).to receive(:mkdir)
428
430
  @cap.find_and_execute_task('dump:remote:download')
429
431
  end
430
432
 
431
433
  it 'handles extra spaces around file names' do
432
434
  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 ")
433
435
  expect(@cap.dump).to receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", 'dump/300.tgz')
434
- allow(FileUtils).to receive(:mkpath)
436
+ allow(Dir).to receive(:mkdir)
435
437
  @cap.find_and_execute_task('dump:remote:download')
436
438
  end
437
439
 
438
440
  it 'creates local dump dir' do
439
441
  allow(@cap.dump).to receive(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
440
442
  allow(@cap.dump).to receive(:do_transfer)
441
- expect(FileUtils).to receive(:mkpath).with('dump')
443
+ allow(Dir).to receive(:mkdir).with('dump')
442
444
  @cap.find_and_execute_task('dump:remote:download')
443
445
  end
444
446
 
445
447
  it 'runs rake versions use custom rake binary' do
446
448
  expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
447
- expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
449
+ expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=#{plus} RAILS_ENV\\=production").and_return('')
448
450
  @cap.find_and_execute_task('dump:remote:download')
449
451
  end
450
452
  end
@@ -19,7 +19,7 @@ describe 'rake assets' do
19
19
  end_src
20
20
  expect(File).to receive(:readlines).with(File.join(Dump.rails_root, 'config/assets')).and_return(StringIO.new(data).readlines)
21
21
  @rake['assets'].invoke
22
- expect(ENV['ASSETS']).to eq('public/images/a:public/images/b')
22
+ expect(ENV.fetch('ASSETS', nil)).to eq('public/images/a:public/images/b')
23
23
  end
24
24
 
25
25
  it 'ignores comments in config/assets' do
@@ -31,7 +31,7 @@ describe 'rake assets' do
31
31
  end_src
32
32
  allow(File).to receive(:readlines).and_return(StringIO.new(data).readlines)
33
33
  @rake['assets'].invoke
34
- expect(ENV['ASSETS']).to eq('public/images/a:public/images/b')
34
+ expect(ENV.fetch('ASSETS', nil)).to eq('public/images/a:public/images/b')
35
35
  end
36
36
 
37
37
  it "does not change ENV['ASSETS'] if it already exists" do
@@ -42,7 +42,7 @@ describe 'rake assets' do
42
42
  allow(File).to receive(:readlines).and_return(StringIO.new(data).readlines)
43
43
  Dump::Env.with_env :assets => 'public/images' do
44
44
  @rake['assets'].invoke
45
- expect(ENV['ASSETS']).to eq('public/images')
45
+ expect(ENV.fetch('ASSETS', nil)).to eq('public/images')
46
46
  end
47
47
  end
48
48