<commit_before>require_relative 'spec_helper'

describe EsConsole do
  it 'starts console' do
    EsConsole::Console.any_instance.should_receive :pry
    EsConsole::Console.start
  end

  subject do
    EsConsole::Console.new
  end

  it 'initializes client' do
    subject.client.class.should == Elasticsearch::Transport::Client
  end

  it 'has default url' do
    subject.url.should == 'http://localhost:9200'
  end

  context 'new url' do
    let(:new_url) {'http://localhost:9201'}

    before do
      subject.url new_url
    end

    it 'sets new url' do
      subject.url.should == new_url
    end

    it 'creates new client' do
      subject.client.transport.options[:url] == new_url
    end
  end

  it 'gets all stats' do
    VCR.use_cassette('all_stats') do
      subject.stats.should == {'greeting'=>2, 'myindexa'=>1, 'myindex'=>1}
    end
  end

  it 'gets all count' do
    VCR.use_cassette('all_count') do
      subject.count.should == 4
    end
  end

  it 'changes context to index' do
    EsConsole::Index.any_instance.should_receive :pry
    subject.index 'greeting'
  end
end<commit_msg>format fixes<commit_after>require_relative 'spec_helper'

describe EsConsole do
  it 'starts console' do
    EsConsole::Console.any_instance.should_receive :pry
    EsConsole::Console.start
  end

  subject do
    EsConsole::Console.new
  end

  it 'initializes client' do
    subject.client.class.should == Elasticsearch::Transport::Client
  end

  it 'has default url' do
    subject.url.should == 'http://localhost:9200'
  end

  context 'new url' do
    let(:new_url) {'http://localhost:9201'}

    before do
      subject.url new_url
    end

    it 'sets new url' do
      subject.url.should == new_url
    end

    it 'creates new client' do
      subject.client.transport.options[:url] == new_url
    end
  end

  it 'gets all stats' do
    VCR.use_cassette 'all_stats' do
      subject.stats.should == {'greeting'=>2, 'myindexa'=>1, 'myindex'=>1}
    end
  end

  it 'gets all count' do
    VCR.use_cassette 'all_count' do
      subject.count.should == 4
    end
  end

  it 'changes context to index' do
    EsConsole::Index.any_instance.should_receive :pry
    subject.index 'greeting'
  end
end
{'fraction_non_alphanumeric': 0.10564334085778782, 'fraction_numerical': 0.010835214446952596, 'mean_word_length': 3.0144927536231885, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5242875', 'n_tokens_mistral': 765, 'n_tokens_neox': 733, 'n_words': 194}