2016-02-15 16:50:18 +00:00
|
|
|
require "../spec_helper"
|
|
|
|
require "../../src/kilt/crustache"
|
2016-02-15 04:18:42 +00:00
|
|
|
|
|
|
|
class MustacheView
|
|
|
|
def has_key?(name)
|
|
|
|
name == "pid"
|
|
|
|
end
|
|
|
|
|
|
|
|
def [](name)
|
|
|
|
name == "pid" ? Process.pid : nil
|
|
|
|
end
|
|
|
|
|
|
|
|
Kilt.file "spec/fixtures/test.mustache", "__kilt_io__", self
|
|
|
|
end
|
|
|
|
|
2016-02-15 16:50:18 +00:00
|
|
|
describe "kilt/crustache" do
|
2016-02-15 04:18:42 +00:00
|
|
|
|
2016-02-15 16:50:18 +00:00
|
|
|
it "renders crustache" do
|
2016-02-15 04:18:42 +00:00
|
|
|
Kilt.render("spec/fixtures/test.mustache", { "pid" => Process.pid }).should eq("<span>#{Process.pid}</span>")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "works with classes" do
|
|
|
|
MustacheView.new.to_s.should eq("<span>#{Process.pid}</span>")
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|