Sha256: dc75d3c4f5a7c8439a9dc324ab88b465150ae3474318e11857c009acf2900051

Contents?: true

Size: 1.1 KB

Versions: 53

Compression:

Stored size: 1.1 KB

Contents

require 'helper'
require 'erb'
require 'tilt'

describe Temple::ERB::Engine do
  it 'should compile erb' do
    src = %q{
%% hi
= hello
<% 3.times do |n| %>
* <%= n %>
<% end %>
}

    erb(src).should.equal ERB.new(src).result
  end

  it 'should recognize comments' do
    src = %q{
hello
  <%# comment -- ignored -- useful in testing %>
world}

    erb(src).should.equal ERB.new(src).result
  end

  it 'should recognize <%% and %%>' do
    src = %q{
<%%
<% if true %>
  %%>
<% end %>
}

    erb(src).should.equal "\n<%\n\n  %>\n\n" #ERB.new(src).result
  end

  it 'should escape automatically' do
    src = '<%= "<" %>'
    ans = '&lt;'
    erb(src, :auto_escape => true).should.equal ans
  end

  it 'should support == to disable automatic escape' do
    src = '<%== "<" %>'
    ans = '<'
    erb(src, :auto_escape => true).should.equal ans
  end

  it 'should support trim mode' do
    src = %q{
%% hi
= hello
<% 3.times do |n| %>
* <%= n %>
<% end %>
}

    erb(src, :trim_mode => '>').should.equal ERB.new(src, nil, '>').result
    erb(src, :trim_mode => '<>').should.equal ERB.new(src, nil, '<>').result
  end
end

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.7.4 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.7.3 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.7.2 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.7.1 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.7.0 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.6.9 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.6.8 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.6.7 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.6.6 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.6.5 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.6.4 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.6.3 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.6.2 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.6.1 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.6.0 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.5.17 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.5.16 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.5.15 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.5.14 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb