From 4a949e0e5a89a8ba88239d92cd2321ce30263bc5 Mon Sep 17 00:00:00 2001 From: Damian Janowski Date: Fri, 14 Aug 2009 13:05:20 -0300 Subject: [PATCH] Fix logger issue when running inside Cucumber. --- lib/webrat/core/logging.rb | 7 +++---- spec/private/core/logging_spec.rb | 10 +++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/webrat/core/logging.rb b/lib/webrat/core/logging.rb index 7a91c4d2..a83b5a67 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