Class: Compass::TestCase
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- Compass::TestCase
- Defined in:
- lib/compass/test_case.rb
Overview
Write your unit test like this if you want to make sure all your stylesheets compile.
require ‘compass/test_case’ class StylesheetsTest < Compass::TestCase
def test_stylesheets
my_sass_files.each do |sass_file|
assert_compiles(sass_file) do |result|
assert_not_blank result
end
end
end
protected
def my_sass_files
Dir.glob(File.(File.join(File.dirname(__FILE__), "../..", "app/stylesheets/**/[^_]*.sass")))
end
end
Instance Method Summary collapse
- #assert_compiles(stylesheet, &block) ⇒ Object
- #compile(stylesheet) {|@last_compile| ... } ⇒ Object
- #setup ⇒ Object
Instance Method Details
#assert_compiles(stylesheet, &block) ⇒ Object
32 33 34 |
# File 'lib/compass/test_case.rb', line 32 def assert_compiles(stylesheet, &block) compile(stylesheet, &block) end |
#compile(stylesheet) {|@last_compile| ... } ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/compass/test_case.rb', line 23 def compile(stylesheet) input = open(stylesheet) template = input.read() input.close() @last_compile = ::Sass::Engine.new(template, ::Sass::Plugin.(:style => :compact, :filename => stylesheet)).render yield @last_compile if block_given? end |
#setup ⇒ Object
19 20 21 |
# File 'lib/compass/test_case.rb', line 19 def setup @last_compile = nil end |