Sha256: a1f6ed561684fd10a504cc3e745aa90d61c13c997d7c3d2df413396e80c3889a

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe Sprockets::Mustache::Template::Generator do

  let :generator do

    namespace = "my.Namespace"
    library = "Zepto"
    logical_path = "javascripts/backbone/templates/mustache/entryList"
    template_string = <<-HTML
<table class="ledger">
  <thead>
    <tr>
      <th class="date">Date</td>
      <th class="name">Name</td>
      <th class="category">Category</td>
      <th class="amount">Amount ($)</td>
    </tr>
  </thead>
  {{{rows}}}
</table>
    HTML

    Sprockets::Mustache::Template::Generator.new(namespace, logical_path, template_string, library)
  end

  it "calculates the template name" do
    generator.template_name.should == "javascripts/backbone/templates/mustache/entryList"
  end

  describe "#generate" do
    before do
      @js = generator.generate
    end

    it "makes the named JS function as a string" do
      @js.should be_present
    end

    it "assigns the correct namespace" do
      @js.should match(/my\.Namespace\.mustache\['javascripts\/backbone\/templates\/mustache\/entryList'\] = \{/)
    end

    it "assigns the correct library" do
      @js.should match(/}\(Zepto\)/)
    end

    it "puts the template in the mustache object" do
      @js.should match(/<table class="ledger">/)
    end

    it "has a render function that calls Mustache.to_html" do
      @js.should match(/Mustache\.to_html/)
    end

    it "passes partials to to_html" do
      @js.should match(/to_html.+, partials/)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sprockets_spacely-0.1.0 spec/lib/template_generator_spec.rb