Sha256: 2d21e561a6fcba96c93c3e4c795508331cee15bb6ee9303bfa5923c206ca95bf

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe Hotcell::Commands::Unless do
  def parse source
    Hotcell::Template.parse(source)
  end

  describe '#validate!' do
    specify { expect { parse('{{ unless }}{{ end unless }}').syntax
      }.to raise_error Hotcell::ArgumentError, 'Wrond number of arguments for `unless` (0 for 1) at 1:4' }
    specify { expect { parse('{{ unless true }}{{ else false }}{{ end unless }}').syntax
      }.to raise_error Hotcell::ArgumentError, 'Wrond number of arguments for `else` (1 for 0) at 1:21' }
    specify { expect { parse('{{ unless true }}{{ else }}{{ else }}{{ end unless }}').syntax
      }.to raise_error Hotcell::BlockError, 'Unexpected `else` for `unless` command at 1:31' }
  end

  describe '#render' do
    specify { parse('{{ unless true }}Hello{{ end unless }}').render.should == '' }
    specify { parse('{{ unless false }}Hello{{ end unless }}').render.should == 'Hello' }
    specify { parse('{{ unless true }}Hello{{ else }}World{{ end unless }}').render.should == 'World' }
    specify { parse('{{ unless false }}Hello{{ else }}World{{ end unless }}').render.should == 'Hello' }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hotcell-0.3.0 spec/lib/hotcell/commands/unless_spec.rb
hotcell-0.2.0 spec/lib/hotcell/commands/unless_spec.rb
hotcell-0.1.0 spec/lib/hotcell/commands/unless_spec.rb