2006-11-28 20:33:22 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
require 'test/unit'
|
2006-12-03 23:56:47 +00:00
|
|
|
require File.dirname(__FILE__) + '/../../lib/sass'
|
2006-12-04 02:47:37 +00:00
|
|
|
|
|
|
|
RAILS_ROOT = ''
|
|
|
|
RAILS_ENV = 'testing'
|
|
|
|
|
|
|
|
require 'sass/plugin'
|
2006-11-28 20:33:22 +00:00
|
|
|
|
|
|
|
class SassPluginTest < Test::Unit::TestCase
|
2006-12-22 01:52:45 +00:00
|
|
|
@@templates = %w{ complex constants }
|
2006-12-04 02:47:37 +00:00
|
|
|
|
2006-11-28 20:33:22 +00:00
|
|
|
def setup
|
2006-12-04 02:47:37 +00:00
|
|
|
Sass::Plugin.options[:template_location] = File.dirname(__FILE__) + '/templates'
|
|
|
|
Sass::Plugin.options[:css_location] = File.dirname(__FILE__) + '/tmp'
|
|
|
|
Sass::Plugin.options = {:always_update => true}
|
|
|
|
|
|
|
|
Sass::Plugin.update_stylesheets
|
2006-11-28 20:33:22 +00:00
|
|
|
end
|
2006-12-03 23:17:45 +00:00
|
|
|
|
|
|
|
def teardown
|
2006-12-04 02:47:37 +00:00
|
|
|
File.delete(*Dir[tempfile_loc('*')])
|
2006-12-03 23:17:45 +00:00
|
|
|
end
|
2006-11-28 20:39:33 +00:00
|
|
|
|
2006-12-04 02:47:37 +00:00
|
|
|
def test_templates_should_render_correctly
|
|
|
|
@@templates.each { |name| assert_renders_correctly(name) }
|
2006-11-28 20:39:33 +00:00
|
|
|
end
|
2006-12-04 02:47:37 +00:00
|
|
|
|
2006-11-28 20:39:33 +00:00
|
|
|
def test_no_update
|
2006-12-04 02:47:37 +00:00
|
|
|
File.delete(tempfile_loc('basic'))
|
|
|
|
assert Sass::Plugin.stylesheet_needs_update?('basic')
|
|
|
|
Sass::Plugin.update_stylesheets
|
|
|
|
assert !Sass::Plugin.stylesheet_needs_update?('basic')
|
|
|
|
end
|
|
|
|
|
|
|
|
def assert(*args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_controller_process
|
|
|
|
File.delete(tempfile_loc('basic'))
|
|
|
|
assert Sass::Plugin.stylesheet_needs_update?('basic')
|
|
|
|
|
|
|
|
ActionController::Base.new.process
|
|
|
|
|
|
|
|
assert !Sass::Plugin.stylesheet_needs_update?('basic')
|
2006-11-28 20:39:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2006-12-03 23:17:45 +00:00
|
|
|
|
|
|
|
def assert_renders_correctly(name)
|
2006-12-04 03:55:34 +00:00
|
|
|
File.read(result_loc(name)).split("\n").zip(File.read(tempfile_loc(name)).split("\n")).each_with_index do |pair, line|
|
2006-12-22 05:09:00 +00:00
|
|
|
message = "template: #{name}\nline: #{line + 1}"
|
2006-12-03 23:17:45 +00:00
|
|
|
assert_equal(pair.first, pair.last, message)
|
|
|
|
end
|
|
|
|
end
|
2006-11-28 20:33:22 +00:00
|
|
|
|
2006-12-04 02:47:37 +00:00
|
|
|
def tempfile_loc(name)
|
|
|
|
File.dirname(__FILE__) + "/tmp/#{name}.css"
|
2006-11-28 20:39:33 +00:00
|
|
|
end
|
2006-12-03 23:17:45 +00:00
|
|
|
|
2006-12-04 02:47:37 +00:00
|
|
|
def result_loc(name)
|
|
|
|
File.dirname(__FILE__) + "/results/#{name}.css"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Sass::Plugin
|
|
|
|
class << self
|
|
|
|
public :stylesheet_needs_update?
|
2006-11-28 20:33:22 +00:00
|
|
|
end
|
|
|
|
end
|
2006-12-04 02:47:37 +00:00
|
|
|
|
|
|
|
class ActionController::Base
|
|
|
|
def sass_old_process(*args); end
|
|
|
|
end
|