Skip to content

Commit 7549f18

Browse files
committed
converted test suite to rspec
1 parent 48e1776 commit 7549f18

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

test/mustache_spec.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require 'rubygems'
2+
require 'json'
3+
4+
__DIR__ = File.dirname(__FILE__)
5+
6+
testnames = Dir.glob(__DIR__ + '/../examples/*.js').map do |name|
7+
File.basename name, '.js'
8+
end
9+
10+
describe "mustache" do
11+
testnames.each do |testname|
12+
13+
describe testname do
14+
it "should generate the correct html" do
15+
view = File.read(__DIR__ + "/../examples/#{testname}.js")
16+
template = File.read(__DIR__ + "/../examples/#{testname}.html").to_json
17+
expect = File.read(__DIR__ + "/../examples/#{testname}.txt")
18+
19+
mustache = File.read(__DIR__ + "/../mustache.js")
20+
runner = <<-JS
21+
#{mustache}
22+
#{view}
23+
var template = #{template};
24+
var result = Mustache.to_html(template, #{testname});
25+
print(result);
26+
JS
27+
28+
File.open("runner.js", 'w') {|f| f << runner}
29+
30+
result = `js runner.js`
31+
result.should == expect
32+
end
33+
end
34+
end
35+
end
36+

test/mustache_test.rb

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)