diff --git a/lib/webrat/core/logging.rb b/lib/webrat/core/logging.rb index 7868c952..260c57b6 100644 --- a/lib/webrat/core/logging.rb +++ b/lib/webrat/core/logging.rb @@ -1,3 +1,5 @@ +require "logger" + module Webrat module Logging #:nodoc: @@ -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 diff --git a/spec/private/core/logging_spec.rb b/spec/private/core/logging_spec.rb index 932f54ba..83db7b57 100644 --- a/spec/private/core/logging_spec.rb +++ b/spec/private/core/logging_spec.rb @@ -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