spec/sprockets-sass_spec.rb in sprockets-sass-0.3.0 vs spec/sprockets-sass_spec.rb in sprockets-sass-0.4.0
- old
+ new
@@ -113,14 +113,14 @@
asset.to_s.should == "body {\n color: blue; }\n"
Sprockets::Sass.options.delete(:load_paths)
end
it "works with the Compass framework" do
- @assets.file "main.css.scss", %(@import "compass/typography/text/nowrap";\np { @include nowrap; })
+ @assets.file "main.css.scss", %(@import "compass/css3";\nbutton { @include border-radius(5px); })
asset = @env["main.css"]
- asset.to_s.should == "p {\n white-space: nowrap; }\n"
+ asset.to_s.should include("border-radius: 5px;")
end
it "imports globbed files" do
@assets.file "main.css.scss", %(@import "folder/*";\nbody { color: $color; background: $bg-color; })
@assets.file "folder/dep1.css.scss", "$color: blue;"
@@ -169,7 +169,33 @@
mtime = Time.now + 1
dep.open("w") { |f| f.write "$bg-color: white;" }
dep.utime mtime, mtime
asset.should be_stale
+ end
+
+ it "adds the #asset_path helper" do
+ @assets.file "asset_path.css.scss", %(body { background: url(asset-path("image.jpg")); })
+ @assets.file "asset_url.css.scss", %(body { background: asset-url("image.jpg"); })
+ @assets.file "asset_path_options.css.scss", %(body { background: url(asset-path("image.jpg", $digest: true, $prefix: "/themes")); })
+ @assets.file "asset_url_options.css.scss", %(body { background: asset-url("image.jpg", $digest: true, $prefix: "/themes"); })
+ @assets.file "image.jpg"
+
+ @env["asset_path.css"].to_s.should == %(body {\n background: url("/assets/image.jpg"); }\n)
+ @env["asset_url.css"].to_s.should == %(body {\n background: url("/assets/image.jpg"); }\n)
+ @env["asset_path_options.css"].to_s.should =~ %r(body \{\n background: url\("/themes/image-[0-9a-f]+.jpg"\); \}\n)
+ @env["asset_url_options.css"].to_s.should =~ %r(body \{\n background: url\("/themes/image-[0-9a-f]+.jpg"\); \}\n)
+ end
+
+ it "adds the #image_path helper" do
+ @assets.file "image_path.css.scss", %(body { background: url(image-path("image.jpg")); })
+ @assets.file "image_url.css.scss", %(body { background: image-url("image.jpg"); })
+ @assets.file "image_path_options.css.scss", %(body { background: url(image-path("image.jpg", $digest: true, $prefix: "/themes")); })
+ @assets.file "image_url_options.css.scss", %(body { background: image-url("image.jpg", $digest: true, $prefix: "/themes"); })
+ @assets.file "image.jpg"
+
+ @env["image_path.css"].to_s.should == %(body {\n background: url("/assets/image.jpg"); }\n)
+ @env["image_url.css"].to_s.should == %(body {\n background: url("/assets/image.jpg"); }\n)
+ @env["image_path_options.css"].to_s.should =~ %r(body \{\n background: url\("/themes/image-[0-9a-f]+.jpg"\); \}\n)
+ @env["image_url_options.css"].to_s.should =~ %r(body \{\n background: url\("/themes/image-[0-9a-f]+.jpg"\); \}\n)
end
end