Browse Source

Working on save args

dev
Andy Meneely 10 years ago
parent
commit
4aee48dada
  1. 8
      lib/squib/args/save_batch.rb
  2. 21
      spec/args/save_batch_spec.rb

8
lib/squib/args/save_batch.rb

@ -25,6 +25,14 @@ module Squib
[] # none of them
end
def validate_dir(arg)
unless Dir.exists?(arg)
Squib.logger.warn("Dir '#{arg}' does not exist, creating it.")
Dir.mkdir arg
end
return arg
end
end
end
end

21
spec/args/save_batch_spec.rb

@ -0,0 +1,21 @@
require 'spec_helper'
require 'squib/args/save_batch'
describe Squib::Args::SaveBatch do
subject(:save_batch) {Squib::Args::SaveBatch.new}
context 'dir' do
it 'is created if not exists (and warns)' do
opts = {dir: 'tocreate'}
Dir.chdir(output_dir) do
FileUtils.rm_rf('tocreate', secure: true)
expect(Squib.logger).to receive(:warn).with("Dir 'tocreate' does not exist, creating it.").once
save_batch.load! opts
expect(save_batch).to have_attributes({dir: 'tocreate'})
expect(Dir.exists? 'tocreate').to be true
end
end
end
end
Loading…
Cancel
Save