<commit_before># -*- coding: utf-8 -*-
require "rspec"
require 'tmpdir'
require "fileutils"
require File.join(File.dirname(__FILE__), '../lib/robust_excel_ole')

module RobustExcelOle::SpecHelpers
  def create_tmpdir     # :nodoc: #
    tmpdir = Dir.mktmpdir
    FileUtils.cp_r(File.join(File.dirname(__FILE__), 'data'), tmpdir)
    tmpdir + '/data'
  end

  def rm_tmp(tmpdir)     # :nodoc: #
    FileUtils.remove_entry_secure(File.dirname(tmpdir))
  end

  # This method is almost copy of wycats's implementation.
  # http://pochi.hatenablog.jp/entries/2010/03/24
  def capture(stream)   # :nodoc: #
    begin
      stream = stream.to_s
      eval "$#{stream} = StringIO.new"
      yield
      result = eval("$#{stream}").string
    ensure
      eval("$#{stream} = #{stream.upcase}")
    end
    result
  end
end

RSpec.configure do |config|
  config.include RobustExcelOle::SpecHelpers
end<commit_msg>enable new rspec syntax<commit_after># -*- coding: utf-8 -*-
require "rspec"
require 'tmpdir'
require "fileutils"
require File.join(File.dirname(__FILE__), '../lib/robust_excel_ole')

module RobustExcelOle::SpecHelpers
  def create_tmpdir     # :nodoc: #
    tmpdir = Dir.mktmpdir
    FileUtils.cp_r(File.join(File.dirname(__FILE__), 'data'), tmpdir)
    tmpdir + '/data'
  end

  def rm_tmp(tmpdir)     # :nodoc: #
    FileUtils.remove_entry_secure(File.dirname(tmpdir))
  end

  # This method is almost copy of wycats's implementation.
  # http://pochi.hatenablog.jp/entries/2010/03/24
  def capture(stream)   # :nodoc: #
    begin
      stream = stream.to_s
      eval "$#{stream} = StringIO.new"
      yield
      result = eval("$#{stream}").string
    ensure
      eval("$#{stream} = #{stream.upcase}")
    end
    result
  end
end

RSpec.configure do |config|
  config.include RobustExcelOle::SpecHelpers
  config.expect_with :rspec do |expectations|
    expectations.syntax = [:should, :expect]
  end
end
{'fraction_non_alphanumeric': 0.13733681462140993, 'fraction_numerical': 0.009399477806788513, 'mean_word_length': 3.4045977011494255, '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': '3263683', 'n_tokens_mistral': 687, 'n_tokens_neox': 678, 'n_words': 138}