<commit_before>require 'spec_helper'

describe Mongo::BulkWrite do

  before do
    authorized_collection.find.delete_many
  end

  after do
    authorized_collection.find.delete_many
  end

  let(:bulk) do
    described_class.get(authorized_collection, operations, options)
  end

  describe '#get' do

    let(:operations) do
      [{ insert_one: { _id: 0 } }]
    end

    context 'When an ordered bulk write object is created' do

      let(:options) do
        { ordered: true }
      end

      it 'returns an OrderedBulkWrite object' do
        expect(bulk).to be_a(Mongo::BulkWrite::OrderedBulkWrite)
      end
    end

    context 'When an unordered bulk write object is created' do

      let(:options) do
        { ordered: false }
      end

      it 'returns an UnorderedBulkWrite object' do
        expect(bulk).to be_a(Mongo::BulkWrite::UnorderedBulkWrite)
      end
    end
  end

  describe 'Ordered bulk write' do

    let(:options) do
       { ordered: true }
    end
     
    it_behaves_like 'a bulk write object'
    
    context 'when the batch requires splitting' do<commit_msg>RUBY-875 test for default ordered value when instantiating bulk object<commit_after>require 'spec_helper'

describe Mongo::BulkWrite do

  before do
    authorized_collection.find.delete_many
  end

  after do
    authorized_collection.find.delete_many
  end

  let(:bulk) do
    described_class.get(authorized_collection, operations, options)
  end

  describe '#get' do

    let(:operations) do
      [{ insert_one: { _id: 0 } }]
    end

    context 'When an ordered bulk write object is created' do

      let(:options) do
        { ordered: true }
      end

      it 'returns an OrderedBulkWrite object' do
        expect(bulk).to be_a(Mongo::BulkWrite::OrderedBulkWrite)
      end
    end

    context 'When an unordered bulk write object is created' do

      let(:options) do
        { ordered: false }
      end

      it 'returns an UnorderedBulkWrite object' do
        expect(bulk).to be_a(Mongo::BulkWrite::UnorderedBulkWrite)
      end
    end

    context 'When ordered is not specified in options' do

      let(:options) do
        { }
      end

      it 'returns an OrderedBulkWrite object' do
        expect(bulk).to be_a(Mongo::BulkWrite::OrderedBulkWrite)
      end
    end
  end

  describe 'Ordered bulk write' do

    let(:options) do
       { ordered: true }
    end
     
    it_behaves_like 'a bulk write object'
    
    context 'when the batch requires splitting' do
{'fraction_non_alphanumeric': 0.0740296118447379, 'fraction_numerical': 0.0020008003201280513, 'mean_word_length': 2.586800573888092, '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': '5648800', 'n_tokens_mistral': 787, 'n_tokens_neox': 745, 'n_words': 232}