Sha256: f40b0750eecd339432e29a8b8651b31a7061c888f6db9c797ad052d6e93b45bf
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require 'spec_helper' RSpec.describe 'Script rendering', type: :render do it 'parses script' do expect(render_string('%span= 1 + 2')).to eq("<span>3</span>\n") end it 'parses multi-line script' do expect(render_string(<<HAML)).to eq("<span>\n3\n</span>\n") %span = 1 + 2 HAML end it 'parses script and text' do expect(render_string(<<HAML)).to eq("<span>\n3\n3\n9\n</span>\n") %span = 1 + 2 3 = 4 + 5 HAML end it 'can contain Ruby comment' do expect(render_string('%span= 1 + 2 # comments')).to eq("<span>3</span>\n") end it 'can contain Ruby comment in multi-line' do expect(render_string(<<HAML)).to eq("<span>\n3\n3\n9\n</span>\n") %span = 1 + 2 # comment 3 = 4 + 5 # comment HAML end it 'can be comment-only' do expect(render_string(<<HAML)).to eq("\nstring\n") = # comment = 'string' HAML end it 'can have children' do expect(render_string(<<HAML)).to eq("<span>0</span>\n1<span>end</span>\n") = 1.times do |i| %span= i %span end HAML end it 'escapes unsafe string' do expect(render_string(<<HAML)).to eq("<p><script>alert(1)</script></p>\n") - title = '<script>alert(1)</script>' %p= title HAML end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
faml-0.8.1 | spec/render/script_spec.rb |
faml-0.8.0 | spec/render/script_spec.rb |