sprite base spec
This commit is contained in:
parent
a5e27952f8
commit
03b0ee2660
@ -7,7 +7,7 @@ GIT
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
compass (0.11.beta.3.6e1daf6)
|
||||
compass (0.11.beta.3.a5e2795)
|
||||
chunky_png (~> 1.1.0)
|
||||
sass (>= 3.1.0.alpha.249)
|
||||
|
||||
|
@ -143,7 +143,10 @@ module Compass
|
||||
|
||||
# Checks whether this sprite is outdated
|
||||
def outdated?
|
||||
@images.map(&:mtime).any? { |mtime| mtime > self.mtime }
|
||||
if File.exists?(filename)
|
||||
return @images.map(&:mtime).any? { |mtime| mtime > self.mtime }
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
def mtime
|
||||
|
@ -3,27 +3,50 @@ describe Compass::SassExtensions::Sprites::Base do
|
||||
|
||||
before :each do
|
||||
@images_src_path = File.join(File.dirname(__FILE__), '..', '..', '..', 'test_project', 'public', 'images')
|
||||
@images_tmp_path = File.join(File.dirname(__FILE__), '..', '..', '..', 'test_project', 'public', 'selectors-images-tmp')
|
||||
#FileUtils.mkdir_p @images_src_path
|
||||
#FileUtils.mkdir_p @images_tmp_path
|
||||
@images_tmp_path = File.join(File.dirname(__FILE__), '..', '..', '..', 'test_project', '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")
|
||||
config = Compass::Configuration::Data.new('config')
|
||||
config.images_path = @images_tmp_path
|
||||
Compass.add_configuration(config)
|
||||
Compass.configure_sass_plugin!
|
||||
rels = Dir["#{@images_src_path}/selectors/*.png"].sort.map { |f| f.split('/')[-2..-1].join('/') }
|
||||
Compass::SassExtensions::Sprites::Base.new(rels, @images_src_path, 'selectors', self, options)
|
||||
#fix this eww
|
||||
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.path, 'selectors', @map.sass_engine, @map.options)
|
||||
end
|
||||
|
||||
after :each do
|
||||
FileUtils.rm_r @images_tmp_path
|
||||
end
|
||||
|
||||
it "should" do
|
||||
"foo"
|
||||
subject { @base }
|
||||
|
||||
its(:size) { should == [10,40] }
|
||||
its(:sprite_names) { should == @map.sprite_names }
|
||||
its(:image_filenames) { should == Dir["#{@images_tmp_path}/selectors/*.png"].sort }
|
||||
its(:generation_required?) { should be_true }
|
||||
its(:uniqueness_hash) { should == 'ef52c5c63a'}
|
||||
its(:outdated?) { should be_true }
|
||||
its(:filename) { should == File.join(@images_tmp_path, "#{@base.path}-#{@base.uniqueness_hash}.png")}
|
||||
|
||||
it "should return the 'ten-by-ten' image" do
|
||||
subject.image_for('ten-by-ten').name.should == 'ten-by-ten'
|
||||
subject.image_for('ten-by-ten').should be_a Compass::SassExtensions::Sprites::Image
|
||||
end
|
||||
|
||||
%w(target hover active).each do |selector|
|
||||
it "should have a #{selector}" do
|
||||
subject.send(:"has_#{selector}?", 'ten-by-ten').should be_true
|
||||
end
|
||||
end
|
||||
context "#generate" do
|
||||
before { @base.generate }
|
||||
it "should generate sprite" do
|
||||
File.exists?(@base.filename).should be_true
|
||||
end
|
||||
|
||||
|
||||
|
||||
its(:generation_required?) { should be_false }
|
||||
its(:outdated?) { should be_false }
|
||||
end
|
||||
|
||||
end
|
@ -7,7 +7,6 @@ describe Compass::SassExtensions::Sprites::Image do
|
||||
let(:sprite_name) { File.basename(sprite_filename, '.png') }
|
||||
let(:image) { self.class.describes.new(nil, File.join(sprite_filename), options)}
|
||||
let(:digest) { Digest::MD5.file(sprite_path).hexdigest }
|
||||
|
||||
subject { image }
|
||||
|
||||
before {
|
||||
@ -37,6 +36,7 @@ describe Compass::SassExtensions::Sprites::Image do
|
||||
}
|
||||
|
||||
describe '#repeat' do
|
||||
let(:type) { nil }
|
||||
let(:get_var_return) { OpenStruct.new(:value => type) }
|
||||
|
||||
context 'specific image' do
|
||||
@ -61,6 +61,7 @@ describe Compass::SassExtensions::Sprites::Image do
|
||||
end
|
||||
|
||||
describe '#position' do
|
||||
let(:type) { nil }
|
||||
let(:get_var_return) { type }
|
||||
|
||||
context 'specific image' do
|
||||
@ -85,6 +86,7 @@ describe Compass::SassExtensions::Sprites::Image do
|
||||
end
|
||||
|
||||
describe '#spacing' do
|
||||
let(:type) { nil }
|
||||
let(:get_var_return) { OpenStruct.new(:value => type) }
|
||||
|
||||
context 'specific image' do
|
||||
|
@ -45,6 +45,8 @@ describe Compass::SpriteMap do
|
||||
|
||||
its(:mtime) { should == mtime }
|
||||
|
||||
it "should have a test for the sass engine"
|
||||
it "should have a test for the sass engine" do
|
||||
pending 'sass'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user