<commit_before>
require 'muack/test'

describe Muack::Mock do
  describe 'Muack.verify == true' do
    after do
      Muack.verify.should.eq true
    end

    should 'mock with regular method' do
      moo = mock.moo(true){ 'boo' }
      moo.moo(true).should.eq 'boo'
    end

    should 'mock with is_a matcher' do
      moo = mock('Moo').say(is_a(String)){ |arg| arg.reverse }
      moo.say('Foo').should.eq 'ooF'
    end

    should 'stub with regular method' do
      moo = stub.foo{ 'goo' }
      3.times{ moo.foo.should.eq 'goo' }
      Muack.verify.should.eq true
    end

    should 'mock chain' do
      moo = mock
      moo.moo(true){ moo.boo }.mock.boo{ 'coo' }
      moo.moo(true).should.eq 'coo'
    end

    should 'mock external object' do
      moo = mock('Moo')
      moo.sleep{ moo.sub('M', 'H') }
      moo.sleep.should.eq 'Hoo'
    end
  end

  describe 'Muack.verify == false' do
    after do
      Muack.verify.should.eq false
    end

    should 'raise Muack::Unexpected error if passing unexpected argument' do
      moo = mock.moo(true){ 'boo' }
      obj = moo.__mock_object
      def obj.inspect
        'moo'
      end
      begin
        moo.moo(false).should.eq 'boo'
        'never'.should.eq 'reach'
      rescue Muack::Unexpected => e
        e.expected.should.eq 'moo.moo(true)'
        e.was     .should.eq 'moo.moo(false)'
      end
    end
  end
end<commit_msg>let's work toward this API<commit_after>
require 'muack/test'

describe Muack::Mock do
  describe 'Muack.verify == true' do
    after do
      Muack.verify.should.eq true
    end

    obj = Object.new
    moo = 'Moo'
    def obj.inspect
      'obj'
    end

    should 'mock with regular method' do
      mock(obj).moo(true){ 'boo' }
      obj.moo(true).should.eq 'boo'
    end

    should 'mock with is_a matcher' do
      mock(moo).say(is_a(String)){ |arg| arg.reverse }
      moo.say('Foo').should.eq 'ooF'
    end

    should 'stub with regular method' do
      stub(obj).foo{ 'goo' }
      3.times{ obj.foo.should.eq 'goo' }
    end

    should 'mock chain' do
      mock(obj).moo(true){ obj.boo }.mock.boo{ 'coo' }
      obj.moo(true).should.eq 'coo'
    end

    should 'mock external object' do
      mock(moo).sleep{ moo.sub('M', 'H') }
      moo.sleep.should.eq 'Hoo'
    end
  end

  describe 'Muack.verify == false' do
    after do
      Muack.verify.should.eq false
    end

    should 'raise Muack::Unexpected error if passing unexpected argument' do
      mock(obj).moo(true){ 'boo' }
      begin
        obj.moo(false)
        'never'.should.eq 'reach'
      rescue Muack::Unexpected => e
        e.expected.should.eq 'obj.moo(true)'
        e.was     .should.eq 'obj.moo(false)'
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13120176405733186, 'fraction_numerical': 0.000735023888276369, 'mean_word_length': 2.132336018411968, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1828674', 'n_tokens_mistral': 1007, 'n_tokens_neox': 990, 'n_words': 246}