From f78744171d3986022ec3145ed79dd3bd0a671ed2 Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Wed, 23 Mar 2011 01:09:41 -0400 Subject: [PATCH] sprite base spec selector methods --- Gemfile.lock | 2 +- lib/compass/sass_extensions/sprites/image.rb | 24 +++++++++++++++++++ .../sass_extensions/sprites/base_spec.rb | 5 ++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 88e6d492..630b7668 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,7 @@ GIT PATH remote: . specs: - compass (0.11.beta.3.a5e2795) + compass (0.11.beta.3.03b0ee2) chunky_png (~> 1.1.0) sass (>= 3.1.0.alpha.249) diff --git a/lib/compass/sass_extensions/sprites/image.rb b/lib/compass/sass_extensions/sprites/image.rb index 11fc5c7e..4ed352be 100644 --- a/lib/compass/sass_extensions/sprites/image.rb +++ b/lib/compass/sass_extensions/sprites/image.rb @@ -54,6 +54,30 @@ module Compass def mtime File.mtime(file) end + + def hover? + base.has_hover?(name) + end + + def hover + base.image_for("#{name}_hover") + end + + def target? + base.has_target?(name) + end + + def target + base.image_for("#{name}_target") + end + + def active? + base.has_active?(name) + end + + def active + base.image_for("#{name}_active") + end private def dimensions diff --git a/spec/compass/sass_extensions/sprites/base_spec.rb b/spec/compass/sass_extensions/sprites/base_spec.rb index 41344885..6a086737 100644 --- a/spec/compass/sass_extensions/sprites/base_spec.rb +++ b/spec/compass/sass_extensions/sprites/base_spec.rb @@ -38,6 +38,11 @@ describe Compass::SassExtensions::Sprites::Base do it "should have a #{selector}" do subject.send(:"has_#{selector}?", 'ten-by-ten').should be_true end + + it "should return #{selector} image class" do + subject.image_for('ten-by-ten').send(:"#{selector}").name.should == "ten-by-ten_#{selector}" + end + end context "#generate" do before { @base.generate }