require 'spec_helper' require 'tilt' require 'pakunok/haml_js_template' describe 'HAML-JS processor' do def template haml, file = "file.js.hamljs" Pakunok::HamlJsTemplate.new(file) { haml } end def render haml, file = "file.js.hamljs" template(haml, file).render end it 'should have default mime type' do Pakunok::HamlJsTemplate.default_mime_type.should == 'application/javascript' end describe 'rendering' do subject { render "#main= 'quotes'\n #inner= name", 'myTemplate.js.hamljs' } it { should include "function (locals) {" } it { should include 'function html_escape' } it 'should make template available for JavaScript' do context = ExecJS.compile(subject) html = context.eval("JST.myTemplate({name: 'dima'})") html.should include '