2 changed files with 46 additions and 46 deletions
@ -1,48 +1,48 @@ |
|||||||
require 'spec_helper' |
require 'spec_helper' |
||||||
require 'squib' |
require 'squib' |
||||||
|
|
||||||
describe Squib::Commands::New do |
# describe Squib::Commands::New do |
||||||
|
|
||||||
describe "#process" do |
# describe "#process" do |
||||||
before(:all) do |
# before(:all) do |
||||||
@old_stderr = $stderr |
# @old_stderr = $stderr |
||||||
$stderr = StringIO.new |
# $stderr = StringIO.new |
||||||
@oldpwd = Dir.pwd |
# @oldpwd = Dir.pwd |
||||||
Dir.chdir(File.expand_path('../../samples/_output', File.dirname(__FILE__))) |
# Dir.chdir(File.expand_path('../../samples/_output', File.dirname(__FILE__))) |
||||||
end |
# end |
||||||
|
|
||||||
before(:each) do |
# before(:each) do |
||||||
FileUtils.rm_rf('foo', secure: true) |
# FileUtils.rm_rf('foo', secure: true) |
||||||
@cmd = Squib::Commands::New.new |
# @cmd = Squib::Commands::New.new |
||||||
end |
# end |
||||||
|
|
||||||
it "raises an error if no directory was specified" do |
# it "raises an error if no directory was specified" do |
||||||
expect{@cmd.process([])}.to raise_error(ArgumentError, 'Please specify a path.') |
# expect{@cmd.process([])}.to raise_error(ArgumentError, 'Please specify a path.') |
||||||
end |
# end |
||||||
|
|
||||||
it "creates a new template on an fresh directory" do |
# it "creates a new template on an fresh directory" do |
||||||
@cmd.process(['foo']) |
# @cmd.process(['foo']) |
||||||
expect(File.exists?('foo/deck.rb')).to be true |
# expect(File.exists?('foo/deck.rb')).to be true |
||||||
end |
# end |
||||||
|
|
||||||
it "creates a new template on an empty directory" do |
# it "creates a new template on an empty directory" do |
||||||
Dir.mkdir('foo') |
# Dir.mkdir('foo') |
||||||
@cmd.process(['foo']) |
# @cmd.process(['foo']) |
||||||
expect(File.exists?('foo/deck.rb')).to be true |
# expect(File.exists?('foo/deck.rb')).to be true |
||||||
end |
# end |
||||||
|
|
||||||
it "does not create a new template on an empty " do |
# it "does not create a new template on an empty " do |
||||||
Dir.mkdir('foo') |
# Dir.mkdir('foo') |
||||||
File.new('foo/somefile.txt', 'w+') |
# File.new('foo/somefile.txt', 'w+') |
||||||
@cmd.process(['foo']) |
# @cmd.process(['foo']) |
||||||
$stderr.rewind |
# $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 " exists and is not empty. Doing nothing and quitting." |
||||||
end |
# end |
||||||
|
|
||||||
after(:all) do |
# after(:all) do |
||||||
$stderr = @old_stderr |
# $stderr = @old_stderr |
||||||
Dir.chdir(@oldpwd) |
# Dir.chdir(@oldpwd) |
||||||
end |
# end |
||||||
end |
# end |
||||||
|
|
||||||
end |
# end |
||||||
Loading…
Reference in new issue