60 lines
1.6 KiB
Ruby
60 lines
1.6 KiB
Ruby
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
require "compass/sprites"
|
|
|
|
describe Compass::Sprites do
|
|
|
|
before :each do
|
|
Compass.configuration.images_path = File.dirname(__FILE__) + "/test_project/public/images"
|
|
Compass.configure_sass_plugin!
|
|
Compass::Sprites.reset
|
|
end
|
|
|
|
def render(scss)
|
|
scss = %Q(@import "compass"; #{scss})
|
|
options = Compass.sass_engine_options
|
|
options[:syntax] = :scss
|
|
options[:load_paths] << Compass::Sprites.new
|
|
css = Sass::Engine.new(scss, options).render
|
|
# reformat to fit result of heredoc:
|
|
" #{css.gsub('@charset "UTF-8";', '').gsub(/\n/, "\n ").strip}\n"
|
|
end
|
|
|
|
it "should generate sprite classes" do
|
|
css = render <<-SCSS
|
|
@import "squares/*.png";
|
|
@include all-squares-sprites;
|
|
SCSS
|
|
css.should == <<-CSS
|
|
.squares-sprite, .squares-10x10, .squares-20x20 {
|
|
background: url('/squares.png') no-repeat; }
|
|
|
|
.squares-10x10 {
|
|
background-position: 0 0; }
|
|
|
|
.squares-20x20 {
|
|
background-position: 0 -10px; }
|
|
CSS
|
|
end
|
|
|
|
it "should generate sprite classes with dimensions" do
|
|
css = render <<-SCSS
|
|
$squares-sprite-dimensions: true;
|
|
@import "squares/*.png";
|
|
@include all-squares-sprites;
|
|
SCSS
|
|
css.should == <<-CSS
|
|
.squares-sprite, .squares-10x10, .squares-20x20 {
|
|
background: url('/squares.png') no-repeat; }
|
|
|
|
.squares-10x10 {
|
|
background-position: 0 0;
|
|
height: 10px;
|
|
width: 10px; }
|
|
|
|
.squares-20x20 {
|
|
background-position: 0 -10px;
|
|
height: 20px;
|
|
width: 20px; }
|
|
CSS
|
|
end
|
|
end |