Permalink
Browse files

spec: passes or fails, no chrashing; higher resolution; some cleanup

git-svn-id: svn+ssh://rubyforge.org/var/svn/alogr/trunk@12 5d4fd1e0-7adf-40a7-adde-e9af6235188f
  • Loading branch information...
1 parent 1f58853 commit fdaf64a68c347057ab2272f1afe76818b3feabd2 flazz committed Sep 20, 2007
Showing with 30 additions and 14 deletions.
  1. +30 −14 specs/base.rb
View
@@ -1,26 +1,42 @@
-require "lib/alogr"
+require "fileutils"
+require "alogr"
describe "AlogR" do
- before :each do
- puts "Removing log/ directory"
- system("rm -rf log/")
+
+ before do
+ @log_dir = File.join Dir.pwd, "log"
+ @log_file = File.join @log_dir, "default.log"
+ end
+
+ after do
+ FileUtils::rm_rf @log_dir
end
- it "should create two global array variables: $alogr_buffer and $alog_log_files" do
- $alogr_buffer.should eql([]) and $alog_log_files.should eql([])
+ it "should create global array $alogr_buffer" do
+ $alogr_buffer.should == []
+ end
+
+ it "should create global array $alogr_log_files" do
+ $alog_log_files.should == []
end
- it "should define a new method Object#log" do
+ it "should define Object#log" do
Object.should respond_to(:log)
end
- it "should create log/ then create and log to the file specified as a string" do
- $logger = AlogR.new("#{Dir.pwd}/log/default.log")
- File.exists?("log") and File.exists?("log/default.log")
+ it "should create a log directory" do
+ $logger = AlogR::Logger.new @log_file
+ true.should == File.directory?(@log_dir)
+ end
+
+ it "should create a log to the file specified as a string" do
+ $logger = AlogR::Logger.new @log_file
+ true.should == File.file?(@log_file)
end
- it "should create log/ then create and log to the file specified as a hash :log => 'spec.log'" do
- $logger = AlogR.new(:log => "#{Dir.pwd}/log/default.log")
- File.exists?("log") and File.exists?("log/default.log")
+ it "should create a log to the file specified as a hash :log => 'spec.log'" do
+ $logger = AlogR::Logger.new :log => @log_file
+ true.should == File.file?(@log_file)
end
-end
+
+end

0 comments on commit fdaf64a

Please sign in to comment.