Sha256: d9d6a29b21475914bc28425434d20ee02eb43f0236bf94a46f5f52355f6f72e3

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

module ThousandIsland
  module Components
    describe Footer do
      let(:prawn_doc) { instance_double('Prawn::Document') }
      let(:bounds) { double(:bounds) }
      let(:footer) { described_class.new(prawn_doc) }

      it '#repeated? uses the option value' do
        footer.options[:repeated] = true
        expect(footer.repeated?).to be true
      end

      context 'Page Numbering' do
        context 'uses the correct string when options are' do
          it 'set' do
            expected = 'Page <page> of <total>'
            footer.options[:numbering_string] = expected
            expect(footer.numbering_string).to eq(expected)
          end

          it 'not set' do
            expect(footer.numbering_string).to eq('<page>')
          end
        end

      end

      context 'interactions with Prawn' do

        before :each do
          allow(prawn_doc).to receive(:bounding_box).and_yield
          allow(bounds).to receive(:width) { std_doc_width }
          allow(prawn_doc).to receive(:bounds) { bounds }
          allow(prawn_doc).to receive(:number_pages)
        end

        it 'sizes the box' do
          h = footer.options[:height]
          expect(prawn_doc).to receive(:bounding_box).with([0, h], width: std_doc_width, height: h)
          footer.render
        end

        it 'renders the page numbers' do
          expect(prawn_doc).to receive(:number_pages).with(footer.numbering_string, footer.options[:numbering_options])
          footer.render
        end

      end

    private
      def std_doc_width
        595
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thousand_island-0.1.1 spec/thousand_island/components/footer_spec.rb
thousand_island-0.1.0 spec/thousand_island/components/footer_spec.rb
thousand_island-0.0.1 spec/thousand_island/components/footer_spec.rb