spec/lib/roadie/inliner_spec.rb in roadie-1.1.3 vs spec/lib/roadie/inliner_spec.rb in roadie-2.0.0
- old
+ new
@@ -147,33 +147,42 @@
end
end
end
describe "linked stylesheets" do
- before(:each) do
- Rails.stub(:root => FixturesPath)
- end
-
it "inlines styles from the linked stylesheet" do
rendering(<<-HTML).should have_styling('color' => 'green').at_selector('p')
<html>
<head>
- <link rel="stylesheet" href="/stylesheets/green_paragraphs.css">
+ <link rel="stylesheet" href="/assets/green_paragraphs.css">
</head>
<body>
<p></p>
</body>
</html>
HTML
end
+ it "inlines styles from the linked stylesheet in subdirectory" do
+ rendering(<<-HTML).should have_styling('color' => 'red').at_selector('p')
+ <html>
+ <head>
+ <link rel="stylesheet" href="/assets/subdirectory/red_paragraphs.css">
+ </head>
+ <body>
+ <p></p>
+ </body>
+ </html>
+ HTML
+ end
+
it "inlines styles from more than one linked stylesheet" do
html = <<-HTML
<html>
<head>
- <link rel="stylesheet" href="/stylesheets/green_paragraphs.css">
- <link rel="stylesheet" href="/stylesheets/large_purple_paragraphs.css">
+ <link rel="stylesheet" href="/assets/green_paragraphs.css">
+ <link rel="stylesheet" href="/assets/large_purple_paragraphs.css">
</head>
<body>
<p></p>
</body>
</html>
@@ -187,12 +196,12 @@
it "removes the stylesheet links from the DOM" do
rendering(<<-HTML).should_not have_selector('link')
<html>
<head>
- <link rel="stylesheet" href="/stylesheets/green_paragraphs.css">
- <link rel="stylesheet" href="/stylesheets/large_purple_paragraphs.css">
+ <link rel="stylesheet" href="/assets/green_paragraphs.css">
+ <link rel="stylesheet" href="/assets/large_purple_paragraphs.css">
</head>
<body>
</body>
</html>
HTML
@@ -201,11 +210,11 @@
context "when stylesheet is for print media" do
it "does not inline the stylesheet" do
rendering(<<-HTML).should_not have_styling('color' => 'green').at_selector('p')
<html>
<head>
- <link rel="stylesheet" href="/stylesheets/green_paragraphs.css" media="print">
+ <link rel="stylesheet" href="/assets/green_paragraphs.css" media="print">
</head>
<body>
<p></p>
</body>
</html>
@@ -214,11 +223,11 @@
it "does not remove the links" do
rendering(<<-HTML).should have_selector('link')
<html>
<head>
- <link rel="stylesheet" href="/stylesheets/green_paragraphs.css" media="print">
+ <link rel="stylesheet" href="/assets/green_paragraphs.css" media="print">
</head>
<body>
</body>
</html>
HTML
@@ -228,11 +237,11 @@
context "when stylesheet is marked as immutable" do
it "does not inline the stylesheet" do
rendering(<<-HTML).should_not have_styling('color' => 'green').at_selector('p')
<html>
<head>
- <link rel="stylesheet" href="/stylesheets/green_paragraphs.css" data-immutable="true">
+ <link rel="stylesheet" href="/assets/green_paragraphs.css" data-immutable="true">
</head>
<body>
<p></p>
</body>
</html>
@@ -241,11 +250,11 @@
it "does not remove link" do
rendering(<<-HTML).should have_selector('link')
<html>
<head>
- <link rel="stylesheet" href="/stylesheets/green_paragraphs.css" data-immutable="true">
+ <link rel="stylesheet" href="/assets/green_paragraphs.css" data-immutable="true">
</head>
<body>
</body>
</html>
HTML
@@ -282,30 +291,30 @@
context "stylesheet cannot be found on disk" do
it "raises an error" do
html = <<-HTML
<html>
<head>
- <link rel="stylesheet" href="/stylesheets/not_found.css">
+ <link rel="stylesheet" href="/assets/not_found.css">
</head>
<body>
</body>
</html>
HTML
expect { rendering(html) }.to raise_error do |error|
error.should be_a(Roadie::CSSFileNotFound)
- error.filename.should == Rails.root.join('public', 'stylesheets', 'not_found.css')
- error.guess.should == '/stylesheets/not_found.css'
+ error.filename.should == Roadie.assets['not_found.css']
+ error.guess.should == '/assets/not_found.css'
end
end
end
context "link element is not for a stylesheet" do
it "is ignored" do
html = <<-HTML
<html>
<head>
- <link rel="not_stylesheet" href="/stylesheets/green_paragraphs.css">
+ <link rel="not_stylesheet" href="/assets/green_paragraphs.css">
</head>
<body>
<p></p>
</body>
</html>