cli: unit tests for advanced template

This commit is contained in:
Andy Meneely
2017-10-10 10:36:06 -04:00
parent 1d4de1e2ad
commit 60ca032d2d
3 changed files with 15 additions and 8 deletions
+13 -6
View File
@@ -19,26 +19,33 @@ describe Squib::Commands::New do
end
it 'raises an error if no directory was specified' do
expect{@cmd.process([])}.to raise_error(ArgumentError, 'Please specify a path.')
expect{@cmd.process([], false)}.
to raise_error(ArgumentError, 'Please specify a path.')
end
it 'creates a new template on an fresh directory' do
@cmd.process(['foo'])
it 'creates a basic template on an fresh directory' do
@cmd.process(['foo'], false)
expect(File.exists?('foo/deck.rb')).to be true
end
it 'creates an advanced template on an fresh directory' do
@cmd.process(['foo'], true)
expect(File.exists?('foo/src/deck.rb')).to be true
end
it 'creates a new template on an empty directory' do
Dir.mkdir('foo')
@cmd.process(['foo'])
@cmd.process(['foo'], false)
expect(File.exists?('foo/deck.rb')).to be true
end
it 'does not create a new template on an empty ' do
Dir.mkdir('foo')
File.new('foo/somefile.txt', 'w+')
@cmd.process(['foo'])
@cmd.process(['foo'], false)
$stderr.rewind
expect($stderr.string.chomp).to end_with ' exists and is not empty. Doing nothing and quitting.'
expect($stderr.string.chomp).
to end_with 'not empty. Doing nothing and quitting.'
end
after(:all) do