<commit_before>require 'spec_helper'
require 'stringio'
require 'nyan_cat_music_formatter'

class MockKernel
  def system(string)
    seen << string
  end

  def seen
    @seen ||= []
  end
end

describe NyanCatMusicFormatter do
  def path_to_mp3
    "#{File.expand_path('data/nyan-cat.mp3')}"
  end

  let(:stdout)      { StringIO.new }
  let(:formatter)   { described_class.new stdout }
  let(:mock_kernel) { MockKernel.new }

  before { formatter.kernel = mock_kernel }

  describe 'kernel' do
    it 'defaults to Kernel' do
      described_class.new(stdout).kernel.should == Kernel
    end

    it 'can be set' do
      formatter = described_class.new stdout
      formatter.kernel = 'something else'
      formatter.kernel.should == 'something else'
    end
  end

  describe 'platform' do
    it 'defaults to RUBY_PLATFORM' do
      described_class.new(stdout).platform.should equal RUBY_PLATFORM
    end

    it 'can be set' do
      formatter = described_class.new stdout
      formatter.platform = 'something else'
      formatter.platform.should == 'something else'
    end
  end

  describe 'start' do
    it 'sets the total amount of specs' do
      formatter.start 3
      formatter.example_count.should == 3
    end

    it 'sets the current to 0' do
      formatter.start 3
      formatter.current.should == 0
    end

    context 'when on OS X' do
      before { formatter.platform = 'darwin' }

      it 'plays the song in the background' do<commit_msg>Don't use object identity check<commit_after>require 'spec_helper'
require 'stringio'
require 'nyan_cat_music_formatter'

class MockKernel
  def system(string)
    seen << string
  end

  def seen
    @seen ||= []
  end
end

describe NyanCatMusicFormatter do
  def path_to_mp3
    "#{File.expand_path('data/nyan-cat.mp3')}"
  end

  let(:stdout)      { StringIO.new }
  let(:formatter)   { described_class.new stdout }
  let(:mock_kernel) { MockKernel.new }

  before { formatter.kernel = mock_kernel }

  describe 'kernel' do
    it 'defaults to Kernel' do
      described_class.new(stdout).kernel.should == Kernel
    end

    it 'can be set' do
      formatter = described_class.new stdout
      formatter.kernel = 'something else'
      formatter.kernel.should == 'something else'
    end
  end

  describe 'platform' do
    it 'defaults to RUBY_PLATFORM' do
      described_class.new(stdout).platform.should eq RUBY_PLATFORM
    end

    it 'can be set' do
      formatter = described_class.new stdout
      formatter.platform = 'something else'
      formatter.platform.should == 'something else'
    end
  end

  describe 'start' do
    it 'sets the total amount of specs' do
      formatter.start 3
      formatter.example_count.should == 3
    end

    it 'sets the current to 0' do
      formatter.start 3
      formatter.current.should == 0
    end

    context 'when on OS X' do
      before { formatter.platform = 'darwin' }

      it 'plays the song in the background' do
{'fraction_non_alphanumeric': 0.08697123519458545, 'fraction_numerical': 0.0047377326565143825, 'mean_word_length': 2.8141935483870966, 'pattern_counts': {'":': 0, '<': 7, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4876235', 'n_tokens_mistral': 967, 'n_tokens_neox': 901, 'n_words': 273}