Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Remove references to RAILS_ROOT from Webrat core
- Loading branch information
Showing
8 changed files
with
38 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
module Webrat | ||
class Session | ||
|
||
def doc_root | ||
nil | ||
end | ||
|
||
def saved_page_dir | ||
File.expand_path(".") | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,53 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") | ||
|
||
RAILS_ROOT = "." unless defined?(RAILS_ROOT) | ||
|
||
describe "save_and_open_page" do | ||
before do | ||
@session = Webrat::TestSession.new | ||
|
||
@session.response_body = <<-HTML | ||
<html><head> | ||
<link href="/stylesheets/foo.css" media="screen" rel="stylesheet" type="text/css" /> | ||
</head><body> | ||
<h1>Hello world</h1> | ||
<img src="/images/bar.png" /> | ||
</body></html> | ||
<html> | ||
<head> | ||
<link href="/stylesheets/foo.css" media="screen" rel="stylesheet" type="text/css" /> | ||
</head> | ||
<body> | ||
<h1>Hello world</h1> | ||
<img src="/images/bar.png" /> | ||
</body> | ||
</html> | ||
HTML | ||
|
||
File.stubs(:exist?).returns(true) | ||
Time.stubs(:now).returns(1234) | ||
Webrat::Page.any_instance.stubs(:open_in_browser) | ||
|
||
@file_handle = mock() | ||
File.stubs(:open).with(filename, 'w').yields(@file_handle) | ||
@file_handle.stubs(:write) | ||
end | ||
|
||
it "should rewrite css rules" do | ||
file_handle = mock() | ||
File.expects(:open).with(filename, 'w').yields(file_handle) | ||
file_handle.expects(:write).with{|html| html =~ %r|#{RAILS_ROOT}/public/stylesheets/foo.css|s } | ||
Webrat::Page.any_instance.stubs(:open_in_browser) | ||
@file_handle.expects(:write).with do |html| | ||
html =~ %r|#{@session.doc_root}/stylesheets/foo.css|s | ||
end | ||
|
||
@session.save_and_open_page | ||
end | ||
|
||
it "should rewrite image paths" do | ||
file_handle = mock() | ||
File.expects(:open).with(filename, 'w').yields(file_handle) | ||
file_handle.expects(:write).with{|html| html =~ %r|#{RAILS_ROOT}/public/images/bar.png|s } | ||
Webrat::Page.any_instance.stubs(:open_in_browser) | ||
@file_handle.expects(:write).with do |html| | ||
html =~ %r|#{@session.doc_root}/images/bar.png|s | ||
end | ||
|
||
@session.save_and_open_page | ||
end | ||
|
||
it "should open the temp file in a browser" do | ||
File.stubs(:open) | ||
Webrat::Page.any_instance.expects(:open_in_browser).with(filename) | ||
@session.save_and_open_page | ||
end | ||
|
||
def filename | ||
File.expand_path("./webrat-1234.html") | ||
File.expand_path("./webrat-#{Time.now}.html") | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e6aff6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. I get load orders on Ubuntu from core.rb
Adding “sort” to the file require loop fixes this.
Dir[File.join(File.dirname(FILE), “core”, “*.rb”)].sort.each do |file| … end