2010-09-12 17:45:45 +00:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
|
|
|
2010-09-12 21:58:07 +00:00
|
|
|
describe Compass::Sprites do
|
2010-09-12 17:45:45 +00:00
|
|
|
|
|
|
|
before :each do
|
|
|
|
@sprite = {
|
|
|
|
:info => 'info',
|
|
|
|
:images => [
|
|
|
|
{ :file => 'file1' },
|
|
|
|
{ :file => 'file2' },
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
@file = ""
|
|
|
|
File.stub!(:read => @file)
|
2010-09-12 21:58:07 +00:00
|
|
|
Compass::Sprites.stub(:images_path).and_return('image_path')
|
2010-09-12 17:45:45 +00:00
|
|
|
File.stub!(:ctime => Time.parse('2010-01-01 12:00'))
|
|
|
|
end
|
|
|
|
|
|
|
|
###
|
|
|
|
|
|
|
|
describe '#remember_sprite_info' do
|
2010-09-12 23:11:29 +00:00
|
|
|
|
2010-09-12 21:58:07 +00:00
|
|
|
subject { Compass::Sprites }
|
2010-09-12 17:45:45 +00:00
|
|
|
|
2010-09-12 23:11:29 +00:00
|
|
|
before :each do
|
|
|
|
@options = {
|
|
|
|
:cache_store => Sass::InMemoryCacheStore.new
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should save sprite info to the sass cache' do
|
|
|
|
subject.remember_sprite_info!('the_sprite', @sprite, @options)
|
|
|
|
@options[:cache_store].retrieve('_the_sprite_data', "")[:sprite].should == @sprite
|
2010-09-12 17:45:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
###
|
|
|
|
|
|
|
|
describe '#sprite_changed?' do
|
2010-09-12 23:11:29 +00:00
|
|
|
|
2010-09-12 21:58:07 +00:00
|
|
|
subject { Compass::Sprites }
|
2010-09-12 17:45:45 +00:00
|
|
|
|
2010-09-12 23:11:29 +00:00
|
|
|
before :each do
|
|
|
|
@options = {
|
|
|
|
:cache_store => Sass::InMemoryCacheStore.new
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2010-09-12 17:45:45 +00:00
|
|
|
it 'should be false if nothing changed' do
|
2010-09-12 23:11:29 +00:00
|
|
|
subject.remember_sprite_info!('the sprite', @sprite, @options)
|
|
|
|
subject.sprite_changed?('the sprite', @sprite, @options).should be_false
|
2010-09-12 17:45:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should be true if the sprite info has changed' do
|
2010-09-12 23:11:29 +00:00
|
|
|
subject.remember_sprite_info!('the sprite', @sprite, @options)
|
2010-09-12 17:45:45 +00:00
|
|
|
@sprite[:info] = 'changed info'
|
2010-09-12 23:11:29 +00:00
|
|
|
subject.sprite_changed?('the sprite', @sprite, @options).should be_true
|
2010-09-12 17:45:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should be true if the images changed' do
|
2010-09-12 23:11:29 +00:00
|
|
|
subject.remember_sprite_info!('the sprite', @sprite, @options)
|
2010-09-12 17:45:45 +00:00
|
|
|
@sprite[:images] = []
|
2010-09-12 23:11:29 +00:00
|
|
|
subject.sprite_changed?('the sprite', @sprite, @options).should be_true
|
2010-09-12 17:45:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should be true if a images timestamp changed' do
|
2010-09-12 23:11:29 +00:00
|
|
|
subject.remember_sprite_info!('the sprite', @sprite, @options)
|
2010-09-12 17:45:45 +00:00
|
|
|
File.stub!(:ctime => Time.now)
|
2010-09-12 23:11:29 +00:00
|
|
|
subject.sprite_changed?('the sprite', @sprite, @options).should be_true
|
2010-09-12 17:45:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|