dump 1.0.5 → 1.0.6

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 +7 -15
  2. data/.rubocop_todo.yml +1 -1
  3. data/Gemfile +6 -1
  4. data/LICENSE.txt +1 -1
  5. data/README.markdown +2 -2
  6. data/dump.gemspec +2 -2
  7. data/lib/dump.rb +86 -2
  8. data/lib/{dump_rake/archive_tar_minitar_fix.rb → dump/archive_tar_minitar.rb} +0 -0
  9. data/lib/{dump_rake → dump}/assets.rb +6 -4
  10. data/lib/dump/capistrano/v2.rb +34 -34
  11. data/lib/{dump_rake → dump}/continious_timeout.rb +1 -1
  12. data/lib/{dump_rake → dump}/env.rb +4 -4
  13. data/lib/{dump_rake → dump}/env/filter.rb +1 -1
  14. data/lib/dump/rails_root.rb +19 -0
  15. data/lib/{dump_rake/dump_reader.rb → dump/reader.rb} +25 -17
  16. data/lib/{dump_rake/dump.rb → dump/snapshot.rb} +9 -5
  17. data/lib/{dump_rake → dump}/table_manipulation.rb +28 -14
  18. data/lib/{dump_rake/dump_writer.rb → dump/writer.rb} +13 -5
  19. data/lib/tasks/assets.rake +4 -4
  20. data/lib/tasks/dump.rake +10 -10
  21. data/script/update_readme +3 -3
  22. data/spec/cycle_spec.rb +78 -84
  23. data/spec/{lib/dump_rake → dump}/env/filter_spec.rb +14 -14
  24. data/spec/dump/env_spec.rb +139 -0
  25. data/spec/{lib/dump_rake → dump}/rails_root_spec.rb +11 -13
  26. data/spec/{lib/dump_rake/dump_reader_spec.rb → dump/reader_spec.rb} +89 -89
  27. data/spec/dump/snapshot_spec.rb +290 -0
  28. data/spec/{lib/dump_rake → dump}/table_manipulation_spec.rb +54 -55
  29. data/spec/{lib/dump_rake/dump_writer_spec.rb → dump/writer_spec.rb} +41 -42
  30. data/spec/dump_spec.rb +327 -0
  31. data/spec/recipes/dump_spec.rb +92 -93
  32. data/spec/spec_helper.rb +0 -3
  33. data/spec/tasks/assets_spec.rb +16 -15
  34. data/spec/tasks/dump_spec.rb +30 -29
  35. metadata +75 -98
  36. data/.autotest +0 -13
  37. data/lib/dump_rake.rb +0 -94
  38. data/lib/dump_rake/rails_root.rb +0 -13
  39. data/spec/lib/dump_rake/dump_spec.rb +0 -289
  40. data/spec/lib/dump_rake/env_spec.rb +0 -139
  41. data/spec/lib/dump_rake_spec.rb +0 -326
  42. data/spec/spec.opts +0 -4
@@ -1,94 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'pathname'
4
- require 'find'
5
- require 'fileutils'
6
- require 'zlib'
7
- require 'tempfile'
8
-
9
- require 'rake'
10
- require 'archive/tar/minitar'
11
- require 'dump_rake/archive_tar_minitar_fix'
12
- require 'progress'
13
-
14
- require 'dump_rake/rails_root'
15
- require 'dump_rake/assets'
16
- require 'dump_rake/table_manipulation'
17
- require 'dump_rake/dump'
18
- require 'dump_rake/dump_reader'
19
- require 'dump_rake/dump_writer'
20
- require 'dump_rake/env'
21
-
22
- # Main interface
23
- class DumpRake
24
- class << self
25
- def versions(options = {})
26
- Dump.list(options).each do |dump|
27
- if DumpRake::Env[:show_size] || $stdout.tty?
28
- puts "#{dump.human_size.to_s.rjust(7)}\t#{dump}"
29
- else
30
- puts dump
31
- end
32
- begin
33
- case options[:summary].to_s.downcase[0, 1]
34
- when *%w[1 t y]
35
- puts DumpReader.summary(dump.path)
36
- puts
37
- when *%w[2 s]
38
- puts DumpReader.summary(dump.path, :schema => true)
39
- puts
40
- end
41
- rescue => e
42
- $stderr.puts "Error reading dump: #{e}"
43
- $stderr.puts
44
- end
45
- end
46
- end
47
-
48
- def create(options = {})
49
- dump = Dump.new(options.merge(:dir => File.join(DumpRake::RailsRoot, 'dump')))
50
-
51
- DumpWriter.create(dump.tmp_path)
52
-
53
- File.rename(dump.tmp_path, dump.tgz_path)
54
- puts File.basename(dump.tgz_path)
55
- end
56
-
57
- def restore(options = {})
58
- dump = Dump.list(options).last
59
-
60
- if dump
61
- DumpReader.restore(dump.path)
62
- else
63
- $stderr.puts 'Avaliable versions:'
64
- $stderr.puts Dump.list
65
- end
66
- end
67
-
68
- def cleanup(options = {})
69
- unless options[:leave].nil? || /^\d+$/ =~ options[:leave] || options[:leave].downcase == 'none'
70
- fail 'LEAVE should be number or "none"'
71
- end
72
-
73
- to_delete = []
74
-
75
- all_dumps = Dump.list(options.merge(:all => true))
76
- to_delete.concat(all_dumps.select{ |dump| dump.ext != 'tgz' })
77
-
78
- dumps = Dump.list(options)
79
- leave = (options[:leave] || 5).to_i
80
- to_delete.concat(dumps[0, dumps.length - leave]) if dumps.length > leave
81
-
82
- to_delete.each do |dump|
83
- dump.lock do
84
- begin
85
- dump.path.unlink
86
- puts "Deleted #{dump.path}"
87
- rescue => e
88
- $stderr.puts "Can not delete #{dump.path} — #{e}"
89
- end
90
- end
91
- end
92
- end
93
- end
94
- end
@@ -1,13 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # Get rails app root (Rails.root or RAILS_ROOT or Dir.pwd)
4
- class DumpRake
5
- RailsRoot = case
6
- when defined?(Rails)
7
- Rails.root
8
- when defined?(RAILS_ROOT)
9
- RAILS_ROOT
10
- else
11
- Dir.pwd
12
- end.to_s
13
- end
@@ -1,289 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe DumpRake::Dump do
4
- def dump_path(file_name)
5
- File.join(DumpRake::RailsRoot, 'dump', file_name)
6
- end
7
-
8
- def new_dump(file_name)
9
- DumpRake::Dump.new(dump_path(file_name))
10
- end
11
-
12
- describe 'lock' do
13
- before do
14
- @yield_receiver = double('yield_receiver')
15
- end
16
-
17
- it 'should not yield if file does not exist' do
18
- expect(@yield_receiver).not_to receive(:fire)
19
-
20
- DumpRake::Dump.new('hello').lock do
21
- @yield_receiver.fire
22
- end
23
- end
24
-
25
- it 'should not yield if file can not be locked' do
26
- expect(@yield_receiver).not_to receive(:fire)
27
-
28
- @file = double('file')
29
- expect(@file).to receive(:flock).with(File::LOCK_EX | File::LOCK_NB).and_return(nil)
30
- expect(@file).to receive(:flock).with(File::LOCK_UN)
31
- expect(@file).to receive(:close)
32
- expect(File).to receive(:open).and_return(@file)
33
-
34
- DumpRake::Dump.new('hello').lock do
35
- @yield_receiver.fire
36
- end
37
- end
38
-
39
- it 'should yield if file can not be locked' do
40
- expect(@yield_receiver).to receive(:fire)
41
-
42
- @file = double('file')
43
- expect(@file).to receive(:flock).with(File::LOCK_EX | File::LOCK_NB).and_return(true)
44
- expect(@file).to receive(:flock).with(File::LOCK_UN)
45
- expect(@file).to receive(:close)
46
- expect(File).to receive(:open).and_return(@file)
47
-
48
- DumpRake::Dump.new('hello').lock do
49
- @yield_receiver.fire
50
- end
51
- end
52
- end
53
-
54
- describe 'new' do
55
- it 'should init with path if String sent' do
56
- expect(DumpRake::Dump.new('hello').path).to eq(Pathname('hello'))
57
- end
58
-
59
- it 'should init with path if Pathname sent' do
60
- expect(DumpRake::Dump.new(Pathname('hello')).path).to eq(Pathname('hello'))
61
- end
62
-
63
- describe 'with options' do
64
- before do
65
- @time = double('time')
66
- allow(@time).to receive(:utc).and_return(@time)
67
- allow(@time).to receive(:strftime).and_return('19650414065945')
68
- allow(Time).to receive(:now).and_return(@time)
69
- end
70
-
71
- it 'should generate path with no options' do
72
- expect(DumpRake::Dump.new.path).to eq(Pathname('19650414065945.tgz'))
73
- end
74
-
75
- it 'should generate with dir' do
76
- expect(DumpRake::Dump.new(:dir => 'dump_dir').path).to eq(Pathname('dump_dir/19650414065945.tgz'))
77
- end
78
-
79
- it 'should generate path with description' do
80
- expect(DumpRake::Dump.new(:dir => 'dump_dir', :desc => 'hello world').path).to eq(Pathname('dump_dir/19650414065945-hello world.tgz'))
81
- end
82
-
83
- it 'should generate path with tags' do
84
- expect(DumpRake::Dump.new(:dir => 'dump_dir', :tags => ' mirror, hello world ').path).to eq(Pathname('dump_dir/19650414065945@hello world,mirror.tgz'))
85
- end
86
-
87
- it 'should generate path with description and tags' do
88
- expect(DumpRake::Dump.new(:dir => 'dump_dir', :desc => 'Anniversary backup', :tags => ' mirror, hello world ').path).to eq(Pathname('dump_dir/19650414065945-Anniversary backup@hello world,mirror.tgz'))
89
- end
90
- end
91
- end
92
-
93
- describe 'versions' do
94
- describe 'list' do
95
- def stub_glob
96
- paths = %w[123 345 567].map do |name|
97
- path = dump_path("#{name}.tgz")
98
- expect(File).to receive(:file?).with(path).at_least(1).and_return(true)
99
- path
100
- end
101
- allow(Dir).to receive(:[]).and_return(paths)
102
- end
103
-
104
- it 'should search for files in dump dir when asked for list' do
105
- expect(Dir).to receive(:[]).with(dump_path('*.tgz')).and_return([])
106
- DumpRake::Dump.list
107
- end
108
-
109
- it 'should return selves instances for each found file' do
110
- stub_glob
111
- DumpRake::Dump.list.all?{ |dump| expect(dump).to be_a(DumpRake::Dump) }
112
- end
113
-
114
- it 'should return dumps with name containting :like' do
115
- stub_glob
116
- expect(DumpRake::Dump.list(:like => '3')).to eq(DumpRake::Dump.list.values_at(0, 1))
117
- end
118
- end
119
-
120
- describe 'with tags' do
121
- before do
122
- # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
123
- 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]
124
- paths = dumps_tags.each_with_index.map do |dump_tags, i|
125
- path = dump_path("196504140659#{10 + i}@#{dump_tags}.tgz")
126
- expect(File).to receive(:file?).with(path).at_least(1).and_return(true)
127
- path
128
- end
129
- allow(Dir).to receive(:[]).and_return(paths)
130
- end
131
-
132
- it 'should return all dumps if no tags send' do
133
- expect(DumpRake::Dump.list(:tags => '')).to eq(DumpRake::Dump.list)
134
- end
135
-
136
- {
137
- 'x' => [],
138
- '+x' => [],
139
- 'z' => [16],
140
- 'a,d,s,o' => [1..15],
141
- '+a,+d,+s,+o' => [5],
142
- '-o' => [0, 1, 2, 4, 7, 9, 11, 14, 16],
143
- 'a,b,c,+s,-o' => [4, 7],
144
- '+a,+d' => [2, 3, 4, 5],
145
- '+d,+a' => [2, 3, 4, 5],
146
- }.each do |tags, ids|
147
- it "should return dumps filtered by #{tags}" do
148
- expect(DumpRake::Dump.list(:tags => tags)).to eq(DumpRake::Dump.list.values_at(*ids))
149
- end
150
- end
151
- end
152
- end
153
-
154
- describe 'name' do
155
- it 'should return file name' do
156
- expect(new_dump('19650414065945.tgz').name).to eq('19650414065945.tgz')
157
- end
158
- end
159
-
160
- describe 'parts' do
161
- before do
162
- @time = Time.utc(1965, 4, 14, 6, 59, 45)
163
- end
164
-
165
- def dump_name_parts(name)
166
- dump = new_dump(name)
167
- [dump.time, dump.description, dump.tags, dump.ext]
168
- end
169
-
170
- %w[tmp tgz].each do |ext|
171
- it 'should return empty results for dump with wrong name' do
172
- expect(dump_name_parts("196504140659.#{ext}")).to eq([nil, '', [], nil])
173
- expect(dump_name_parts("196504140659-lala.#{ext}")).to eq([nil, '', [], nil])
174
- expect(dump_name_parts("196504140659@lala.#{ext}")).to eq([nil, '', [], nil])
175
- expect(dump_name_parts('19650414065945.ops')).to eq([nil, '', [], nil])
176
- end
177
-
178
- it 'should return tags for dump with tags' do
179
- expect(dump_name_parts("19650414065945.#{ext}")).to eq([@time, '', [], ext])
180
- expect(dump_name_parts("19650414065945- Hello world &&& .#{ext}")).to eq([@time, 'Hello world _', [], ext])
181
- expect(dump_name_parts("19650414065945- Hello world &&& @ test , hello world , bad tag ~~~~.#{ext}")).to eq([@time, 'Hello world _', ['bad tag _', 'hello world', 'test'], ext])
182
- expect(dump_name_parts("19650414065945@test, test , hello world , bad tag ~~~~.#{ext}")).to eq([@time, '', ['bad tag _', 'hello world', 'test'], ext])
183
- expect(dump_name_parts("19650414065945-Hello world@test,super tag.#{ext}")).to eq([@time, 'Hello world', ['super tag', 'test'], ext])
184
- end
185
- end
186
- end
187
-
188
- describe 'path' do
189
- it 'should return path' do
190
- expect(new_dump('19650414065945.tgz').path).to eq(Pathname(File.join(DumpRake::RailsRoot, 'dump', '19650414065945.tgz')))
191
- end
192
- end
193
-
194
- describe 'tgz_path' do
195
- it 'should return path if extension is already tgz' do
196
- expect(new_dump('19650414065945.tgz').tgz_path).to eq(new_dump('19650414065945.tgz').path)
197
- end
198
-
199
- it 'should return path with tgz extension' do
200
- expect(new_dump('19650414065945.tmp').tgz_path).to eq(new_dump('19650414065945.tgz').path)
201
- end
202
- end
203
-
204
- describe 'tmp_path' do
205
- it 'should return path if extension is already tmp' do
206
- expect(new_dump('19650414065945.tmp').tmp_path).to eq(new_dump('19650414065945.tmp').path)
207
- end
208
-
209
- it 'should return path with tmp extension' do
210
- expect(new_dump('19650414065945.tgz').tmp_path).to eq(new_dump('19650414065945.tmp').path)
211
- end
212
- end
213
-
214
- describe 'clean_description' do
215
- it "should shorten string to 50 chars and replace special symblos with '-'" do
216
- expect(DumpRake::Dump.new('').send(:clean_description, 'Special Dump #12837192837 (before fixind *&^*&^ photos)')).to eq('Special Dump #12837192837 (before fixind _ photos)')
217
- expect(DumpRake::Dump.new('').send(:clean_description, "To#{'o' * 100} long description")).to eq("T#{'o' * 49}")
218
- end
219
-
220
- it 'should accept non string' do
221
- expect(DumpRake::Dump.new('').send(:clean_description, nil)).to eq('')
222
- end
223
- end
224
-
225
- describe 'clean_tag' do
226
- it "should shorten string to 20 chars and replace special symblos with '-'" do
227
- expect(DumpRake::Dump.new('').send(:clean_tag, 'Very special tag #12837192837 (fixind *&^*&^)')).to eq('very special tag _12')
228
- expect(DumpRake::Dump.new('').send(:clean_tag, "To#{'o' * 100} long tag")).to eq("t#{'o' * 19}")
229
- end
230
-
231
- it "should not allow '-' or '+' to be first symbol" do
232
- expect(DumpRake::Dump.new('').send(:clean_tag, ' Very special tag')).to eq('very special tag')
233
- expect(DumpRake::Dump.new('').send(:clean_tag, '-Very special tag')).to eq('very special tag')
234
- expect(DumpRake::Dump.new('').send(:clean_tag, '-----------')).to eq('')
235
- expect(DumpRake::Dump.new('').send(:clean_tag, '+Very special tag')).to eq('_very special tag')
236
- expect(DumpRake::Dump.new('').send(:clean_tag, '+++++++++++')).to eq('_')
237
- end
238
-
239
- it 'should accept non string' do
240
- expect(DumpRake::Dump.new('').send(:clean_tag, nil)).to eq('')
241
- end
242
- end
243
-
244
- describe 'clean_tags' do
245
- it 'should split string and return uniq non blank sorted tags' do
246
- expect(DumpRake::Dump.new('').send(:clean_tags, ' perfect tag , hello,Hello,this is (*^(*&')).to eq(['hello', 'perfect tag', 'this is _'])
247
- expect(DumpRake::Dump.new('').send(:clean_tags, "l#{'o' * 100}ng tag")).to eq(["l#{'o' * 19}"])
248
- end
249
-
250
- it 'should accept non string' do
251
- expect(DumpRake::Dump.new('').send(:clean_tags, nil)).to eq([])
252
- end
253
- end
254
-
255
- describe 'get_filter_tags' do
256
- it 'should split string and return uniq non blank sorted tags' do
257
- expect(DumpRake::Dump.new('').send(:get_filter_tags, 'a,+b,+c,-d')).to eq({:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d]})
258
- expect(DumpRake::Dump.new('').send(:get_filter_tags, ' a , + b , + c , - d ')).to eq({:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d]})
259
- expect(DumpRake::Dump.new('').send(:get_filter_tags, ' a , + c , + b , - d ')).to eq({:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d]})
260
- expect(DumpRake::Dump.new('').send(:get_filter_tags, ' a , + b , + , - ')).to eq({:simple => %w[a], :mandatory => %w[b], :forbidden => []})
261
- expect(DumpRake::Dump.new('').send(:get_filter_tags, ' a , a , + b , + b , - d , - d ')).to eq({:simple => %w[a], :mandatory => %w[b], :forbidden => %w[d]})
262
- expect{ DumpRake::Dump.new('').send(:get_filter_tags, 'a,+a') }.not_to raise_error
263
- expect{ DumpRake::Dump.new('').send(:get_filter_tags, 'a,-a') }.to raise_error
264
- expect{ DumpRake::Dump.new('').send(:get_filter_tags, '+a,-a') }.to raise_error
265
- end
266
-
267
- it 'should accept non string' do
268
- expect(DumpRake::Dump.new('').send(:get_filter_tags, nil)).to eq({:simple => [], :mandatory => [], :forbidden => []})
269
- end
270
- end
271
-
272
- describe 'assets_root_link' do
273
- it 'should create tem dir, chdir there, symlink rails app root to assets, yield and unlink assets ever if something raised' do
274
- expect(Dir).to receive(:mktmpdir).and_yield('/tmp/abc')
275
- expect(Dir).to receive(:chdir).with('/tmp/abc').and_yield
276
- expect(File).to receive(:symlink).with(DumpRake::RailsRoot, 'assets')
277
- expect(File).to receive(:unlink).with('assets')
278
- expect do
279
- DumpRake::Dump.new('').send(:assets_root_link) do |dir, prefix|
280
- expect(dir).to eq('/tmp/abc')
281
- expect(prefix).to eq('assets')
282
- @yielded = true
283
- fail 'just test'
284
- end
285
- end.to raise_error('just test')
286
- expect(@yielded).to eq(true)
287
- end
288
- end
289
- end
@@ -1,139 +0,0 @@
1
- require 'spec_helper'
2
-
3
- Env = DumpRake::Env
4
- describe Env do
5
- def silence_warnings
6
- old_verbose, $VERBOSE = $VERBOSE, nil
7
- yield
8
- ensure
9
- $VERBOSE = old_verbose
10
- end
11
-
12
- before do
13
- silence_warnings do
14
- @old_env, ENV = ENV, {}
15
- end
16
- end
17
-
18
- after do
19
- silence_warnings do
20
- ENV = @old_env
21
- end
22
- end
23
-
24
- describe 'with_env' do
25
- it 'should set env to new_value for duration of block' do
26
- ENV['LIKE'] = 'old_value'
27
-
28
- expect(ENV['LIKE']).to eq('old_value')
29
- Env.with_env('LIKE' => 'new_value') do
30
- expect(ENV['LIKE']).to eq('new_value')
31
- end
32
- expect(ENV['LIKE']).to eq('old_value')
33
- end
34
-
35
- it 'should use dictionary' do
36
- ENV['LIKE'] = 'old_value'
37
-
38
- expect(ENV['LIKE']).to eq('old_value')
39
- Env.with_env(:like => 'new_value') do
40
- expect(ENV['LIKE']).to eq('new_value')
41
- end
42
- expect(ENV['LIKE']).to eq('old_value')
43
- end
44
- end
45
-
46
- describe '[]' do
47
- it 'should mimic ENV' do
48
- ENV['VERSION'] = 'VERSION_value'
49
- expect(Env['VERSION']).to eq(ENV['VERSION'])
50
- end
51
-
52
- it 'should return nil on non existing env variable' do
53
- expect(Env['DESCRIPTON']).to eq(nil)
54
- end
55
-
56
- it 'should get first value that is set' do
57
- ENV['VERSION'] = 'VERSION_value'
58
- expect(Env[:like]).to eq('VERSION_value')
59
- ENV['VER'] = 'VER_value'
60
- expect(Env[:like]).to eq('VER_value')
61
- ENV['LIKE'] = 'LIKE_value'
62
- expect(Env[:like]).to eq('LIKE_value')
63
- end
64
-
65
- it 'should return nil for unset variable' do
66
- expect(Env[:desc]).to eq(nil)
67
- end
68
- end
69
-
70
- describe 'filter' do
71
- before do
72
- Env.instance_variable_set(:@filters, nil)
73
- end
74
-
75
- it 'should return Filter' do
76
- ENV['TABLES'] = 'a,b,c'
77
- filter = Env.filter('TABLES')
78
- expect(filter).to be_instance_of(Env::Filter)
79
- expect(filter.invert).to be_falsey
80
- expect(filter.values).to eq(%w[a b c])
81
- end
82
-
83
- it 'should cache created filter' do
84
- ENV['TABLES'] = 'a,b,c'
85
- ENV['TABLES2'] = 'a,b,c'
86
- expect(Env::Filter).to receive(:new).with('a,b,c', nil).once
87
- Env.filter('TABLES')
88
- Env.filter('TABLES')
89
- Env.filter('TABLES2')
90
- end
91
- end
92
-
93
- describe 'for_command' do
94
- describe 'when no vars present' do
95
- it 'should return empty hash for every command' do
96
- expect(Env.for_command(:create)).to eq({})
97
- expect(Env.for_command(:restore)).to eq({})
98
- expect(Env.for_command(:versions)).to eq({})
99
- expect(Env.for_command(:bad)).to eq({})
100
- end
101
-
102
- it 'should return empty hash for every command when asking for string keys' do
103
- expect(Env.for_command(:create, true)).to eq({})
104
- expect(Env.for_command(:restore, true)).to eq({})
105
- expect(Env.for_command(:versions, true)).to eq({})
106
- expect(Env.for_command(:bad, true)).to eq({})
107
- end
108
- end
109
-
110
- describe 'when vars are present' do
111
- before do
112
- ENV['LIKE'] = 'Version'
113
- ENV['DESC'] = 'Description'
114
- end
115
-
116
- it 'should return hash with symbol keys for every command' do
117
- expect(Env.for_command(:create)).to eq({:desc => 'Description'})
118
- expect(Env.for_command(:restore)).to eq({:like => 'Version'})
119
- expect(Env.for_command(:versions)).to eq({:like => 'Version'})
120
- expect(Env.for_command(:bad)).to eq({})
121
- end
122
-
123
- it 'should return hash with symbol keys for every command when asking for string keys' do
124
- expect(Env.for_command(:create, true)).to eq({'DESC' => 'Description'})
125
- expect(Env.for_command(:restore, true)).to eq({'LIKE' => 'Version'})
126
- expect(Env.for_command(:versions, true)).to eq({'LIKE' => 'Version'})
127
- expect(Env.for_command(:bad, true)).to eq({})
128
- end
129
- end
130
- end
131
-
132
- describe 'stringify!' do
133
- it 'should convert keys to strings' do
134
- @env = {:desc => 'text', :tags => 'a b c', 'LEAVE' => 'none', 'OTHER' => 'data'}
135
- Env.stringify!(@env)
136
- expect(@env).to eq({'DESC' => 'text', 'TAGS' => 'a b c', 'LEAVE' => 'none', 'OTHER' => 'data'})
137
- end
138
- end
139
- end