Merge branch 'master' into stable
* master: sprite test_unit more sprite tests to test_unit sprite base test sprite tests moved over fixed merge in gemfile diff helper refactored tests updated the sencha site graphic updated gemfile updated gemfile updated gemfile fixed merge added application integration to turtorials merge added redirect for reference and updated general layouts redirect Conflicts: Gemfile Gemfile.lock
2
.gitignore
vendored
@ -26,3 +26,5 @@ attic
|
||||
devbin
|
||||
.rvmrc
|
||||
*.rbc
|
||||
vendor/ruby
|
||||
vendor
|
||||
|
8
Gemfile
@ -2,22 +2,24 @@ source :rubygems
|
||||
|
||||
gemspec
|
||||
|
||||
#gem "compass", :path => "." #no idea but it fixed my rage - sdavis
|
||||
gem "cucumber", "~> 0.9.2"
|
||||
gem "rspec", "~>2.0.0"
|
||||
gem "rails", "~>3.0.0.rc"
|
||||
gem "compass-validator", "3.0.0"
|
||||
gem "css_parser", "~> 1.0.1"
|
||||
gem "sass", "~>3.1"
|
||||
gem "haml", "~> 3.1.0.alpha"
|
||||
gem "haml", "~> 3.1"
|
||||
gem "rcov"
|
||||
gem "rubyzip"
|
||||
gem "livereload"
|
||||
gem "rb-fsevent"
|
||||
gem "rb-fsevent" if RUBY_PLATFORM =~ /darwin/
|
||||
|
||||
gem "ruby-prof" unless RUBY_PLATFORM == "java"
|
||||
|
||||
gem 'autotest'
|
||||
gem 'autotest-fsevent' if RUBY_PLATFORM =~ /darwin/
|
||||
gem 'fakefs', :git => 'git://github.com/johnbintz/fakefs.git'
|
||||
gem 'mocha'
|
||||
gem 'timecop'
|
||||
gem 'diff-lcs', '~> 1.1.2'
|
||||
|
||||
|
10
Gemfile.lock
@ -7,7 +7,7 @@ GIT
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
compass (0.11.1.ef013a2)
|
||||
compass (0.11.1.8e2292b)
|
||||
chunky_png (~> 1.1)
|
||||
fssm (>= 0.2.7)
|
||||
sass (~> 3.1)
|
||||
@ -47,6 +47,8 @@ GEM
|
||||
arel (2.0.9)
|
||||
autotest (4.4.6)
|
||||
ZenTest (>= 4.4.1)
|
||||
autotest-fsevent (0.2.5)
|
||||
sys-uname
|
||||
builder (2.1.2)
|
||||
chunky_png (1.1.1)
|
||||
compass-validator (3.0.0)
|
||||
@ -69,7 +71,7 @@ GEM
|
||||
gherkin (2.2.9)
|
||||
json (~> 1.4.6)
|
||||
term-ansicolor (~> 1.0.5)
|
||||
haml (3.1.0.alpha.147)
|
||||
haml (3.1.1)
|
||||
i18n (0.5.0)
|
||||
json (1.4.6)
|
||||
livereload (1.6)
|
||||
@ -131,12 +133,14 @@ PLATFORMS
|
||||
|
||||
DEPENDENCIES
|
||||
autotest
|
||||
autotest-fsevent
|
||||
compass!
|
||||
compass-validator (= 3.0.0)
|
||||
css_parser (~> 1.0.1)
|
||||
cucumber (~> 0.9.2)
|
||||
diff-lcs (~> 1.1.2)
|
||||
fakefs!
|
||||
haml (~> 3.1.0.alpha)
|
||||
haml (~> 3.1)
|
||||
livereload
|
||||
mocha
|
||||
rails (~> 3.0.0.rc)
|
||||
|
1
doc-src/.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
bin
|
||||
vendor
|
||||
output
|
||||
vendor/ruby
|
||||
|
@ -8,8 +8,8 @@ gem 'mime-types'
|
||||
gem 'serve', "1.0.0"
|
||||
gem 'nokogiri'
|
||||
gem 'coderay'
|
||||
gem 'sass', ">= 3.1.0.alpha.249"
|
||||
gem 'haml', ">= 3.1.0.alpha.36"
|
||||
gem 'sass', ">= 3.1"
|
||||
gem 'haml', ">= 3.1"
|
||||
gem 'rake'
|
||||
gem 'compass', :path => ".."
|
||||
gem 'compass-susy-plugin', ">=0.7.0.pre8"
|
||||
@ -19,3 +19,4 @@ gem 'css_parser', "1.0.1"
|
||||
gem 'ruby-prof'
|
||||
gem 'rb-fsevent'
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ GIT
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
compass (0.11.1.63cae60)
|
||||
compass (0.11.1.26f44fd)
|
||||
chunky_png (~> 1.1)
|
||||
fssm (>= 0.2.7)
|
||||
sass (~> 3.1)
|
||||
@ -16,7 +16,7 @@ PATH
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
activesupport (3.0.5)
|
||||
activesupport (3.0.7)
|
||||
chunky_png (1.1.1)
|
||||
coderay (0.9.7)
|
||||
compass-susy-plugin (0.9.beta.3)
|
||||
@ -26,7 +26,7 @@ GEM
|
||||
compass (>= 0.10.0.rc3)
|
||||
css_parser (1.0.1)
|
||||
fssm (0.2.7)
|
||||
haml (3.1.0.alpha.147)
|
||||
haml (3.1.0)
|
||||
i18n (0.4.2)
|
||||
json (1.5.1)
|
||||
mime-types (1.16)
|
||||
@ -43,7 +43,7 @@ GEM
|
||||
rack (~> 1.2.1)
|
||||
tzinfo (~> 0.3.23)
|
||||
thor (0.14.6)
|
||||
tzinfo (0.3.25)
|
||||
tzinfo (0.3.26)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@ -54,7 +54,7 @@ DEPENDENCIES
|
||||
compass-susy-plugin (>= 0.7.0.pre8)
|
||||
css-slideshow (= 0.2.0)
|
||||
css_parser (= 1.0.1)
|
||||
haml (>= 3.1.0.alpha.36)
|
||||
haml (>= 3.1)
|
||||
json
|
||||
mime-types
|
||||
nanoc3!
|
||||
@ -64,6 +64,6 @@ DEPENDENCIES
|
||||
rb-fsevent
|
||||
rdiscount
|
||||
ruby-prof
|
||||
sass (>= 3.1.0.alpha.249)
|
||||
sass (>= 3.1)
|
||||
serve (= 1.0.0)
|
||||
thor
|
||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 13 KiB |
83
doc-src/content/help/tutorials/integration.markdown
Normal file
@ -0,0 +1,83 @@
|
||||
---
|
||||
title: Application Integration
|
||||
layout: tutorial
|
||||
crumb: Appliction Integration
|
||||
classnames:
|
||||
- tutorial
|
||||
---
|
||||
# Application Integration
|
||||
|
||||
## Ruby on Rails
|
||||
|
||||
### Rails 3
|
||||
compass init rails /path/to/myrailsproject
|
||||
### Rails 2.3
|
||||
rake rails:template LOCATION=http://compass-style.org/rails/installer
|
||||
|
||||
## Sinatra
|
||||
|
||||
require 'sinatra'
|
||||
require 'haml'
|
||||
require 'sass'
|
||||
require 'compass'
|
||||
|
||||
configure do
|
||||
Compass.configuration do |config|
|
||||
config.project_path = File.dirname(__FILE__)
|
||||
config.sass_dir = 'views'
|
||||
end
|
||||
|
||||
set :haml, { :format => :html5 }
|
||||
set :sass, Compass.sass_engine_options
|
||||
end
|
||||
|
||||
get '/screen.css' do
|
||||
content_type 'text/css', :charset => 'utf-8'
|
||||
sass :screen
|
||||
end
|
||||
|
||||
If you keep your stylesheets in “views/stylesheets/” directory instead of just “views/”, remember to update sass_dir configuration accordingly.
|
||||
Check out this [sample compass-sinatra project](http://github.com/chriseppstein/compass-sinatra) to get up and running in no time!
|
||||
|
||||
[Sinatra Bootstrap](http://github.com/adamstac/sinatra-bootstrap) - a base Sinatra project with support for Haml, Sass, Compass, jQuery and more.
|
||||
|
||||
## Nanoc3
|
||||
|
||||
### Minimal integration: just drop it in
|
||||
|
||||
One simple route for lightweight integration is to simply install compass inside nanoc. Then edit config.rb to point to the stylesheets you want to use. This means you have to have the Compass watch command running in a separate window from the Nanoc compilation process.
|
||||
|
||||
Example project that works this way: http://github.com/unthinkingly/unthinkingly-blog
|
||||
|
||||
### More formal integration
|
||||
|
||||
At the top of the Nanoc Rules file, load the Compass configuration, like this:
|
||||
|
||||
require 'compass'
|
||||
|
||||
Compass.add_project_configuration 'compass/config.rb' # when using Compass 0.10
|
||||
Compass.configuration.parse 'compass/config.rb' # when using Compass < 0.10
|
||||
|
||||
Your Compass configuration file (in compass/config.rb) could look like this (you may need to change the path to some directories depending on your directory structure):
|
||||
|
||||
http_path = "/"
|
||||
project_path = "."
|
||||
css_dir = "output/assets/style"
|
||||
sass_dir = "content/assets/style"
|
||||
images_dir = "output/assets/images"
|
||||
|
||||
# when using SCSS:
|
||||
sass_options = {
|
||||
:syntax => :scss
|
||||
}
|
||||
|
||||
|
||||
To filter the stylesheets using Sass and Compass, call the sass filter with Sass engine options taken from Compass, like this:
|
||||
|
||||
filter :sass, Compass.sass_engine_options
|
||||
|
||||
|
||||
### Nanoc Projects using the formal approach
|
||||
|
||||
* [nanoc Bootstrap](http://github.com/adamstac/nanoc-bootstrap) - a base nanoc project with support for Haml, Sass, Compass, jQuery and more.
|
||||
* [nanoc & Compass Example Project](http://github.com/ddfreyne/nanoc-bootstrap-compass)
|
4
doc-src/content/reference.haml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
title: Compass Documentation
|
||||
redirect: /reference/compass/
|
||||
---
|
@ -12,7 +12,7 @@
|
||||
Version:
|
||||
%a.number(href="/CHANGELOG/")= compass_version
|
||||
%article= yield
|
||||
-#comments= render "partials/disqus_comments"
|
||||
-comments= render "partials/disqus_comments"
|
||||
%footer(role="contentinfo")= render "partials/footer"
|
||||
= @item[:content_for_javascripts]
|
||||
= render "partials/analytics"
|
||||
|
@ -14,7 +14,7 @@
|
||||
Version:
|
||||
%a.number(href="/CHANGELOG/")= compass_version
|
||||
%article= yield
|
||||
-#comments= render "partials/disqus_comments"
|
||||
-comments= render "partials/disqus_comments"
|
||||
%footer(role="contentinfo")= render "partials/footer"
|
||||
= @item[:content_for_javascripts]
|
||||
= render "partials/analytics"
|
||||
|
5
doc-src/layouts/redirect.haml
Normal file
@ -0,0 +1,5 @@
|
||||
!!!5
|
||||
- # This template redirects.
|
||||
%html{:dir => "ltr", :lang => "en"}
|
||||
%head
|
||||
%meta{:"http-equiv" => "refresh", :content => "0;#{@item[:redirect]}"}/
|
@ -12,7 +12,7 @@ module Compass
|
||||
sprites = sprite_map.files.map do |sprite|
|
||||
sprite.gsub(Compass.configuration.images_path+"/", "")
|
||||
end
|
||||
new(sprites, sprite_map.path, sprite_map.name, context, kwargs)
|
||||
new(sprites, sprite_map, context, kwargs)
|
||||
end
|
||||
|
||||
# Loads the sprite engine
|
||||
@ -24,17 +24,18 @@ module Compass
|
||||
# We should do so only when the packing algorithm changes
|
||||
SPRITE_VERSION = "1"
|
||||
|
||||
attr_accessor :image_names, :path, :name, :options
|
||||
attr_accessor :image_names, :path, :name, :options, :map
|
||||
attr_accessor :images, :width, :height
|
||||
|
||||
|
||||
def initialize(image_names, path, name, context, options)
|
||||
def initialize(image_names, map, context, options)
|
||||
require_engine!
|
||||
@image_names, @path, @name, @options = image_names, path, name, options
|
||||
@image_names, @path, @name, @options = image_names, map.path, map.name, options
|
||||
@images = nil
|
||||
@width = nil
|
||||
@height = nil
|
||||
@evaluation_context = context
|
||||
@map = map
|
||||
validate!
|
||||
compute_image_metadata!
|
||||
end
|
||||
|
@ -5,18 +5,14 @@ require 'compass/logger'
|
||||
require 'sass/plugin'
|
||||
|
||||
class CompassTest < Test::Unit::TestCase
|
||||
include Compass::TestCaseHelper
|
||||
|
||||
def setup
|
||||
Compass.reset_configuration!
|
||||
end
|
||||
|
||||
def teardown
|
||||
teardown_fixtures :blueprint, :empty, :compass, :image_urls, :relative
|
||||
end
|
||||
|
||||
def teardown_fixtures(*project_names)
|
||||
project_names.each do |project_name|
|
||||
FileUtils.rm_rf tempfile_path(project_name)
|
||||
[:blueprint, :empty, :compass, :image_urls, :relative].each do |project_name|
|
||||
::FileUtils.rm_rf tempfile_path(project_name)
|
||||
end
|
||||
end
|
||||
|
||||
@ -117,7 +113,11 @@ private
|
||||
expected_lines = expected_lines.split("\n").reject{|l| l=~/\A\Z/}
|
||||
expected_lines.zip(actual_lines).each_with_index do |pair, line|
|
||||
message = "template: #{name}\nline: #{line + 1}"
|
||||
assert_equal(pair.first, pair.last, message)
|
||||
if pair.first == pair.last
|
||||
assert(true)
|
||||
else
|
||||
assert false, diff_as_string(pair.first.inspect, pair.last.inspect)
|
||||
end
|
||||
end
|
||||
if expected_lines.size < actual_lines.size
|
||||
assert(false, "#{actual_lines.size - expected_lines.size} Trailing lines found in #{actual_result_file}.css: #{actual_lines[expected_lines.size..-1].join('\n')}")
|
||||
|
@ -3,9 +3,12 @@ require 'compass'
|
||||
require 'stringio'
|
||||
|
||||
class ConfigurationTest < Test::Unit::TestCase
|
||||
include Compass::IoHelper
|
||||
|
||||
def setup
|
||||
setup do
|
||||
Compass.reset_configuration!
|
||||
end
|
||||
|
||||
after do
|
||||
Compass.reset_configuration!
|
||||
end
|
||||
|
||||
@ -15,18 +18,23 @@ class ConfigurationTest < Test::Unit::TestCase
|
||||
# Require any additional compass plugins here.
|
||||
|
||||
project_type = :stand_alone
|
||||
|
||||
# Set this to the root of your project when deployed:
|
||||
http_path = "/"
|
||||
css_dir = "css"
|
||||
sass_dir = "sass"
|
||||
images_dir = "img"
|
||||
javascripts_dir = "js"
|
||||
|
||||
output_style = :nested
|
||||
|
||||
# To enable relative paths to assets via compass helper functions. Uncomment:
|
||||
# relative_assets = true
|
||||
|
||||
# To disable debugging comments that display the original location of your selectors. Uncomment:
|
||||
# line_comments = false
|
||||
|
||||
|
||||
# If you prefer the indented syntax, you might want to regenerate this
|
||||
# project again passing --syntax sass, or you can uncomment this:
|
||||
# preferred_syntax = :sass
|
||||
@ -43,7 +51,7 @@ class ConfigurationTest < Test::Unit::TestCase
|
||||
|
||||
expected_lines = contents.string.split("\n").map{|l|l.strip}
|
||||
actual_lines = Compass.configuration.serialize.split("\n").map{|l|l.strip}
|
||||
assert_equal expected_lines, actual_lines
|
||||
assert_correct expected_lines, actual_lines
|
||||
end
|
||||
|
||||
def test_serialization_warns_with_asset_host_set
|
||||
@ -101,19 +109,23 @@ class ConfigurationTest < Test::Unit::TestCase
|
||||
expected_serialization = <<EXPECTED
|
||||
# Require any additional compass plugins here.
|
||||
project_path = "/home/chris/my_compass_project"
|
||||
|
||||
# Set this to the root of your project when deployed:
|
||||
http_path = "/"
|
||||
css_dir = "css"
|
||||
|
||||
# You can select your preferred output style here (can be overridden via the command line):
|
||||
# output_style = :expanded or :nested or :compact or :compressed
|
||||
|
||||
# To enable relative paths to assets via compass helper functions. Uncomment:
|
||||
# relative_assets = true
|
||||
additional_import_paths = ["../foo", "/path/to/my/framework"]
|
||||
|
||||
# To disable debugging comments that display the original location of your selectors. Uncomment:
|
||||
# line_comments = false
|
||||
EXPECTED
|
||||
assert_equal "/", Compass.configuration.http_path
|
||||
assert_equal expected_serialization.split("\n"), Compass.configuration.serialize.split("\n")
|
||||
assert_correct expected_serialization.split("\n"), Compass.configuration.serialize.split("\n")
|
||||
end
|
||||
|
||||
def test_config_with_pathname
|
||||
@ -137,19 +149,23 @@ EXPECTED
|
||||
expected_serialization = <<EXPECTED
|
||||
# Require any additional compass plugins here.
|
||||
project_path = "/home/chris/my_compass_project"
|
||||
|
||||
# Set this to the root of your project when deployed:
|
||||
http_path = "/"
|
||||
css_dir = "css"
|
||||
|
||||
# You can select your preferred output style here (can be overridden via the command line):
|
||||
# output_style = :expanded or :nested or :compact or :compressed
|
||||
|
||||
# To enable relative paths to assets via compass helper functions. Uncomment:
|
||||
# relative_assets = true
|
||||
additional_import_paths = ["../foo", "/path/to/my/framework"]
|
||||
|
||||
# To disable debugging comments that display the original location of your selectors. Uncomment:
|
||||
# line_comments = false
|
||||
EXPECTED
|
||||
assert_equal "/", Compass.configuration.http_path
|
||||
assert_equal expected_serialization.split("\n"), Compass.configuration.serialize.split("\n")
|
||||
assert_correct expected_serialization.split("\n"), Compass.configuration.serialize.split("\n")
|
||||
end
|
||||
|
||||
def test_sass_options
|
||||
@ -164,18 +180,22 @@ EXPECTED
|
||||
|
||||
expected_serialization = <<EXPECTED
|
||||
# Require any additional compass plugins here.
|
||||
|
||||
# Set this to the root of your project when deployed:
|
||||
http_path = "/"
|
||||
http_path = \"/\"
|
||||
|
||||
# You can select your preferred output style here (can be overridden via the command line):
|
||||
# output_style = :expanded or :nested or :compact or :compressed
|
||||
|
||||
# To enable relative paths to assets via compass helper functions. Uncomment:
|
||||
# relative_assets = true
|
||||
sass_options = {:foo=>"bar"}
|
||||
# relative_assets = true\nsass_options = {:foo=>\"bar\"}
|
||||
|
||||
# To disable debugging comments that display the original location of your selectors. Uncomment:
|
||||
# line_comments = false
|
||||
|
||||
EXPECTED
|
||||
|
||||
assert_equal expected_serialization, Compass.configuration.serialize
|
||||
assert_correct(expected_serialization, Compass.configuration.serialize)
|
||||
end
|
||||
|
||||
def test_strip_trailing_directory_separators
|
||||
@ -223,18 +243,24 @@ EXPECTED
|
||||
assert_equal "baz", Compass.configuration.foobar
|
||||
expected_serialization = <<EXPECTED
|
||||
# Require any additional compass plugins here.
|
||||
|
||||
# Set this to the root of your project when deployed:
|
||||
http_path = "/"
|
||||
|
||||
# You can select your preferred output style here (can be overridden via the command line):
|
||||
# output_style = :expanded or :nested or :compact or :compressed
|
||||
|
||||
# To enable relative paths to assets via compass helper functions. Uncomment:
|
||||
# relative_assets = true
|
||||
|
||||
# To disable debugging comments that display the original location of your selectors. Uncomment:
|
||||
# line_comments = false
|
||||
|
||||
|
||||
# this is a foobar
|
||||
foobar = "baz"
|
||||
EXPECTED
|
||||
assert_equal expected_serialization, Compass.configuration.serialize
|
||||
assert_correct(expected_serialization, Compass.configuration.serialize)
|
||||
Compass.reset_configuration!
|
||||
Compass.configuration.environment = :production
|
||||
assert_equal "foo", Compass.configuration.foobar
|
||||
@ -255,5 +281,4 @@ EXPECTED
|
||||
end.compact
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
BIN
test/fixtures/sprites/public/images/ko/default_background.png
vendored
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
test/fixtures/sprites/public/images/ko/starbg26x27.png
vendored
Executable file
After Width: | Height: | Size: 1.1 KiB |
BIN
test/fixtures/sprites/public/images/nested/squares/ten-by-ten.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
test/fixtures/sprites/public/images/prefix/20-by-20.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
test/fixtures/sprites/public/images/prefix/ten-by-ten.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
test/fixtures/sprites/public/images/selectors/ten-by-ten.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
test/fixtures/sprites/public/images/selectors/ten-by-ten_active.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
test/fixtures/sprites/public/images/selectors/ten-by-ten_hover.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
test/fixtures/sprites/public/images/selectors/ten-by-ten_target.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
test/fixtures/sprites/public/images/squares/ten-by-ten.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
test/fixtures/sprites/public/images/squares/twenty-by-twenty.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
1
test/fixtures/stylesheets/relative/config.rb
vendored
@ -6,4 +6,5 @@ javascripts_dir = "assets/javascripts"
|
||||
# Set this to the root of your project when deployed:
|
||||
http_path = "/"
|
||||
# To enable relative paths to assets via compass helper functions. Uncomment:
|
||||
output_style = :compact
|
||||
relative_assets = true
|
||||
|
49
test/helpers/diff.rb
Normal file
@ -0,0 +1,49 @@
|
||||
require 'diff/lcs'
|
||||
require 'diff/lcs/hunk'
|
||||
module Compass
|
||||
module Diff
|
||||
#stole this from rspec who stole this from the gem
|
||||
def diff_as_string(data_new, data_old)
|
||||
data_old = data_old.split(/\n/).map! { |e| e.chomp }
|
||||
data_new = data_new.split(/\n/).map! { |e| e.chomp }
|
||||
output = ""
|
||||
diffs = ::Diff::LCS.diff(data_old, data_new)
|
||||
return output if diffs.empty?
|
||||
oldhunk = hunk = nil
|
||||
file_length_difference = 0
|
||||
diffs.each do |piece|
|
||||
begin
|
||||
hunk = ::Diff::LCS::Hunk.new(
|
||||
data_old, data_new, piece, context_lines, file_length_difference
|
||||
)
|
||||
file_length_difference = hunk.file_length_difference
|
||||
next unless oldhunk
|
||||
# Hunks may overlap, which is why we need to be careful when our
|
||||
# diff includes lines of context. Otherwise, we might print
|
||||
# redundant lines.
|
||||
if (context_lines > 0) and hunk.overlaps?(oldhunk)
|
||||
hunk.unshift(oldhunk)
|
||||
else
|
||||
output << oldhunk.diff(format)
|
||||
end
|
||||
ensure
|
||||
oldhunk = hunk
|
||||
output << "\n"
|
||||
end
|
||||
end
|
||||
#Handle the last remaining hunk
|
||||
output << oldhunk.diff(format) << "\n"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def format
|
||||
:unified
|
||||
end
|
||||
|
||||
def context_lines
|
||||
3
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -12,6 +12,7 @@ module Compass
|
||||
# by manipulating the load path.
|
||||
def generate_rails_app(name)
|
||||
if pid = fork
|
||||
puts "HELP I FORKED"
|
||||
Process.wait(pid)
|
||||
if $?.exitstatus == 2
|
||||
raise LoadError, "Couldn't load rails"
|
57
test/helpers/test_case.rb
Normal file
@ -0,0 +1,57 @@
|
||||
module Compass
|
||||
module TestCaseHelper
|
||||
def absolutize(path)
|
||||
if Compass::Util.blank?(path)
|
||||
File.expand_path('../../', __FILE__)
|
||||
elsif path[0] == ?/
|
||||
File.join(File.expand_path('../', __FILE__), path)
|
||||
else
|
||||
File.join(File.expand_path('../../', __FILE__), path)
|
||||
end
|
||||
end
|
||||
|
||||
def assert_correct(before, after)
|
||||
if before == after
|
||||
assert(true)
|
||||
else
|
||||
assert false, diff_as_string(before.inspect, after.inspect)
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
||||
def let(method, &block)
|
||||
define_method method, &block
|
||||
end
|
||||
|
||||
def it(name, &block)
|
||||
test(name, &block)
|
||||
end
|
||||
|
||||
def test(name, &block)
|
||||
define_method "test_#{underscore(name)}".to_sym, &block
|
||||
end
|
||||
|
||||
def setup(&block)
|
||||
define_method :setup do
|
||||
yield
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def after(&block)
|
||||
define_method :teardown do
|
||||
yield
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def underscore(string)
|
||||
string.gsub(' ', '_')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -5,7 +5,6 @@ require 'compass/exec'
|
||||
require 'timeout'
|
||||
|
||||
class RailsIntegrationTest < Test::Unit::TestCase
|
||||
include Compass::TestCaseHelper
|
||||
include Compass::CommandLineHelper
|
||||
include Compass::IoHelper
|
||||
include Compass::RailsHelper
|
||||
|
73
test/sprites/base_test.rb
Normal file
@ -0,0 +1,73 @@
|
||||
require 'test_helper'
|
||||
|
||||
class SpritesBaseTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@images_src_path = File.join(File.dirname(__FILE__), '..', 'fixtures', 'sprites', 'public', 'images')
|
||||
@images_tmp_path = File.join(File.dirname(__FILE__), '..', 'fixtures', 'sprites', 'public', 'images-tmp')
|
||||
FileUtils.cp_r @images_src_path, @images_tmp_path
|
||||
config = Compass::Configuration::Data.new('config')
|
||||
config.images_path = @images_tmp_path
|
||||
Compass.add_configuration(config)
|
||||
Compass.configure_sass_plugin!
|
||||
options = Compass.sass_engine_options.extend Compass::SassExtensions::Functions::Sprites::VariableReader
|
||||
@map = Compass::SpriteMap.new("selectors/*.png", options)
|
||||
@base = Compass::SassExtensions::Sprites::Base.new(@map.sprite_names.map{|n| "selectors/#{n}.png"}, @map, @map.sass_engine, @map.options)
|
||||
end
|
||||
|
||||
def teardown
|
||||
FileUtils.rm_r @images_tmp_path
|
||||
end
|
||||
|
||||
it "should have the correct size" do
|
||||
assert_equal [10,40], @base.size
|
||||
end
|
||||
|
||||
it "should have the sprite names" do
|
||||
assert_equal @map.sprite_names, @base.sprite_names
|
||||
end
|
||||
|
||||
it 'should have image filenames' do
|
||||
assert_equal Dir["#{@images_tmp_path}/selectors/*.png"].sort, @base.image_filenames
|
||||
end
|
||||
|
||||
it 'should need generation' do
|
||||
assert @base.generation_required?
|
||||
end
|
||||
|
||||
test 'uniqueness_hash' do
|
||||
assert_equal 'ef52c5c63a', @base.uniqueness_hash
|
||||
end
|
||||
|
||||
it 'should be outdated' do
|
||||
assert @base.outdated?
|
||||
end
|
||||
|
||||
it 'should have correct filename' do
|
||||
assert_equal File.join(@images_tmp_path, "#{@base.path}-#{@base.uniqueness_hash}.png"), @base.filename
|
||||
end
|
||||
|
||||
it "should return the 'ten-by-ten' image" do
|
||||
assert_equal 'ten-by-ten', @base.image_for('ten-by-ten').name
|
||||
assert @base.image_for('ten-by-ten').is_a?(Compass::SassExtensions::Sprites::Image)
|
||||
end
|
||||
|
||||
%w(target hover active).each do |selector|
|
||||
it "should have a #{selector}" do
|
||||
assert @base.send(:"has_#{selector}?", 'ten-by-ten')
|
||||
end
|
||||
|
||||
it "should return #{selector} image class" do
|
||||
assert_equal "ten-by-ten_#{selector}", @base.image_for('ten-by-ten').send(:"#{selector}").name
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it "should generate sprite" do
|
||||
@base.generate
|
||||
assert File.exists?(@base.filename)
|
||||
assert !@base.generation_required?
|
||||
assert !@base.outdated?
|
||||
end
|
||||
|
||||
end
|
96
test/sprites/image_test.rb
Normal file
@ -0,0 +1,96 @@
|
||||
require 'test_helper'
|
||||
require 'mocha'
|
||||
require 'ostruct'
|
||||
class SpritesImageTest < Test::Unit::TestCase
|
||||
|
||||
|
||||
def setup
|
||||
@images_src_path = File.join(File.dirname(__FILE__), '..', 'fixtures', 'sprites', 'public', 'images')
|
||||
file = StringIO.new("images_path = #{@images_src_path.inspect}\n")
|
||||
Compass.add_configuration(file, "sprite_config")
|
||||
@repeat = 'no-repeat'
|
||||
@spacing = 0
|
||||
@position = 100
|
||||
@offset = 100
|
||||
end
|
||||
|
||||
let(:sprite_filename) { 'squares/ten-by-ten.png' }
|
||||
let(:sprite_path) { File.join(@images_src_path, sprite_filename) }
|
||||
let(:sprite_name) { File.basename(sprite_filename, '.png') }
|
||||
def parent
|
||||
map = Compass::SpriteMap.new("selectors/*.png", options)
|
||||
@parent ||= Compass::SassExtensions::Sprites::Base.new(map.sprite_names.map{|n| "selectors/#{n}.png"}, map, map.sass_engine, map.options)
|
||||
end
|
||||
|
||||
let(:options) do
|
||||
options = {:offset => @offset}
|
||||
options.stubs(:get_var).with(anything).returns(nil)
|
||||
::OpenStruct.any_instance.stubs(:unitless?).returns(true)
|
||||
options.stubs(:get_var).with("#{sprite_name}-repeat").returns(::OpenStruct.new(:value => @repeat))
|
||||
options.stubs(:get_var).with("#{sprite_name}-spacing").returns(::OpenStruct.new(:value => @spacing))
|
||||
options.stubs(:get_var).with("#{sprite_name}-position").returns(::OpenStruct.new(:value => @position))
|
||||
options
|
||||
end
|
||||
|
||||
|
||||
|
||||
let(:digest) { Digest::MD5.file(sprite_path).hexdigest }
|
||||
|
||||
|
||||
let(:image) { Compass::SassExtensions::Sprites::Image.new(parent, File.join(sprite_filename), options)}
|
||||
|
||||
test 'initialize' do
|
||||
assert_equal sprite_name, image.name
|
||||
assert_equal sprite_path, image.file
|
||||
assert_equal sprite_filename, image.relative_file
|
||||
assert_equal 10, image.width
|
||||
assert_equal 10, image.height
|
||||
assert_equal digest, image.digest
|
||||
assert_equal 0, image.top
|
||||
assert_equal 0, image.left
|
||||
end
|
||||
|
||||
test 'hover' do
|
||||
assert_equal 'ten-by-ten_hover', image.hover.name
|
||||
end
|
||||
|
||||
test 'no parent' do
|
||||
assert_nil image.parent
|
||||
end
|
||||
|
||||
test 'image type is nil' do
|
||||
@repeat = nil
|
||||
assert_nil image.repeat
|
||||
end
|
||||
|
||||
|
||||
test 'image type is "global"' do
|
||||
@repeat = 'global'
|
||||
assert_equal @repeat, image.repeat
|
||||
end
|
||||
|
||||
test 'image type is "no-repeat"' do
|
||||
assert_equal 'no-repeat', image.repeat
|
||||
end
|
||||
|
||||
test 'image position' do
|
||||
assert_equal Sass::Script::Number.new(100, ["px"]).value, image.position.value
|
||||
end
|
||||
|
||||
test 'image spacing' do
|
||||
@spacing = 10
|
||||
assert_equal @spacing, image.spacing
|
||||
end
|
||||
|
||||
test 'offset' do
|
||||
assert_equal @offset, image.offset
|
||||
end
|
||||
|
||||
test 'neither, uses 0' do
|
||||
@offset = 0
|
||||
img = image
|
||||
img.position.stubs(:unitless?).returns(false)
|
||||
assert_equal 0, img.offset
|
||||
end
|
||||
|
||||
end
|
550
test/sprites_test.rb
Normal file
@ -0,0 +1,550 @@
|
||||
require 'test_helper'
|
||||
require 'fileutils'
|
||||
require 'compass'
|
||||
require 'compass/logger'
|
||||
require 'sass/plugin'
|
||||
|
||||
|
||||
class SpritesTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
Compass.reset_configuration!
|
||||
@images_src_path = File.join(File.dirname(__FILE__), 'fixtures', 'sprites', 'public', 'images')
|
||||
@images_tmp_path = File.join(File.dirname(__FILE__), 'fixtures', 'sprites', 'public', 'images-tmp')
|
||||
::FileUtils.cp_r @images_src_path, @images_tmp_path
|
||||
file = StringIO.new("images_path = #{@images_tmp_path.inspect}\n")
|
||||
Compass.add_configuration(file, "sprite_config")
|
||||
Compass.configure_sass_plugin!
|
||||
end
|
||||
|
||||
def teardown
|
||||
Compass.reset_configuration!
|
||||
::FileUtils.rm_r @images_tmp_path
|
||||
end
|
||||
|
||||
|
||||
def map_location(file)
|
||||
Dir.glob(File.join(@images_tmp_path, file)).first
|
||||
end
|
||||
|
||||
def image_size(file)
|
||||
IO.read(map_location(file))[0x10..0x18].unpack('NN')
|
||||
end
|
||||
|
||||
def image_md5(file)
|
||||
md5 = Digest::MD5.new
|
||||
md5.update IO.read(map_location(file))
|
||||
md5.hexdigest
|
||||
end
|
||||
|
||||
def render(scss)
|
||||
scss = %Q(@import "compass"; #{scss})
|
||||
options = Compass.sass_engine_options
|
||||
options[:line_comments] = false
|
||||
options[:style] = :expanded
|
||||
options[:syntax] = :scss
|
||||
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
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-161c60ad78.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.squares-twenty-by-twenty {
|
||||
background-position: 0 -10px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-*.png'), 'fcc93d7b279c2ad6898fbca49cbd01e1'
|
||||
end
|
||||
|
||||
it "should generate sprite classes with dimensions" do
|
||||
css = render <<-SCSS
|
||||
$squares-sprite-dimensions: true;
|
||||
@import "squares/*.png";
|
||||
@include all-squares-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-161c60ad78.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
background-position: 0 0;
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
.squares-twenty-by-twenty {
|
||||
background-position: 0 -10px;
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
end
|
||||
|
||||
it "should provide sprite mixin" do
|
||||
css = render <<-SCSS
|
||||
@import "squares/*.png";
|
||||
|
||||
.cubicle {
|
||||
@include squares-sprite("ten-by-ten");
|
||||
}
|
||||
|
||||
.large-cube {
|
||||
@include squares-sprite("twenty-by-twenty", true);
|
||||
}
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .cubicle, .large-cube {
|
||||
background: url('/squares-161c60ad78.png') no-repeat;
|
||||
}
|
||||
|
||||
.cubicle {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.large-cube {
|
||||
background-position: 0 -10px;
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
end
|
||||
|
||||
# CUSTOMIZATIONS:
|
||||
|
||||
it "should be possible to change the base class" do
|
||||
css = render <<-SCSS
|
||||
$squares-sprite-base-class: ".circles";
|
||||
@import "squares/*.png";
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.circles {
|
||||
background: url('/squares-161c60ad78.png') no-repeat;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
end
|
||||
|
||||
it "should calculate the spacing between images but not before first image" do
|
||||
css = render <<-SCSS
|
||||
$squares-ten-by-ten-spacing: 33px;
|
||||
@import "squares/*.png";
|
||||
@include all-squares-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-89450808af.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.squares-twenty-by-twenty {
|
||||
background-position: 0 -43px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 63]
|
||||
end
|
||||
|
||||
it "should calculate the spacing between images" do
|
||||
css = render <<-SCSS
|
||||
$squares-twenty-by-twenty-spacing: 33px;
|
||||
@import "squares/*.png";
|
||||
@include all-squares-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-673837183a.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.squares-twenty-by-twenty {
|
||||
background-position: 0 -43px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 63]
|
||||
end
|
||||
|
||||
it "should calculate the maximum spacing between images" do
|
||||
css = render <<-SCSS
|
||||
$squares-ten-by-ten-spacing: 44px;
|
||||
$squares-twenty-by-twenty-spacing: 33px;
|
||||
@import "squares/*.png";
|
||||
@include all-squares-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-1cd84c9068.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.squares-twenty-by-twenty {
|
||||
background-position: 0 -54px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 74]
|
||||
end
|
||||
|
||||
it "should calculate the maximum spacing between images in reversed order" do
|
||||
css = render <<-SCSS
|
||||
$squares-ten-by-ten-spacing: 33px;
|
||||
$squares-twenty-by-twenty-spacing: 44px;
|
||||
@import "squares/*.png";
|
||||
@include all-squares-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-f25b7090ca.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.squares-twenty-by-twenty {
|
||||
background-position: 0 -54px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 74]
|
||||
end
|
||||
|
||||
it "should calculate the default spacing between images" do
|
||||
css = render <<-SCSS
|
||||
$squares-spacing: 22px;
|
||||
@import "squares/*.png";
|
||||
@include all-squares-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-d66bf24bab.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.squares-twenty-by-twenty {
|
||||
background-position: 0 -32px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 52]
|
||||
end
|
||||
|
||||
it "should use position adjustments in functions" do
|
||||
css = render <<-SCSS
|
||||
$squares: sprite-map("squares/*.png", $position: 100%);
|
||||
.squares-sprite {
|
||||
background: $squares no-repeat;
|
||||
}
|
||||
|
||||
.adjusted-percentage {
|
||||
background-position: sprite-position($squares, ten-by-ten, 100%);
|
||||
}
|
||||
|
||||
.adjusted-px-1 {
|
||||
background-position: sprite-position($squares, ten-by-ten, 4px);
|
||||
}
|
||||
|
||||
.adjusted-px-2 {
|
||||
background-position: sprite-position($squares, twenty-by-twenty, -3px, 2px);
|
||||
}
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite {
|
||||
background: url('/squares-8e490168dd.png') no-repeat;
|
||||
}
|
||||
|
||||
.adjusted-percentage {
|
||||
background-position: 100% 0;
|
||||
}
|
||||
|
||||
.adjusted-px-1 {
|
||||
background-position: -6px 0;
|
||||
}
|
||||
|
||||
.adjusted-px-2 {
|
||||
background-position: -3px -8px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-*.png'), '652b67f5e9092520d6f26caae7e18012'
|
||||
end
|
||||
|
||||
it "should use position adjustments in mixins" do
|
||||
css = render <<-SCSS
|
||||
$squares-position: 100%;
|
||||
@import "squares/*.png";
|
||||
|
||||
.adjusted-percentage {
|
||||
@include squares-sprite("ten-by-ten", $offset-x: 100%);
|
||||
}
|
||||
|
||||
.adjusted-px-1 {
|
||||
@include squares-sprite("ten-by-ten", $offset-x: 4px);
|
||||
}
|
||||
|
||||
.adjusted-px-2 {
|
||||
@include squares-sprite("twenty-by-twenty", $offset-x: -3px, $offset-y: 2px);
|
||||
}
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .adjusted-percentage, .adjusted-px-1, .adjusted-px-2 {
|
||||
background: url('/squares-8e490168dd.png') no-repeat;
|
||||
}
|
||||
|
||||
.adjusted-percentage {
|
||||
background-position: 100% 0;
|
||||
}
|
||||
|
||||
.adjusted-px-1 {
|
||||
background-position: -6px 0;
|
||||
}
|
||||
|
||||
.adjusted-px-2 {
|
||||
background-position: -3px -8px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-*.png'), '652b67f5e9092520d6f26caae7e18012'
|
||||
end
|
||||
|
||||
it "should repeat the image" do
|
||||
css = render <<-SCSS
|
||||
$squares-repeat: repeat;
|
||||
@import "squares/*.png";
|
||||
@include all-squares-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-a5550fd132.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.squares-twenty-by-twenty {
|
||||
background-position: 0 -10px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [20, 30]
|
||||
assert_equal image_md5('squares-*.png'), '94abae8440f1b58617f52920b70aaed2'
|
||||
end
|
||||
|
||||
it "should allow the position of a sprite to be specified in absolute pixels" do
|
||||
css = render <<-SCSS
|
||||
$squares-ten-by-ten-position: 10px;
|
||||
$squares-twenty-by-twenty-position: 10px;
|
||||
@import "squares/*.png";
|
||||
@include all-squares-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
||||
background: url('/squares-89a274044e.png') no-repeat;
|
||||
}
|
||||
|
||||
.squares-ten-by-ten {
|
||||
background-position: -10px 0;
|
||||
}
|
||||
|
||||
.squares-twenty-by-twenty {
|
||||
background-position: -10px -10px;
|
||||
}
|
||||
CSS
|
||||
assert_equal image_size('squares-*.png'), [30, 30]
|
||||
assert_equal image_md5('squares-*.png'), '2fb19ef9c83018c93c6f147af3a56cb2'
|
||||
end
|
||||
|
||||
it "should provide a nice errors for lemonade's old users" do
|
||||
assert_raise(Sass::SyntaxError) do
|
||||
render <<-SCSS
|
||||
.squares {
|
||||
background: sprite-url("squares/*.png") no-repeat;
|
||||
}
|
||||
SCSS
|
||||
end
|
||||
assert_raise(Sass::SyntaxError) do
|
||||
css = render <<-SCSS
|
||||
.squares {
|
||||
background: sprite-image("squares/twenty-by-twenty.png") no-repeat;
|
||||
}
|
||||
SCSS
|
||||
end
|
||||
assert_raise(Sass::SyntaxError) do
|
||||
css = render <<-SCSS
|
||||
@import "squares/*.png";
|
||||
|
||||
.squares {
|
||||
background: sprite-position("squares/twenty-by-twenty.png") no-repeat;
|
||||
}
|
||||
SCSS
|
||||
end
|
||||
end
|
||||
|
||||
it "should work even if @import is missing" do
|
||||
css = render <<-SCSS
|
||||
.squares {
|
||||
background: sprite(sprite-map("squares/*.png"), twenty-by-twenty) no-repeat;
|
||||
}
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.squares {
|
||||
background: url('/squares-145869726f.png') 0 -10px no-repeat;
|
||||
}
|
||||
CSS
|
||||
end
|
||||
|
||||
it "should calculate corret sprite demsions when givin spacing via issue#253" do
|
||||
css = render <<-SCSS
|
||||
$squares-spacing: 10px;
|
||||
@import "squares/*.png";
|
||||
.foo {
|
||||
@include sprite-background-position($squares-sprites, "twenty-by-twenty");
|
||||
}
|
||||
.bar {
|
||||
@include sprite-background-position($squares-sprites, "ten-by-ten");
|
||||
}
|
||||
SCSS
|
||||
assert_equal image_size('squares-*.png'), [20, 40]
|
||||
assert_correct css, <<-CSS
|
||||
.squares-sprite {
|
||||
background: url('/squares-e3c68372d9.png') no-repeat;
|
||||
}
|
||||
|
||||
.foo {
|
||||
background-position: 0 -20px;
|
||||
}
|
||||
|
||||
.bar {
|
||||
background-position: 0 0;
|
||||
}
|
||||
CSS
|
||||
end
|
||||
|
||||
it "should render corret sprite with css selectors via issue#248" do
|
||||
css = render <<-SCSS
|
||||
@import "selectors/*.png";
|
||||
@include all-selectors-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.selectors-sprite, .selectors-ten-by-ten {
|
||||
background: url('/selectors-edfef809e2.png') no-repeat;
|
||||
}
|
||||
|
||||
.selectors-ten-by-ten {
|
||||
background-position: 0 0;
|
||||
}
|
||||
.selectors-ten-by-ten:hover, .selectors-ten-by-ten.ten-by-ten_hover, .selectors-ten-by-ten.ten-by-ten-hover {
|
||||
background-position: 0 -20px;
|
||||
}
|
||||
.selectors-ten-by-ten:target, .selectors-ten-by-ten.ten-by-ten_target, .selectors-ten-by-ten.ten-by-ten-target {
|
||||
background-position: 0 -30px;
|
||||
}
|
||||
.selectors-ten-by-ten:active, .selectors-ten-by-ten.ten-by-ten_active, .selectors-ten-by-ten.ten-by-ten-active {
|
||||
background-position: 0 -10px;
|
||||
}
|
||||
CSS
|
||||
end
|
||||
|
||||
it "should render corret sprite with css selectors via magic mixin" do
|
||||
css = render <<-SCSS
|
||||
@import "selectors/*.png";
|
||||
a {
|
||||
@include selectors-sprite(ten-by-ten)
|
||||
}
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.selectors-sprite, a {
|
||||
background: url('/selectors-edfef809e2.png') no-repeat;
|
||||
}
|
||||
|
||||
a {
|
||||
background-position: 0 0;
|
||||
}
|
||||
a:hover, a.ten-by-ten_hover, a.ten-by-ten-hover {
|
||||
background-position: 0 -20px;
|
||||
}
|
||||
a:target, a.ten-by-ten_target, a.ten-by-ten-target {
|
||||
background-position: 0 -30px;
|
||||
}
|
||||
a:active, a.ten-by-ten_active, a.ten-by-ten-active {
|
||||
background-position: 0 -10px;
|
||||
}
|
||||
CSS
|
||||
end
|
||||
|
||||
it "should not render corret sprite with css selectors via magic mixin" do
|
||||
css = render <<-SCSS
|
||||
@import "selectors/*.png";
|
||||
a {
|
||||
$disable-magic-sprite-selectors:true;
|
||||
@include selectors-sprite(ten-by-ten)
|
||||
}
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.selectors-sprite, a {
|
||||
background: url('/selectors-edfef809e2.png') no-repeat;
|
||||
}
|
||||
|
||||
a {
|
||||
background-position: 0 0;
|
||||
}
|
||||
CSS
|
||||
end
|
||||
|
||||
it "should raise error on filenames that are not valid sass syntax" do
|
||||
assert_raise(Compass::Error) do
|
||||
css = render <<-SCSS
|
||||
@import "prefix/*.png";
|
||||
a {
|
||||
@include squares-sprite(20-by-20);
|
||||
}
|
||||
SCSS
|
||||
end
|
||||
end
|
||||
|
||||
it "should generate sprite with bad repeat-x dimensions" do
|
||||
css = render <<-SCSS
|
||||
$ko-starbg26x27-repeat: repeat-x;
|
||||
@import "ko/*.png";
|
||||
@include all-ko-sprites;
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.ko-sprite, .ko-default_background, .ko-starbg26x27 {
|
||||
background: url('/ko-cc3f80660d.png') no-repeat;
|
||||
}
|
||||
|
||||
.ko-default_background {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.ko-starbg26x27 {
|
||||
background-position: 0 -128px;
|
||||
}
|
||||
CSS
|
||||
end
|
||||
|
||||
end
|
@ -1,13 +0,0 @@
|
||||
module Compass
|
||||
module TestCaseHelper
|
||||
def absolutize(path)
|
||||
if Compass::Util.blank?(path)
|
||||
File.dirname(__FILE__)
|
||||
elsif path[0] == ?/
|
||||
"#{File.dirname(__FILE__)}#{path}"
|
||||
else
|
||||
"#{File.dirname(__FILE__)}/#{path}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -22,7 +22,16 @@ require 'compass'
|
||||
|
||||
require 'test/unit'
|
||||
|
||||
require 'test_case_helper'
|
||||
require 'io_helper'
|
||||
require 'rails_helper'
|
||||
require 'command_line_helper'
|
||||
|
||||
%w(command_line diff io rails test_case).each do |helper|
|
||||
require "helpers/#{helper}"
|
||||
end
|
||||
|
||||
|
||||
class Test::Unit::TestCase
|
||||
include Compass::Diff
|
||||
include Compass::TestCaseHelper
|
||||
include Compass::IoHelper
|
||||
extend Compass::TestCaseHelper::ClassMethods
|
||||
|
||||
end
|