require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") require 'markaby/tilt' require 'erb' module Markaby describe Tilt, "templates" do before do @block = lambda do |t| File.read(File.dirname(__FILE__) + "/#{t.file}") end end it "should have the constant ::Tilt::Markaby after registration" do lambda { ::Tilt::MarkabyTemplate }.should_not raise_error end it "should be able to render an erb template" do tilt = ::Tilt::ERBTemplate.new("tilt/erb.erb", &@block) tilt.render.should == "hello from erb!" end it "should be able to render a markaby template with static html" do tilt = ::Tilt::MarkabyTemplate.new("tilt/markaby.mab", &@block) tilt.render.should == "hello from markaby!" end it "should use the contents of the template" do tilt = ::Tilt::MarkabyTemplate.new("tilt/markaby_other_static.mab", &@block) tilt.render.should == "_why?" end it "should render from a string (given as data)" do tilt = ::Tilt::MarkabyTemplate.new { "html do; end" } tilt.render.should == "" end it "should evaluate a block in the scope given" do pending do scope = mock 'scope object', :foo => "bar" tilt = ::Tilt::MarkabyTemplate.new { li foo } tilt.render(scope).should == "