Sha256: 9067fab9bb0391c8f9b1dbd961e9dab6ab01828a1e58d6c777f2ec6ed651aa4d

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

class MyViewContext
  include ActionView::Helpers::TagHelper
  include Stache::AssetHelper
end

describe Stache::AssetHelper do
  def helper
    @helper ||= MyViewContext.new
  end
  
  describe "template_include_tag" do
    it "renders a script tag with the template contents" do
      File.stub!(:open).with(Rails.root.join("app/views/widgets/_oh_herro.html.mustache"), "rb").
        and_return(StringIO.new("{{ awyeah }}"))

      helper.template_include_tag("widgets/oh_herro").should == "<script id=\"oh_herro_template\" type=\"text/html\">{{ awyeah }}</script>"
    end
    it "uses the template_base_path config setting to locate the template" do
      Stache.configure do |c|
        c.template_base_path = "/tmp/whee"
      end
      File.stub!(:open).with(Pathname.new("/tmp/whee/_whooo.html.mustache"), "rb").
        and_return(StringIO.new("{{ awyeah }}"))
        
      helper.template_include_tag("whooo").should == "<script id=\"whooo_template\" type=\"text/html\">{{ awyeah }}</script>"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stache-0.0.3 spec/stache/asset_helper_spec.rb