Sha256: 7735b41391d502ad1a341688877475db1ad93964b3ad874c75bc0491ecead6f5

Contents?: true

Size: 1.72 KB

Versions: 15

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

module CiteProc
  
  describe Bibliography do
    
    it { should be_empty }
    it { should_not have_errors }
    
    describe '#to_citeproc conversion' do
      
      it 'returns an array' do
        subject.to_citeproc.should be_a(Array)
      end
      
      it 'returns exactly two elements' do
        subject.to_citeproc.should have(2).elements
      end
      
      it 'returns formatting options as the first element' do
        subject.to_citeproc.first.should be_a(Hash)
      end

      describe 'the formatting options' do
        let(:options) { subject.to_citeproc[0] }
        
        it 'contains a the error list' do
          options.should have_key('bibliography_errors')
          options['bibliography_errors'].should be_empty
        end
        
      end
      
      it 'returns the list of references as the second element' do
        subject.to_citeproc.last.should be_a(Array)
      end
      
    end
    
    describe '.create (citeproc parser)' do
      let(:js) { <<-JS_END }
      [
        {
          "maxoffset": 0,
          "entryspacing": 0,
          "linespacing": 0,
          "hangingindent": 0,
          "second-field-align": true,
          "bibstart": "<div class=\\"csl-bib-body\\">\\n",
          "bibend": "</div>",
          "bibliography_errors": []
        },
        [
          "<div class=\\"csl-entry\\">Book A</div>",
          "<div class=\\"csl-entry\\">Book C</div>"
        ]
      ]
      JS_END
      
      it 'parses citeproc/json strings' do
        b = Bibliography.create(js)
        b.should be_a(Bibliography)
        b.should have(2).references
        b.should_not have_errors
        b.options[:align].should be true
      end
      
    end
    
  end
  
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
citeproc-1.0.0.pre12 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre11 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre10 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre9 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre8 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre7 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre6 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre5 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre4 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre3 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre2 spec/citeproc/bibliography_spec.rb
citeproc-1.0.0.pre1 spec/citeproc/bibliography_spec.rb
citeproc-0.0.9 spec/citeproc/bibliography_spec.rb
citeproc-0.0.8 spec/citeproc/bibliography_spec.rb
citeproc-0.0.6 spec/citeproc/bibliography_spec.rb