Sha256: d8d653b6d13329fff93d99a6605d92cc9771cb78e51531beb7514d3cc4261c08

Contents?: true

Size: 1.34 KB

Versions: 12

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

module CiteProc
  module Ruby

    describe Renderer::History do
      let(:state) { Renderer::State.new }
      let(:history) { state.history }

      it 'has an empty citation history' do
        expect(history.memory['citation']).to eq([])
      end

      it 'has an empty bibliography history' do
        expect(history.memory['bibliogrpahy']).to eq([])
      end

      describe '#update' do
        it 'saves the passed in items for :store!' do
          expect {
            history.update :store!, 'citation', { :x => 1 }
          }.to change { history.citation }.to([{ :x => 1 }])
        end

        it 'drops remembered items when they are too old' do
          expect {
            history.update :store!, 'citation', { :x => 1 }
            history.update :store!, 'citation', { :x => 2 }
            history.update :store!, 'citation', { :x => 3 }
            history.update :store!, 'citation', { :x => 4 }
            history.update :store!, 'citation', { :x => 5 }
          }.to change { history.citation.length }.to(3)
        end
      end

      describe '#discard' do
        it 'clears the history' do
          history.update :store!, 'bibliography', { :x => 1 }
          expect(history.memory).not_to be_empty
          history.discard
          expect(history.memory).to be_empty
        end
      end
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
citeproc-ruby-1.1.8 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.1.7 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.1.6 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.1.5 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.1.4 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.1.3 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.1.2 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.1.1 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.1.0 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.0.6 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.0.5 spec/citeproc/ruby/renderer/history_spec.rb
citeproc-ruby-1.0.4 spec/citeproc/ruby/renderer/history_spec.rb