<commit_before>module ThousandIsland
  module Components
    describe Header do
      let(:prawn_doc) { instance_double('Prawn::Document') }
      let(:header) { described_class.new(prawn_doc) }
      let(:bounds) { double(:bounds) }

      it '#repeated? uses the option value' do
        expect(header.repeated?).to eq(header.options[:repeated])
      end

      context 'interactions with Prawn' do

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

        it 'repeats the header' do
          expect(prawn_doc).to receive(:repeat).with(:all)
          header.render_all
        end


        context 'yields the block' do
          it 'when render' do
            expect{ |doc| header.render(&doc) }.to yield_with_args(prawn_doc)
          end

          it 'when render_all' do
            expect{ |doc| header.render_all(&doc) }.to yield_with_args(prawn_doc)
          end

          it 'when draw' do
            expect{ |doc| header.draw(&doc) }.to yield_with_args(prawn_doc)
          end
        end

        context 'options' do
          context 'defaults' do
            it 'sizes the box' do
              header.render
              h = header.options[:header_height]
              expect(prawn_doc).to have_received(:bounding_box).with([0, std_doc_height], width: std_doc_width, height: h)
            end
          end
          context 'custom' do<commit_msg>Expanded tests for Component::Header<commit_after>module ThousandIsland
  module Components
    describe Header do
      let(:prawn_doc) { instance_double('Prawn::Document') }
      let(:header) { described_class.new(prawn_doc) }
      let(:bounds) { double(:bounds) }
      let(:test_block) { lambda { |a| a } }

      it '#repeated? uses the option value' do
        expect(header.repeated?).to eq(header.options[:repeated])
      end

      context 'interactions with Prawn' do

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

        it 'repeats the header' do
          expect(prawn_doc).to receive(:repeat).with(:all)
          header.render_all
        end


        context 'the block' do
          it 'yields when render' do
            expect{ |doc| header.render(&doc) }.to yield_with_args(prawn_doc)
          end

          it 'is passed to render when render_all' do
            expect(header).to receive(:render)
            header.render_all(&test_block)
          end

          context 'is passed by draw to' do
            it 'render_all when repeated?' do
              allow(header).to receive(:repeated?) { true }
              expect(header).to receive(:render_all)
              header.draw(&test_block)
            end

            it 'render when not repeated?' do
              allow(header).to receive(:repeated?) { false }
              expect(header).to receive(:render)
              header.draw(&test_block)
            end
          end
        end

        context 'options' do
          context 'defaults' do
            it 'sizes the box' do
              header.render
              h = header.options[:header_height]
              expect(prawn_doc).to have_received(:bounding_box).with([0, std_doc_height], width: std_doc_width, height: h)
            end
          end
          context 'custom' do
{'fraction_non_alphanumeric': 0.10233393177737882, 'fraction_numerical': 0.0005129520389843549, 'mean_word_length': 2.061224489795918, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6072856', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1122, 'n_words': 267}