test/units/sprites/image_test.rb in compass-0.12.alpha.2 vs test/units/sprites/image_test.rb in compass-0.12.alpha.3
- old
+ new
@@ -2,14 +2,19 @@
require 'mocha'
require 'ostruct'
class SpritesImageTest < Test::Unit::TestCase
include SpriteHelper
+
def setup
create_sprite_temp
end
+ def teardown
+ clean_up_sprites
+ end
+
SPRITE_FILENAME = 'selectors/ten-by-ten.png'
def sprite_path
File.join(@images_tmp_path, SPRITE_FILENAME)
end
@@ -49,19 +54,28 @@
test 'no parent' do
assert_nil test_image.parent
end
- test 'image type is "global"' do
- image = test_image "selectors_ten_by_ten_repeat" => Sass::Script::String.new('global')
- assert_equal 'global', image.repeat
+ test 'image type is "global" should raise exception' do
+ assert_raise ::Compass::SpriteException do
+ image = test_image "selectors_ten_by_ten_repeat" => Sass::Script::String.new('global')
+ image.repeat
+ end
end
test 'image type is "no-repeat"' do
- assert_equal 'no-repeat', test_image.repeat
+ img = test_image
+ assert_equal 'no-repeat', img.repeat
+ assert img.no_repeat?
end
+ test 'image repeat-x' do
+ img = test_image "selectors_ten_by_ten_repeat" => Sass::Script::String.new('repeat-x')
+ assert img.repeat_x?
+ end
+
test 'image position' do
image = test_image "selectors_ten_by_ten_position" => Sass::Script::Number.new(100, ["px"])
assert_equal 100, image.position.value
end
@@ -78,28 +92,8 @@
test 'neither, uses 0' do
img = test_image
img.position.stubs(:unitless?).returns(false)
assert_equal 0, img.offset
- end
-
-
- test 'gets name for sprite in search path' do
- Compass.reset_configuration!
- uri = 'foo/*.png'
- other_folder = File.join(@images_tmp_path, '../other-temp')
- FileUtils.mkdir_p other_folder
- FileUtils.mkdir_p File.join(other_folder, 'foo')
- %w(my bar).each do |file|
- FileUtils.touch(File.join(other_folder, "foo/#{file}.png"))
- end
- config = Compass::Configuration::Data.new('config')
- config.images_path = @images_tmp_path
- config.sprite_load_path = [@images_tmp_path, other_folder]
- Compass.add_configuration(config, "sprite_config")
- image = Compass::SassExtensions::Sprites::Image.new(test_map, "foo/my.png", {})
- assert_equal File.join(other_folder, 'foo/my.png'), image.file
- assert_equal 0, image.size
- FileUtils.rm_rf other_folder
end
end