Sha256: 2d118861a5be68628dde567f49afde9534ff84e4f986429e5b95a6b312ecc765

Contents?: true

Size: 1018 Bytes

Versions: 4

Compression:

Stored size: 1018 Bytes

Contents

require 'spec_helper'
require 'tilt/erubi'

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

    expect(erb(src)).to eq(erubi(src))
  end

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

    expect(erb(src)).to eq(erubi(src))
  end

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

    expect(erb(src)).to eq("\n<%\n  %>\n")
  end

  it 'should escape automatically' do
    src = '<%== "<" %>'
    ans = '&lt;'
    expect(erb(src)).to eq(ans)
  end

  it 'should support = to disable automatic escape' do
    src = '<%= "<" %>'
    ans = '<'
    expect(erb(src)).to eq(ans)
  end

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

    expect(erb(src, trim: true)).to eq(erubi(src, trim: true))
    expect(erb(src, trim: false)).to eq(erubi(src, trim: false))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
temple-0.10.2 spec/erb_spec.rb
temple-0.10.1 spec/erb_spec.rb
temple-0.10.0 spec/erb_spec.rb
temple-0.9.1 spec/erb_spec.rb