<commit_before>require 'rubygems'
require 'bundler'
Bundler.setup
Bundler.require :default, :test

require File.expand_path(File.dirname(__FILE__) + '/../lib/bunyan')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))

class DuckedMongo
end

Spec::Runner.configure do |config|

  config.before :each do
    mock_mongo_connection
  end

  def mock_mongo_connection
    @mock_collection = mock("Mongo Collection")
    @mock_connection = mock("Mongo Connection")
    @mock_database   = mock("Mongo Database", 
       :collection        => @mock_collection, 
       :create_collection => @mock_collection,
       :collection_names  => ['name 1'],
       :connection        => @mock_connection)
    @mock_connection.stub!(:db).and_return(@mock_database)
    Mongo::Connection.stub!(:new).and_return(@mock_connection)
    @mock_database
  end

  def unstub_mongo
    Mongo::Connection.unstub!(:new)
  end

  def other_fake_mongo
    #I want to check Mongo::Connection.stub.new is not called
    dm = DuckedMongo
    dm.stub!(:db).and_return(@mock_database)
    dm
  end

  def configure_test_db
    Bunyan::Logger.configure do |config|
      config.database   'bunyan_test'
      config.collection 'bunyan_test_log'
    end<commit_msg>modify configure_test_db to take a block<commit_after>require 'rubygems'
require 'bundler'
Bundler.setup
Bundler.require :default, :test

require File.expand_path(File.dirname(__FILE__) + '/../lib/bunyan')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))

class DuckedMongo
end

Spec::Runner.configure do |config|

  config.before :each do
    mock_mongo_connection
  end

  def mock_mongo_connection
    @mock_collection = mock("Mongo Collection")
    @mock_connection = mock("Mongo Connection")
    @mock_database   = mock("Mongo Database", 
       :collection        => @mock_collection, 
       :create_collection => @mock_collection,
       :collection_names  => ['name 1'],
       :connection        => @mock_connection)
    @mock_connection.stub!(:db).and_return(@mock_database)
    Mongo::Connection.stub!(:new).and_return(@mock_connection)
    @mock_database
  end

  def unstub_mongo
    Mongo::Connection.unstub!(:new)
  end

  def other_fake_mongo
    #I want to check Mongo::Connection.stub.new is not called
    dm = DuckedMongo
    dm.stub!(:db).and_return(@mock_database)
    dm
  end

  def configure_test_db(&block)
    Bunyan::Logger.configure do |c|
      c.database   'bunyan_test'
      c.collection 'bunyan_test_log'
      yield(c) if block_given?
    end
{'fraction_non_alphanumeric': 0.11080332409972299, 'fraction_numerical': 0.0007914523149980214, 'mean_word_length': 3.8336520076481837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4511348', 'n_tokens_mistral': 842, 'n_tokens_neox': 830, 'n_words': 161}