spec/csl/locale/term_spec.rb in csl-1.0.0.pre15 vs spec/csl/locale/term_spec.rb in csl-1.0.0.pre16

- old
+ new

@@ -1,5 +1,6 @@ +# coding: utf-8 require 'spec_helper' module CSL describe Locale::Terms do @@ -51,22 +52,58 @@ </term> <term name="page"> <single>page</single> <multiple>pages</multiple> </term> + <term name="section"> + <single>section</single> + <multiple>sections</multiple> + </term> + <term name="section" form="short">sec.</term> + <term name="section" form="symbol"> + <single>§</single> + <multiple>§§</multiple> + </term> + <term name="editor"> + <single>editor</single> + <multiple>editors</multiple> + </term> + <term name="editor" form="short"> + <single>ed.</single> + <multiple>eds.</multiple> + </term> + <term name="editor" form="verb">edited by</term> + <term name="editor" form="verb-short">ed.</term> </terms> EOS end - + it 'returns nil if there is no matching term' do en.lookup(:foo).should be_nil end - it 'returns the first matching form by default' do - en.lookup(:page).should be_short + it 'returns the long form by default' do + en.lookup(:page).should be_long end - + + it 'returns the term in the passed-in form if available' do + en.lookup(:section, :form => 'long').should be_long + en.lookup(:section, :form => 'short').should be_short + en.lookup(:section, :form => 'symbol').should be_symbol + + en.lookup(:editor).should be_long + en.lookup(:editor, :form => 'long').should be_long + en.lookup(:editor, :form => 'verb').should be_verb + en.lookup(:editor, :form => 'verb-short').should be_verb_short + end + + it 'returns the right fallback form if the passed-in form is not available' do + en.lookup(:page, :form => 'verb').should be_long + en.lookup(:page, :form => 'verb-short').should be_long + en.lookup(:page, :form => 'symbol').should be_short + end + it 'ignores irrelevant options' do en.lookup(:page, :plural => true).should_not be_nil end end @@ -76,13 +113,14 @@ describe Locale::Term do it { should_not be_nil } it { should_not be_gendered } - it { should be_neutral } + it { should be_long } + it { should_not be_ordinal } it { should_not be_short_ordinal } it { should_not be_long_ordinal } it 'is not a textnode by default' do @@ -147,10 +185,10 @@ end end describe 'attributes#to_a' do it 'returns an array of all attribute values of underlying struct' do - f.attributes.to_a.should == ['edition', nil, 'feminine', nil, nil] + f.attributes.to_a.should == ['edition', 'long', 'feminine', nil, nil] end end end describe '#to_s' do \ No newline at end of file