Sha256: 3fe7311dfebd25f2b9e2a3fab1ac8b983f3f6c96220c246e93bcd106628d171a

Contents?: true

Size: 961 Bytes

Versions: 1

Compression:

Stored size: 961 Bytes

Contents

require 'test_helper'


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

  # existing.
  it { Templates.new[['test/fixtures/bassist'], 'play.erb', {template_class: Cell::Erb::Template}].file.must_equal 'test/fixtures/bassist/play.erb' }

  # not existing.
  it { assert_nil(Templates.new[['test/fixtures/bassist'], 'not-here.erb', {}]) }


  # different caches for different classes

  # same cache for subclasses

end


class TemplatesCachingTest < MiniTest::Spec
  class SongCell < Cell::ViewModel
    self.view_paths = ['test/fixtures']
    # include Cell::Erb

    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'

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cells-4.1.7 test/templates_test.rb