Sha256: 381dffc93c6f2d242a5da89bb7b2f2f9674730bff58900d9232ac0d14bc0e5aa

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

module CSL
  class Style

    describe Choose do

    end

    describe Choose::Block do
      
      describe '#conditions' do
        it 'returns an empty list by default' do
          Choose::Block.new.conditions.should be_empty
        end
        
        describe 'when the node has a single condition' do
          let(:node) { Choose::Block.new(:'is-numeric' => 'edition' )}
          
          it 'returns an array with an array containing the type and value of the condition' do
            node.conditions.should == [[:'is-numeric', 'edition']]
          end
          
          describe 'when the node has two conditions' do
            before(:each) { node[:disambiguate] = 'true' }
            
            it 'returns an array with two elements' do
              node.conditions.should have_exactly(2).items
            end
            
            it 'returns both conditions as arrays' do
              node.conditions.map(&:first).sort.should == [:disambiguate, :'is-numeric']
              node.conditions.map(&:last).sort.should == ['edition', 'true']
            end
          end
        end
        
        describe 'when the node has a single condition with multiple values' do
          let(:node) { Choose::Block.new(:variable => 'author editor' )}
          
          it 'expands the conditions in the result' do
            node.conditions.should == [[:variable, 'author'], [:variable, 'editor']]
          end
        end
      end
      
    end
  
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csl-1.0.0.pre21 spec/csl/style/choose_spec.rb