Sha256: 0d051ea48becefd6a0d66597cd73bdd0e10994f92151031cb2c633654474bddc

Contents?: true

Size: 1.5 KB

Versions: 17

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

RSpec.describe 'Comment rendering', type: :render do
  it 'renders html comment' do
    expect(render_string('/ comments')).to eq("<!-- comments -->\n")
  end

  it 'strips spaces' do
    expect(render_string('/   comments   ')).to eq("<!-- comments -->\n")
  end

  it 'renders structured comment' do
    expect(render_string(<<HAML)).to eq("<span>hello</span>\n<!--\ngreat\n-->\n<span>world</span>\n")
%span hello
/
  great
%span world
HAML
  end

  it 'renders comment with interpolation' do
    expect(render_string(<<'HAML')).to eq("<span>hello</span>\n<!--\ngreat\n-->\n<span>world</span>\n")
- comment = 'great'
%span hello
/
  #{comment}
%span world
HAML
  end

  it 'renders conditional comment' do
    expect(render_string('/ [if IE] hello')).to eq("<!--[if IE]> hello <![endif]-->\n")
  end

  it 'renders conditional comment with children' do
    expect(render_string(<<HAML)).to eq("<!--[if IE]>\n<span>hello</span>\nworld\n<![endif]-->\n")
/[if IE]
  %span hello
  world
HAML
  end

  it 'parses nested conditional comment' do
    expect(render_string(<<HAML)).to eq("<!--[[if IE]]>\n<span>hello</span>\nworld\n<![endif]-->\n")
/[[if IE]]
  %span hello
  world
HAML
  end

  it 'raises error if conditional comment bracket is unbalanced' do
    expect { render_string('/[[if IE]') }.to raise_error(Faml::SyntaxError)
  end

  it 'raises error if both comment text and children are given' do
    expect { render_string(<<HAML) }.to raise_error(Faml::SyntaxError)
/ hehehe
  %span hello
HAML
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
faml-0.2.16 spec/render/comment_spec.rb
faml-0.2.15 spec/render/comment_spec.rb
faml-0.2.14 spec/render/comment_spec.rb
faml-0.2.13 spec/render/comment_spec.rb
faml-0.2.12 spec/render/comment_spec.rb
faml-0.2.11 spec/render/comment_spec.rb
faml-0.2.10 spec/render/comment_spec.rb
faml-0.2.9 spec/render/comment_spec.rb
faml-0.2.8 spec/render/comment_spec.rb
faml-0.2.7 spec/render/comment_spec.rb
faml-0.2.6 spec/render/comment_spec.rb
faml-0.2.5 spec/render/comment_spec.rb
faml-0.2.4 spec/render/comment_spec.rb
faml-0.2.3 spec/render/comment_spec.rb
faml-0.2.2 spec/render/comment_spec.rb
faml-0.2.1 spec/render/comment_spec.rb
faml-0.2.0 spec/render/comment_spec.rb