compass/test/helpers/test_case.rb

56 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2011-04-28 03:18:52 +00:00
module Compass
module TestCaseHelper
def absolutize(path)
if Compass::Util.blank?(path)
File.expand_path('../../', __FILE__)
elsif path[0] == ?/
File.join(File.expand_path('../', __FILE__), path)
else
File.join(File.expand_path('../../', __FILE__), path)
end
end
2011-04-28 04:00:54 +00:00
def assert_correct(before, after)
if before == after
assert(true)
else
assert false, diff_as_string(before.inspect, after.inspect)
end
end
2011-04-28 03:18:52 +00:00
module ClassMethods
2011-04-28 06:50:14 +00:00
def let(method, &block)
define_method method, &block
end
2011-04-28 03:18:52 +00:00
def it(name, &block)
test(name, &block)
end
def test(name, &block)
define_method "test_#{underscore(name)}".to_sym, &block
end
def setup(&block)
define_method :setup do
yield
end
end
def after(&block)
define_method :teardown do
yield
end
end
private
def underscore(string)
string.gsub(' ', '_')
end
end
end
end