<commit_before>describe Svgeez::Builder do
  describe '#build' do
    let(:logger) { Svgeez.logger }

    let(:error_message) { "Setting `source` and `destination` to the same path isn't allowed!" }

    let(:warning_message) { 'No SVGs were found in `source` folder.' }

    context 'when @source and @destination are the same' do
      let :builder do
        Svgeez::Builder.new(
          'source' => './foo',
          'destination' => './foo'
        )
      end

      it 'logs an error' do
        expect(logger).to receive(:error).with(error_message)
        builder.build
      end
    end

    context 'when @destination is nested within @source' do
      let :builder do
        Svgeez::Builder.new(
          'source' => './foo',
          'destination' => './foo/bar.svg'
        )
      end

      it 'logs an error' do
        expect(logger).to receive(:error).with(error_message)
        builder.build
      end
    end

    context 'when @source contains no SVG files' do
      let(:builder) { Svgeez::Builder.new }

      it 'logs a warning' do
        expect(logger).to receive(:warn).with(warning_message)
        builder.build
      end
    end

    context 'when @source contains SVG files' do
      let :file_paths do
        %w(facebook github heart skull twitter).map { |i| "./spec/fixtures/icons/#{i}.svg" }
      end

      let(:file) { double(File) }

      before do
        allow_any_instance_of(Svgeez::Source).to receive(:file_paths).and_return(file_paths)

        allow(FileUtils).to receive(:mkdir_p)
        allow(File).to receive(:open).and_yield(file)
        allow(SecureRandom).to receive(:uuid).and_return('1234-abcd-5678-efgh')
        allow(file).to receive(:write)
      end

      context 'when @svgo is not specified' do
        let :builder do
          Svgeez::Builder.new(
            'source' => './spec/fixtures/icons',
            'destination' => './spec/fixtures/icons.svg'
          )
        end

        it 'writes a file' do
          expect(logger).to receive(:info).exactly(:twice)
          expect(file).to receive(:write).with(IO.read('./spec/fixtures/icons.svg'))

          builder.build
        end
      end

      context 'when @svgo is specified' do
        let :builder do
          Svgeez::Builder.new(
            'source' => './spec/fixtures/icons',
            'destination' => './spec/fixtures/icons-svgo.svg',
            'svgo' => true
          )
        end

        it 'writes a file' do
          expect(logger).to receive(:info).exactly(:twice)
          expect(file).to receive(:write).with(IO.read('./spec/fixtures/icons-svgo.svg'))

          builder.build
        end
      end
    end
  end

  describe '#destination' do
    let(:builder) { Svgeez::Builder.new }

    it 'returns an instance of Svgeez::Destination' do
      expect(builder.destination).to be_instance_of(Svgeez::Destination)
    end
  end

  describe '#source' do
    let(:builder) { Svgeez::Builder.new }

    it 'returns an instance of Svgeez::Source' do
      expect(builder.source).to be_instance_of(Svgeez::Source)
    end
  end
end
<commit_msg>Remove unnecessary line from spec<commit_after>describe Svgeez::Builder do
  describe '#build' do
    let(:logger) { Svgeez.logger }

    let(:error_message) { "Setting `source` and `destination` to the same path isn't allowed!" }

    let(:warning_message) { 'No SVGs were found in `source` folder.' }

    context 'when @source and @destination are the same' do
      let :builder do
        Svgeez::Builder.new(
          'source' => './foo',
          'destination' => './foo'
        )
      end

      it 'logs an error' do
        expect(logger).to receive(:error).with(error_message)
        builder.build
      end
    end

    context 'when @destination is nested within @source' do
      let :builder do
        Svgeez::Builder.new(
          'source' => './foo',
          'destination' => './foo/bar.svg'
        )
      end

      it 'logs an error' do
        expect(logger).to receive(:error).with(error_message)
        builder.build
      end
    end

    context 'when @source contains no SVG files' do
      let(:builder) { Svgeez::Builder.new }

      it 'logs a warning' do
        expect(logger).to receive(:warn).with(warning_message)
        builder.build
      end
    end

    context 'when @source contains SVG files' do
      let :file_paths do
        %w(facebook github heart skull twitter).map { |i| "./spec/fixtures/icons/#{i}.svg" }
      end

      let(:file) { double(File) }

      before do
        allow_any_instance_of(Svgeez::Source).to receive(:file_paths).and_return(file_paths)

        allow(FileUtils).to receive(:mkdir_p)
        allow(File).to receive(:open).and_yield(file)
        allow(SecureRandom).to receive(:uuid).and_return('1234-abcd-5678-efgh')
      end

      context 'when @svgo is not specified' do
        let :builder do
          Svgeez::Builder.new(
            'source' => './spec/fixtures/icons',
            'destination' => './spec/fixtures/icons.svg'
          )
        end

        it 'writes a file' do
          expect(logger).to receive(:info).exactly(:twice)
          expect(file).to receive(:write).with(IO.read('./spec/fixtures/icons.svg'))

          builder.build
        end
      end

      context 'when @svgo is specified' do
        let :builder do
          Svgeez::Builder.new(
            'source' => './spec/fixtures/icons',
            'destination' => './spec/fixtures/icons-svgo.svg',
            'svgo' => true
          )
        end

        it 'writes a file' do
          expect(logger).to receive(:info).exactly(:twice)
          expect(file).to receive(:write).with(IO.read('./spec/fixtures/icons-svgo.svg'))

          builder.build
        end
      end
    end
  end

  describe '#destination' do
    let(:builder) { Svgeez::Builder.new }

    it 'returns an instance of Svgeez::Destination' do
      expect(builder.destination).to be_instance_of(Svgeez::Destination)
    end
  end

  describe '#source' do
    let(:builder) { Svgeez::Builder.new }

    it 'returns an instance of Svgeez::Source' do
      expect(builder.source).to be_instance_of(Svgeez::Source)
    end
  end
end

{'fraction_non_alphanumeric': 0.12667636128615284, 'fraction_numerical': 0.0025852318629827112, 'mean_word_length': 2.187435633367662, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '6936770', 'n_tokens_mistral': 1900, 'n_tokens_neox': 1871, 'n_words': 456}