Fix logger issue when running inside Cucumber.
This commit is contained in:
parent
6a85b6e444
commit
4a949e0e5a
|
@ -1,3 +1,5 @@
|
||||||
|
require "logger"
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
module Logging #:nodoc:
|
module Logging #:nodoc:
|
||||||
|
|
||||||
|
@ -13,10 +15,7 @@ module Webrat
|
||||||
when :merb
|
when :merb
|
||||||
Merb.logger
|
Merb.logger
|
||||||
else
|
else
|
||||||
@logger ||= begin
|
@logger ||= ::Logger.new("webrat.log")
|
||||||
require "logger"
|
|
||||||
::Logger.new("webrat.log")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,17 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
||||||
|
|
||||||
describe Webrat::Logging do
|
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 = Class.new
|
||||||
klass.send(:include, Webrat::Logging)
|
klass.send(:include, Webrat::Logging)
|
||||||
klass.new.debug_log "Testing"
|
klass.new.debug_log "Testing"
|
||||||
|
|
||||||
|
File.read("webrat.log").should match(/Testing/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue