Skip to content

Commit

Permalink
Merge commit 'djanowski/fix_logger'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Helmkamp committed Aug 29, 2009
2 parents 5b90488 + 4a949e0 commit b9466df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/webrat/core/logging.rb
@@ -1,3 +1,5 @@
require "logger"

module Webrat
module Logging #:nodoc:

Expand All @@ -13,10 +15,7 @@ def logger # :nodoc:
when :merb
::Merb.logger
else
@logger ||= begin
require "logger"
::Logger.new("webrat.log")
end
@logger ||= ::Logger.new("webrat.log")
end
end

Expand Down
10 changes: 9 additions & 1 deletion spec/private/core/logging_spec.rb
Expand Up @@ -2,9 +2,17 @@

describe Webrat::Logging do

it "should not log if there is no logger" do
it "should always log outside of Rails and Merb" do
FileUtils.rm("webrat.log")

Webrat.configure do |config|
config.mode = :rack
end

klass = Class.new
klass.send(:include, Webrat::Logging)
klass.new.debug_log "Testing"

File.read("webrat.log").should match(/Testing/)
end
end

0 comments on commit b9466df

Please sign in to comment.