mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Use updated test from haml-spec, no need for separate test now
This commit is contained in:
parent
9e9d537c6d
commit
c7f1321d6c
3 changed files with 2 additions and 45 deletions
2
Rakefile
2
Rakefile
|
@ -13,7 +13,7 @@ end
|
|||
|
||||
Rake::TestTask.new do |t|
|
||||
t.libs << 'lib'
|
||||
t.test_files = Dir["test/**/*_test.rb"].reject {|x| x =~ /haml-spec/}
|
||||
t.test_files = Dir["test/**/*_test.rb"]
|
||||
t.verbose = true
|
||||
end
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|||
'extra/**/*', 'Rakefile', 'init.rb', '.yardopts'] + readmes
|
||||
spec.homepage = 'http://haml-lang.com/'
|
||||
spec.has_rdoc = false
|
||||
spec.test_files = Dir["test/**/*_test.rb"].reject {|x| x =~ /haml-spec/}
|
||||
spec.test_files = Dir["test/**/*_test.rb"]
|
||||
|
||||
spec.add_development_dependency 'yard', '>= 0.5.3'
|
||||
spec.add_development_dependency 'maruku', '>= 0.5.9'
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/test_helper'
|
||||
|
||||
begin
|
||||
require 'json'
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
class SpecTest < Test::Unit::TestCase
|
||||
spec_file = File.dirname(__FILE__) + '/haml-spec/tests.json'
|
||||
if !File.exists?(spec_file)
|
||||
error = <<MSG.rstrip
|
||||
Couldn't load haml-spec, skipping some tests.
|
||||
To use haml-spec, run `git submodule update --init`
|
||||
MSG
|
||||
elsif !defined?(JSON)
|
||||
error = "Couldn't load json, skipping some tests."
|
||||
end
|
||||
|
||||
if error
|
||||
define_method(:test_fake_couldnt_load_spec) {warn("\n" + error)}
|
||||
else
|
||||
JSON.parse(File.read(spec_file)).each do |name, tests|
|
||||
tests.each do |subname, test|
|
||||
define_method("test_spec: #{name} (#{subname})") do
|
||||
options = convert_hash(test["config"])
|
||||
options[:format] = options[:format].to_sym if options[:format]
|
||||
engine = Haml::Engine.new(test["haml"], options)
|
||||
|
||||
result = engine.render(Object.new, convert_hash(test["locals"]))
|
||||
|
||||
assert_equal(test["html"], result.rstrip)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def convert_hash(hash)
|
||||
return {} unless hash
|
||||
Haml::Util.map_keys(hash) {|k| k.to_sym}
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue