forked from rack/rack-contrib
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
specs added, comments, readme updated
- Loading branch information
Daniel Mendler
committed
Mar 4, 2009
1 parent
b8e7f9a
commit 088813e
Showing
8 changed files
with
123 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!-- | ||
line 6 column 14 - Error: unexpected </div> in <p> | ||
line 7 column 3 - Error: unexpected </body> in <p> | ||
line 8 column 1 - Error: unexpected </html> in <p> | ||
line 1 column 1 - Access: [3.2.1.1]: <doctype> missing. | ||
line 1 column 1 - Access: [3.3.1.1]: use style sheets to control presentation. | ||
--> |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<title>Titel</title> | ||
</head> | ||
<body> | ||
Blabla<p></div> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'test/spec' | ||
require 'rack/mock' | ||
require 'rack/contrib/rewrite' | ||
|
||
context "Rack::Rewrite" do | ||
|
||
def action(id, expect) | ||
response = Rack::MockRequest.new(@app).get("/~user/app/action#{id}") | ||
response.body.should.equal(expect) | ||
response.status.should.equal(200) | ||
end | ||
|
||
specify "should rewrite absolute paths" do | ||
@app = Rack::Builder.new do | ||
use Rack::Lint | ||
use Rack::Rewrite, :base => '/~user/app' | ||
run Rack::URLMap.new({ | ||
'/action1' => lambda { [200, {"Content-Type" => "text/html"}, ['<a href="/action">']] }, | ||
'/action2' => lambda { [200, {"Content-Type" => "text/html"}, ['<a href=\'/action\'>']] }, | ||
'/action3' => lambda { [200, {"Content-Type" => "text/html"}, ['<a href="http://xy">']] }, | ||
'/action4' => lambda { [200, {"Content-Type" => "text/html"}, ['<a href="relative">']] }, | ||
'/action5' => lambda { [200, {"Content-Type" => "text/html"}, ['<img title="image" src="/img"/>']] }, | ||
'/action6' => lambda { [200, {"Content-Type" => "text/html"}, ['<link rel="stylesheet" href="/style.css" type="text/css">']] }, | ||
}) | ||
end | ||
|
||
action(1, '<a href="/~user/app/action">') | ||
action(2, '<a href=\'/~user/app/action\'>') | ||
action(3, '<a href="http://xy">') | ||
action(4, '<a href="relative">') | ||
action(5, '<img title="image" src="/~user/app/img"/>') | ||
action(6, '<link rel="stylesheet" href="/~user/app/style.css" type="text/css">') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'test/spec' | ||
require 'rack/mock' | ||
require 'rack/contrib/tidy' | ||
|
||
context "Rack::Tidy" do | ||
|
||
specify "should run tidy on xml" do | ||
app = Rack::Builder.new do | ||
use Rack::Lint | ||
use Rack::Tidy | ||
run Rack::URLMap.new({ | ||
"/valid" => lambda { [200, {"Content-Type" => "text/html"}, File.open('test/valid.html')] }, | ||
"/invalid" => lambda { [200, {"Content-Type" => "text/html"}, File.open('test/invalid.html')] }, | ||
}) | ||
end | ||
response = Rack::MockRequest.new(app).get('/valid') | ||
response.status.should.equal(200) | ||
response.body.should.equal(File.read('test/valid.html')) | ||
|
||
response = Rack::MockRequest.new(app).get('/invalid') | ||
response.status.should.equal(200) | ||
response.body.should.equal(File.read('test/invalid-output.html')) | ||
end | ||
|
||
specify "should not run tidy on non-xml" do | ||
app = Rack::Builder.new do | ||
use Rack::Lint | ||
use Rack::Tidy | ||
run Rack::URLMap.new({ | ||
"/image" => lambda { [200, {"Content-Type" => "image/png", "Content-Length" => "9"}, ['>no html<']] }, | ||
}) | ||
end | ||
response = Rack::MockRequest.new(app).get('/image') | ||
response.status.should.equal(200) | ||
response.body.should.equal('>no 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<title>Titel</title> | ||
<link rel="stylesheet" type="text/css" href="style.css" /> | ||
</head> | ||
<body> | ||
<div>Content</div> | ||
</body> | ||
</html> |