<commit_before>require 'delta_test/cli/stats_show_command'

describe DeltaTest::CLI::StatsShowCommand do

end<commit_msg>Write specs for stats:show command<commit_after>require 'delta_test/cli/stats_show_command'
require 'delta_test/related_spec_list'
require 'delta_test/stats'

describe DeltaTest::CLI::StatsShowCommand do

  let(:command) { DeltaTest::CLI::StatsShowCommand.new([]) }

  let(:table) do
    {
      'spec/foo_spec.rb' => ['lib/foo.rb']
    }
  end

  let(:base_commit) { '1111111111111111111111111111111111111111' }

  before do
    allow($stdout).to receive(:puts).and_return(nil)
    allow($stderr).to receive(:puts).and_return(nil)

    allow_any_instance_of(DeltaTest::RelatedSpecList).to receive(:load_table!).and_return(nil)
    allow_any_instance_of(DeltaTest::RelatedSpecList).to receive(:table).and_return(table)

    allow_any_instance_of(DeltaTest::Stats).to receive(:base_commit).and_return(base_commit)
  end

  describe '#invoke!' do

    it 'should raise an error if a base commit does not exist' do
      allow_any_instance_of(DeltaTest::Stats).to receive(:base_commit).and_return(nil)

      expect {
        command.invoke!
      }.to raise_error(DeltaTest::StatsNotFoundError)
    end

    it 'should load a table file' do
      expect_any_instance_of(DeltaTest::RelatedSpecList).to receive(:load_table!)
      expect_any_instance_of(DeltaTest::RelatedSpecList).to receive(:table)

      expect {
        command.invoke!
      }.not_to raise_error
    end

    it 'should show the table contents' do
      expect_any_instance_of(DeltaTest::RelatedSpecList).to receive(:load_table!)
      expect_any_instance_of(DeltaTest::RelatedSpecList).to receive(:table)

      expect {
        command.invoke!
      }.to output(/foo_spec\.rb/).to_stdout
    end

  end

end
{'fraction_non_alphanumeric': 0.11234705228031146, 'fraction_numerical': 0.02224694104560623, 'mean_word_length': 4.5015290519877675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '4326787', 'n_tokens_mistral': 620, 'n_tokens_neox': 556, 'n_words': 97}