Last active
September 27, 2015 15:57
-
-
Save vjdhama/c1a0fc972e38c8dd04db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code | |
if Dir.exists?(name) || File.exists?(name) | |
STDERR.puts "file or directory #{name} already exists" | |
puts opts | |
exit 1 | |
end | |
# Spec | |
module Init | |
def exit(status=0) | |
puts "my exit running" | |
end | |
end | |
describe Init do | |
it "prints error to STDERR" do | |
Dir.mkdir_p("#{__DIR__}/tmp") | |
stderr = File.open("/dev/null") | |
stderr.reopen(STDERR) | |
STDERR.reopen(File.open("#{__DIR__}/test_stderr", "w")) | |
Crystal::Init.run(["lib", "#{__DIR__}/tmp"]) | |
puts "Spec Check" | |
File.read("#{__DIR__}/test_stderr").should eq("file or directory #{__DIR__}/tmp already exists") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment