Sha256: 311b6c25b9e11e221d38abeee035f97c903da5f882ebd814b00794db4eaea8ba

Contents?: true

Size: 1018 Bytes

Versions: 32

Compression:

Stored size: 1018 Bytes

Contents

require 'spec_helper'

RSpec.describe 'JavaScript filter rendering', type: :render do
  it 'renders javascript filter' do
    expect(render_string(<<HAML)).to eq("<div>\n<script>\n  alert('hello');\n</script>\n<span>world</span>\n</div>\n")
%div
  :javascript
    alert('hello');
  %span world
HAML
  end

  it 'keeps indent' do
    expect(render_string(<<HAML)).to eq("<div>\n<script>\n  alert('hello');\n  \n      alert('world');\n</script>\n</div>\n")
%div
  :javascript
    alert('hello');

        alert('world');
HAML
  end

  it 'ignores empty filter' do
    expect(render_string(<<HAML)).to eq("<div>\n<span>world</span>\n</div>\n")
%div
  :javascript
  %span world
HAML
  end

  it 'parses string interpolation' do
    expect(render_string(<<'HAML')).to eq("<script>\n  var x = 3;\n</script>\n")
:javascript
  var x = #{1 + 2};
HAML
  end

  it "doesn't escape in string interpolation" do
    expect(render_string(<<'HAML')).to eq("<script>\n  <span/>\n</script>\n")
:javascript
  #{'<span/>'}
HAML
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
faml-0.6.0 spec/render/filters/javascript_spec.rb
faml-0.5.1 spec/render/filters/javascript_spec.rb
faml-0.5.0 spec/render/filters/javascript_spec.rb
faml-0.4.2 spec/render/filters/javascript_spec.rb
faml-0.4.1 spec/render/filters/javascript_spec.rb
faml-0.4.0 spec/render/filters/javascript_spec.rb
faml-0.3.6 spec/render/filters/javascript_spec.rb
faml-0.3.5 spec/render/filters/javascript_spec.rb
faml-0.3.4 spec/render/filters/javascript_spec.rb
faml-0.3.3 spec/render/filters/javascript_spec.rb
faml-0.3.2 spec/render/filters/javascript_spec.rb
faml-0.3.1 spec/render/filters/javascript_spec.rb
faml-0.3.0 spec/render/filters/javascript_spec.rb
faml-0.2.16 spec/render/filters/javascript_spec.rb
faml-0.2.15 spec/render/filters/javascript_spec.rb
faml-0.2.14 spec/render/filters/javascript_spec.rb
faml-0.2.13 spec/render/filters/javascript_spec.rb
faml-0.2.12 spec/render/filters/javascript_spec.rb
faml-0.2.11 spec/render/filters/javascript_spec.rb
faml-0.2.10 spec/render/filters/javascript_spec.rb