<commit_before># encoding: UTF-8
require 'spec_helper'

describe Mysql2::Client do
  before(:each) do
    @client = Mysql2::Client.new DatabaseCredentials['root']
  end

  it "should raise an exception upon connection failure" do
    lambda {
      Mysql2::Client.new DatabaseCredentials['root'].merge(:port => 999999)
    }.should raise_error(Mysql2::Error)
  end

  if defined? Encoding
    it "should raise an exception on create for invalid encodings" do
      lambda {
        c = Mysql2::Client.new(:encoding => "fake")
      }.should raise_error(Mysql2::Error)
    end

    it "should not raise an exception on create for a valid encoding" do
      lambda {
        c = Mysql2::Client.new(:encoding => "utf8")
      }.should raise_error(Mysql2::Error)

      lambda {
        c = Mysql2::Client.new(:encoding => "big5")
      }.should raise_error(Mysql2::Error)<commit_msg>Fix the connection exception spec by forcing mysql library to use TCP to localhost in a way that will fail.<commit_after># encoding: UTF-8
require 'spec_helper'

describe Mysql2::Client do
  before(:each) do
    @client = Mysql2::Client.new DatabaseCredentials['root']
  end

  it "should raise an exception upon connection failure" do
    lambda {
      # The odd local host IP address forces the mysql client library to
      # use a TCP socket rather than a domain socket.
      Mysql2::Client.new DatabaseCredentials['root'].merge(:host => '127.0.0.2', :port => 999999)
    }.should raise_error(Mysql2::Error)
  end

  if defined? Encoding
    it "should raise an exception on create for invalid encodings" do
      lambda {
        c = Mysql2::Client.new(:encoding => "fake")
      }.should raise_error(Mysql2::Error)
    end

    it "should not raise an exception on create for a valid encoding" do
      lambda {
        c = Mysql2::Client.new(:encoding => "utf8")
      }.should raise_error(Mysql2::Error)

      lambda {
        c = Mysql2::Client.new(:encoding => "big5")
      }.should raise_error(Mysql2::Error)
{'fraction_non_alphanumeric': 0.10933599600599102, 'fraction_numerical': 0.02196704942586121, 'mean_word_length': 3.2729211087420045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '1522848', 'n_tokens_mistral': 639, 'n_tokens_neox': 600, 'n_words': 193}