Sha256: 535cf2f59191988fc57de679392878bb540557b2185788d45e0c6ddcbea85e1b

Contents?: true

Size: 1.62 KB

Versions: 16

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

RSpec.describe 'SilentScript rendering', type: :render do
  it 'parses silent script' do
    expect(render_string(<<HAML)).to eq("<span>0</span>\n<span>1</span>\n")
- 2.times do |i|
  %span= i
HAML
  end

  it 'parses if' do
    expect(render_string(<<HAML)).to eq("<div>\neven\n</div>\n")
%div
  - if 2.even?
    even
HAML
  end

  it 'parses if and text' do
    expect(render_string(<<HAML)).to eq("<div>\neven\nok\n</div>\n")
%div
  - if 2.even?
    even
  ok
HAML
  end

  it 'parses if and else' do
    expect(render_string(<<HAML)).to eq("<div>\nodd\n</div>\n")
%div
  - if 1.even?
    even
  - else
    odd
HAML
  end

  it 'parses if and elsif' do
    expect(render_string(<<HAML)).to eq("<div>\n2\neven\n</div>\n")
%div
  - if 1.even?
    even
  - elsif 2.even?
    2
    even
  - else
    odd
HAML
  end

  it 'parses case-when' do
    expect(render_string(<<HAML)).to eq("<div>\n2\neven\n</div>\n")
%div
  - case
  - when 1.even?
    even
  - when 2.even?
    2
    even
  - else
    else
HAML
  end

  it 'parses Ruby comment' do
    expect(render_string(<<HAML)).to eq("<span>Print me</span>\n")
- # Ruby comment here
%span Print me
HAML
  end

  it 'parses Ruby multiline' do
    expect(render_string(<<HAML)).to eq("<div>\n<span>ne</span>\n</div>\n")
%div
  - if 1 == Complex(2,
3)
    %span eq
  - else
    %span ne
HAML
  end

  it 'allows empty silent script body' do
    expect(render_string("%br\n-\n%br")).to eq("<br>\n<br>\n")
  end

  it 'checks indent levels' do
    expect(render_string(<<HAML)).to eq("<span>hello</span>\n")
- if true
  %span hello
  - if false
    %span world
- else
  %span !!!
HAML
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
faml-0.3.6 spec/render/silent_script_spec.rb
faml-0.3.5 spec/render/silent_script_spec.rb
faml-0.3.4 spec/render/silent_script_spec.rb
faml-0.3.3 spec/render/silent_script_spec.rb
faml-0.3.2 spec/render/silent_script_spec.rb
faml-0.3.1 spec/render/silent_script_spec.rb
faml-0.3.0 spec/render/silent_script_spec.rb
faml-0.2.16 spec/render/silent_script_spec.rb
faml-0.2.15 spec/render/silent_script_spec.rb
faml-0.2.14 spec/render/silent_script_spec.rb
faml-0.2.13 spec/render/silent_script_spec.rb
faml-0.2.12 spec/render/silent_script_spec.rb
faml-0.2.11 spec/render/silent_script_spec.rb
faml-0.2.10 spec/render/silent_script_spec.rb
faml-0.2.9 spec/render/silent_script_spec.rb
faml-0.2.8 spec/render/silent_script_spec.rb