Sha256: 6e8fe9f28800baff2ee9735ef915078d9e02db5b6817c5518f4829c1449a3edf

Contents?: true

Size: 939 Bytes

Versions: 1

Compression:

Stored size: 939 Bytes

Contents

require 'test_helper'


class TemplatesTest < MiniTest::Spec
  Templates = Cell::Templates

  let (:base) { ["test/vm/fixtures"] }

  # existing.
  it { Templates.new[base, ["bassist"], "play", "haml"].file.must_equal "test/vm/fixtures/bassist/play.haml" }

  # not existing.
  it { Templates.new[base, ["bassist"], "not-here", "haml"].must_equal nil }


  # different caches for different classes

  # same cache for subclasses

end


class TemplatesCachingTest < MiniTest::Spec
  class SongCell < Cell::ViewModel
    self.view_paths = ["test/vm/fixtures"]

    def show
      render
    end
  end

  # templates are cached once and forever.
  it do
    cell = cell("templates_caching_test/song")

    cell.call(:show).must_equal "The Great Mind Eraser\n"

    SongCell.templates.instance_eval do
      def create; raise; end
    end

    # cached, NO new tilt template.
    cell.call(:show).must_equal "The Great Mind Eraser\n"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cells-jamie-4.0.0.alpha1 test/vm/templates_test.rb