Wrap RAILS_ROOT to support Merb also

This commit is contained in:
Gwyn Morfey 2008-04-17 11:52:42 +01:00
parent ede0073db4
commit 2e03051735
2 changed files with 5 additions and 2 deletions

View File

@ -4,6 +4,9 @@ end
module Webrat
VERSION = '0.2.1'
def self.root
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
end
end
if defined?(Merb)

View File

@ -94,10 +94,10 @@ module Webrat
# Example:
# save_and_open
def save_and_open
return unless File.exist?(RAILS_ROOT + "/tmp")
return unless File.exist?(Webrat.root + "/tmp")
filename = "webrat-#{Time.now.to_i}.html"
File.open(RAILS_ROOT + "/tmp/#{filename}", "w") do |f|
File.open(Webrat.root + "/tmp/#{filename}", "w") do |f|
f.write response.body
end
`open tmp/#{filename}`