Sha256: 7a6f4357cc92e03b0fcf961ba79c86a79ab30660ae5e8bd9f7115ad33e61d567

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 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
          subject.abbreviations.should == abbrev
          subject.abbreviations.should_not 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
          subject.abbreviations.should == Hash[:foo,'bar']
        end
      end
    end
    
    describe '#abbreviate' do
      it 'looks up abbreviations in the default namespace by default' do
        subject.abbreviate(:title, 'foo').should == nil
        subject.abbreviations[:default][:title] = { 'foo' => 'bar' }
        subject.abbreviate(:title, 'foo').should == 'bar'
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
citeproc-1.0.1 spec/citeproc/abbreviate_spec.rb