Sha256: 6accbd67a7bf1e8592d49e953a884c022b666f8498b824b7c3ac02550dea37cb

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

module CiteProc
  describe Abbreviate do
    before { Object.class_eval { include Abbreviate } }

    let(:subject) { Object.new }
        
    describe '#abbreviations=' do
      context 'given a hash' do
        let(:abbrev) { Hash[:foo, :bar] }
        it 'uses the hash as the new set of abbreviations' do
          subject.abbreviations = abbrev
          expect(subject.abbreviations).to eq(abbrev)
          expect(subject.abbreviations).not_to equal(abbrev)
        end
      end
      
      context 'given a string' do
        let(:abbrev) { '{"foo":"bar"}' }
        it 'uses the hash as the new set of abbreviations' do
          subject.abbreviations = abbrev
          expect(subject.abbreviations).to eq(Hash[:foo,'bar'])
        end
      end
    end
    
    describe '#abbreviate' do
      it 'looks up abbreviations in the default namespace by default' do
        expect(subject.abbreviate(:title, 'foo')).to eq(nil)
        subject.abbreviations[:default][:title] = { 'foo' => 'bar' }
        expect(subject.abbreviate(:title, 'foo')).to eq('bar')
      end
    end
    
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
citeproc-1.0.7 spec/citeproc/abbreviate_spec.rb
citeproc-1.0.6 spec/citeproc/abbreviate_spec.rb
citeproc-1.0.5 spec/citeproc/abbreviate_spec.rb
citeproc-1.0.4 spec/citeproc/abbreviate_spec.rb
citeproc-1.0.3 spec/citeproc/abbreviate_spec.rb
citeproc-1.0.2 spec/citeproc/abbreviate_spec.rb