Sha256: 58a3770b7903fea908e5b16e814516492eebca644f8d84d7d5a2177d05a0fa30

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

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

  describe '#normalize_arguments' do
    subject { described_class.new 'cycle' }
    specify { subject.normalize_arguments([42]).should == [[42], subject.object_id.to_s] }
    specify { subject.normalize_arguments([42, 43, 44]).should == [[42, 43, 44], subject.object_id.to_s] }
    specify { subject.normalize_arguments(['hello' => 42]).should == [[42], 'hello'] }
    specify { subject.normalize_arguments(['hello' => [42, 43, 44]]).should == [[42, 43, 44], 'hello'] }
    specify { subject.normalize_arguments([42, { 'group' => 'hello' }]).should == [[42], 'hello'] }
    specify { subject.normalize_arguments([42, 43, { 'group' => 'hello' }]).should == [[42, 43], 'hello'] }
  end

  describe '#render' do
    specify { parse(
      "{{ cycle 'one', 'two', 'three' }} {{ cycle 'one', 'two', 'three' }}"
    ).render.should == 'one one' }
    specify { parse(
      "{{ cycle count: ['one', 'two', 'three'] }} {{ cycle 'one', 'two', 'three', group: 'count' }}"
    ).render.should == 'one two' }
    specify { parse(
      "{{ for i, in: [1, 2, 3], loop: true }}{{ i }} {{ cycle ['one', 'two', 'three'] }}{{ unless loop.last? }}, {{ end unless }}{{ end for }}"
    ).render.should == '1 one, 2 two, 3 three' }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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