<commit_before>
require 'bacon'
require 'rr'
require 'fileutils'
require 'ripl/rc/squeeze_history'
Bacon.summary_on_exit
include RR::Adapters::RRMethods

describe Ripl::Rc::SqueezeHistory do
  before do
    @history = '/tmp/test_ripl_history'
    @shell   = Ripl::Shell.create(Ripl.config.merge!(:history => @history))
    @input   = %w[foo bar bar foo bar]
    @shell.history.clear
    @shell.before_loop
  end

  after do; FileUtils.rm_f(@history); end

  should 'after_loop saves squeezed history' do
    @shell.history.push(*@input)
    @shell.instance_variable_set('@input', '')
    @shell.after_loop
    File.read(@history).should == %w[foo bar foo bar].join("\n") + "\n"
  end

  should 'loop_once squeeze history' do<commit_msg>test_squeeze_history.rb: no ~/.irbrc please...<commit_after>
require 'bacon'
require 'rr'
require 'fileutils'
require 'ripl/rc/squeeze_history'
Bacon.summary_on_exit
include RR::Adapters::RRMethods

describe Ripl::Rc::SqueezeHistory do
  before do
    @history = '/tmp/test_ripl_history'
    @shell   = Ripl::Shell.create(Ripl.config.merge!(:history => @history,
                                                     :irbrc   => nil))
    @input   = %w[foo bar bar foo bar]
    @shell.history.clear
    @shell.before_loop
  end

  after do; FileUtils.rm_f(@history); end

  should 'after_loop saves squeezed history' do
    @shell.history.push(*@input)
    @shell.instance_variable_set('@input', '')
    @shell.after_loop
    File.read(@history).should == %w[foo bar foo bar].join("\n") + "\n"
  end

  should 'loop_once squeeze history' do
{'fraction_non_alphanumeric': 0.1384126984126984, 'fraction_numerical': 0.0, 'mean_word_length': 3.554913294797688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '898820', 'n_tokens_mistral': 551, 'n_tokens_neox': 530, 'n_words': 116}