File tree Expand file tree Collapse file tree 2 files changed +36
-34
lines changed Expand file tree Collapse file tree 2 files changed +36
-34
lines changed Original file line number Diff line number Diff line change
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
+
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments