spec/sprockets-sass_spec.rb in sprockets-sass-0.8.0 vs spec/sprockets-sass_spec.rb in sprockets-sass-0.9.0
- old
+ new
@@ -247,10 +247,23 @@
@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
+
+ it 'adds the #font_path helper' do
+ @assets.file 'font_path.css.scss', %(@font-face { src: url(font-path("font.ttf")); })
+ @assets.file 'font_url.css.scss', %(@font-face { src: font-url("font.ttf"); })
+ @assets.file 'font_path_options.css.scss', %(@font-face { src: url(font-path("font.ttf", $digest: true, $prefix: "/themes")); })
+ @assets.file 'font_url_options.css.scss', %(@font-face { src: font-url("font.ttf", $digest: true, $prefix: "/themes"); })
+ @assets.file 'font.ttf'
+
+ @env['font_path.css'].to_s.should == %(@font-face {\n src: url("/assets/font.ttf"); }\n)
+ @env['font_url.css'].to_s.should == %(@font-face {\n src: url("/assets/font.ttf"); }\n)
+ @env['font_path_options.css'].to_s.should =~ %r(@font-face \{\n src: url\("/themes/font-[0-9a-f]+.ttf"\); \}\n)
+ @env['font_url_options.css'].to_s.should =~ %r(@font-face \{\n src: url\("/themes/font-[0-9a-f]+.ttf"\); \}\n)
+ end
it 'adds the #asset_data_uri helper' do
@assets.file 'asset_data_uri.css.scss', %(body { background: asset-data-uri("image.jpg"); })
@assets.file 'image.jpg', File.read('spec/fixtures/image.jpg')
@@ -265,25 +278,47 @@
@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['cache_buster.css'].to_s.should == %(body {\n background: url("/assets/image.jpg"); }\n)
end
+
+ it "mirrors Compass's #font_url helper" do
+ @assets.file 'font_path.css.scss', %(@font-face { src: url(font-url("font.ttf", true)); })
+ @assets.file 'font_url.css.scss', %(@font-face { src: font-url("font.ttf", false); })
+ @assets.file 'font.ttf'
+
+ @env['font_path.css'].to_s.should == %(@font-face {\n src: url("/assets/font.ttf"); }\n)
+ @env['font_url.css'].to_s.should == %(@font-face {\n src: url("/assets/font.ttf"); }\n)
+ end
it "mirrors Sass::Rails's #asset_path helpers" do
@assets.file 'asset_path.css.scss', %(body { background: url(asset-path("image.jpg", image)); })
@assets.file 'asset_url.css.scss', %(body { background: asset-url("icon.jpg", image); })
@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("/images/icon.jpg"); }\n)
end
- it "compresses css" do
- css = <<-CSS
- div {
- color: red;
- }
- CSS
-
+ it 'compresses css' do
+ css = "div {\n color: red;\n}\n"
Sprockets::Sass::Compressor.new.compress(css).should == "div{color:red}\n"
+ end
+
+ describe Sprockets::Sass::SassTemplate do
+ describe 'initialize_engine' do
+ it 'initializes super if super is uninitinalized' do
+ Tilt::SassTemplate.stub(:engine_initialized?).and_return false
+ template = Sprockets::Sass::SassTemplate.new {}
+ template.should_receive(:require_template_library) # called from Tilt::SassTemplate.initialize
+ template.initialize_engine
+ end
+
+ it "does not initializes super if super is initinalized to silence warnings" do
+ Tilt::SassTemplate.stub(:engine_initialized?).and_return true
+ template = Sprockets::Sass::SassTemplate.new {}
+ template.should_not_receive(:require_template_library) # called from Tilt::SassTemplate.initialize
+ template.initialize_engine
+ end
+ end
end
end