Sha256: a247bf0e25960f150340fb390159feb78756073725a74b3a7cc2338b6f4851aa

Contents?: true

Size: 1.04 KB

Versions: 22

Compression:

Stored size: 1.04 KB

Contents

require 'helper'

class Nanoc::Filters::MustacheTest < Nanoc::TestCase
  def test_filter
    if_have 'mustache' do
      # Create item
      item = Nanoc::Int::Item.new(
        'content',
        { title: 'Max Payne', protagonist: 'Max Payne' },
        '/games/max-payne/',
      )

      # Create filter
      filter = ::Nanoc::Filters::Mustache.new(item: item)

      # Run filter
      result = filter.setup_and_run('The protagonist of {{title}} is {{protagonist}}.')
      assert_equal('The protagonist of Max Payne is Max Payne.', result)
    end
  end

  def test_filter_with_yield
    if_have 'mustache' do
      # Create item
      item = Nanoc::Int::Item.new(
        'content',
        { title: 'Max Payne', protagonist: 'Max Payne' },
        '/games/max-payne/',
      )

      # Create filter
      filter = ::Nanoc::Filters::Mustache.new(
        content: 'No Payne No Gayne', item: item,
      )

      # Run filter
      result = filter.setup_and_run('Max says: {{yield}}.')
      assert_equal('Max says: No Payne No Gayne.', result)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
nanoc-4.7.9 test/filters/test_mustache.rb
nanoc-4.7.8 test/filters/test_mustache.rb
nanoc-4.7.7 test/filters/test_mustache.rb
nanoc-4.7.6 test/filters/test_mustache.rb
nanoc-4.7.5 test/filters/test_mustache.rb
nanoc-4.7.4 test/filters/test_mustache.rb
nanoc-4.7.3 test/filters/test_mustache.rb
nanoc-4.7.2 test/filters/test_mustache.rb
nanoc-4.7.1 test/filters/test_mustache.rb
nanoc-4.7.0 test/filters/test_mustache.rb
nanoc-4.6.4 test/filters/test_mustache.rb
nanoc-4.6.3 test/filters/test_mustache.rb
nanoc-4.6.2 test/filters/test_mustache.rb
nanoc-4.6.1 test/filters/test_mustache.rb
nanoc-4.6.0 test/filters/test_mustache.rb
nanoc-4.5.4 test/filters/test_mustache.rb
nanoc-4.5.3 test/filters/test_mustache.rb
nanoc-4.5.2 test/filters/test_mustache.rb
nanoc-4.5.1 test/filters/test_mustache.rb
nanoc-4.5.0 test/filters/test_mustache.rb