Sha256: 2d922444f35b9a1fad0f404d7010c908eb8f5d59ac4b8a10afefa4426ee3c556

Contents?: true

Size: 1.17 KB

Versions: 76

Compression:

Stored size: 1.17 KB

Contents

require 'test_helper'
require 'tilt'
require 'tilt/sigil'

system('sigil -v')

if $?.success?
  class SigilTemplateTest < Minitest::Test
    test "registered for '.sigil' files" do
      assert_equal Tilt::SigilTemplate, Tilt['test.sigil']
    end

    test "loading and evaluating templates on #render" do
      template = Tilt::SigilTemplate.new { |t| "Hello World!" }
      assert_equal "Hello World!", template.render
    end

    test "can be rendered more than once" do
      template = Tilt::SigilTemplate.new { |t| "Hello World!" }
      3.times { assert_equal "Hello World!", template.render }
    end

    test "passing locals" do
      template = Tilt::SigilTemplate.new { 'Hey $name!' }
      assert_equal "Hey Joe!", template.render(Object.new, :name => 'Joe')
    end

    test "error message" do
      template = Tilt::SigilTemplate.new('test.sigil') { '{{undef_func}}' }
      begin
        template.render
        fail 'should have raised an exception'
      rescue => boom
        assert_kind_of RuntimeError, boom
        assert_equal 'template: test.sigil:1: function "undef_func" not defined', boom.message
      end
    end
  end
else
  warn "Tilt::SigilTemplate (disabled)"
end

Version data entries

76 entries across 75 versions & 14 rubygems

Version Path
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/tilt-2.0.9/test/tilt_sigil_test.rb
tilt-2.0.9 test/tilt_sigil_test.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/tilt-2.0.8/test/tilt_sigil_test.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
brakeman-4.3.1 bundle/ruby/2.5.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
brakeman-4.1.1 bundle/ruby/2.3.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
brakeman-4.1.0 bundle/ruby/2.3.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/tilt-2.0.7/test/tilt_sigil_test.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/tilt-2.0.7/test/tilt_sigil_test.rb
brakeman-4.0.1 bundle/ruby/2.3.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
brakeman-4.0.1.pre1 bundle/ruby/2.3.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
brakeman-4.0.0 bundle/ruby/2.3.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
brakeman-3.7.2 bundle/ruby/2.3.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
brakeman-3.7.1 bundle/ruby/2.3.0/gems/tilt-2.0.8/test/tilt_sigil_test.rb
tilt-2.0.8 test/tilt_sigil_test.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/tilt-2.0.7/test/tilt_sigil_test.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/tilt-2.0.7/test/tilt_sigil_test.rb