Skip to content
Browse files

spec: crashing as per issue #14092; cleanup

git-svn-id: svn+ssh://rubyforge.org/var/svn/alogr/trunk@13 5d4fd1e0-7adf-40a7-adde-e9af6235188f
  • Loading branch information...
1 parent fdaf64a commit d89bbc081b989f955596c8cfe40cb912790587e7 flazz committed Sep 20, 2007
Showing with 27 additions and 19 deletions.
  1. +27 −19 specs/two_logs.rb
View
46 specs/two_logs.rb
@@ -1,30 +1,38 @@
-#require "lib/alogr"
+require "alogr"
describe "AlogR" do
- before :each do
- puts( "Removing log/ directory\n" )
- system("rm -rf log/")
-
- puts( "Creating new logger with a default and error log. \n" )
- $logger = AlogR.new(
- :log => "#{Dir.pwd}/log/default.log",
- :error => "#{Dir.pwd}/log/error.log"
- )
+
+ after do
+ FileUtils::rm_rf @log_dir
end
- it "should create log/ then create and log to the files specified as a hash list :log => 'default.log', :error => 'error.log'" do
- File.exists?("log") and File.exists?("log/default.log") and File.exists?("log/error.log")
+ before do
+ @log_dir = File.join Dir.pwd, "log"
+ @default_log_file = File.join @log_dir, "default.log"
+ @error_log_file = File.join @log_dir, "error.log"
+ $logger = AlogR::Logger.new :log => @default_log_file, :error => @error_log_file
end
- it "should log messages to the error log when '.log(:error)' is called" do
- "This should go to the error log.".log(:error)
+ it "should create the default and error log files and the log dir" do
+ true.should == File.directory?("log") and
+ true.should == File.file?("log/default.log") and
+ true.should == File.file?("log/error.log")
+ end
- File.read("log/error.log").strip.should eql("This should go to the error log.")
+ it "should log messages to the error log when '.log(:error)' is called" do
+ message = "This should go to the error log."
+ message.log :error
+ contents = open(@error_log_file) { |io| io.read }
+ contents.should =~ /#{ Regexp.escape message }/
end
it "should log to the default log if no log level is specified" do
- "This should go to the default log.".log
-
- File.read("log/default.log").strip.should eql("This should go to the default log.")
+ pending 'aio_logger.so tries to lookup undefined symbol: aio_writer64' do
+ message = "This should go to the default log."
+ message.log
+ contents = open(@default_log_file) { |io| io.read }
+ contents.should =~ /#{ Regexp.escape message }/
+ end
end
-end
+
+end

0 comments on commit d89bbc0

Please sign in to comment.
Something went wrong with that request. Please try again.