<commit_before>require_relative '../../spec_helper'

describe MailCatcher::API::Mailbox do
  include MailboxSpecHelpers

  describe 'stubbed' do
    before do
      stub_mailbox
    end
    after do
      remove_request_stub(@stub) if @stub
      unstub_mailbox
    end

    describe '#messages' do
      it 'without reload' do
        mailbox.messages.each do |msg|
          expect(msg).to be_an_instance_of(MailCatcher::API::Mailbox::Message)
        end
        assert_requested(:get, "#{mailbox_server}/messages", times: 1)
        @mailbox_email_index.each do |item|
          assert_requested(:get, "#{mailbox_server}/messages/#{item['id']}.json", times: 1)
        end
      end

      it 'with reload' do
        skip
      end
    end

    it '#count' do
      expect(mailbox.messages.count).to be @mailbox_size
    end
  end
end<commit_msg>Add spec for Mailbox.messages(reload: true)<commit_after>require_relative '../../spec_helper'

describe MailCatcher::API::Mailbox do
  include MailboxSpecHelpers

  describe 'stubbed' do
    before do
      stub_mailbox
    end
    after do
      remove_request_stub(@stub) if @stub
      unstub_mailbox
    end

    describe '#messages' do
      it 'without reload' do
        expect(mailbox.messages.count).to be @mailbox_size
        mailbox.messages.each do |msg|
          expect(msg).to be_an_instance_of(MailCatcher::API::Mailbox::Message)
        end
        assert_requested(:get, "#{mailbox_server}/messages", times: 1)
        @mailbox_email_index.each do |item|
          assert_requested(:get, "#{mailbox_server}/messages/#{item['id']}.json", times: 1)
        end
      end

      it 'with reload' do
        old_mailbox_size = @mailbox_size
        expect(mailbox.messages.count).to be old_mailbox_size
        unstub_mailbox
        new_mailbox_size = old_mailbox_size + 1
        stub_mailbox(new_mailbox_size)
        expect(mailbox.messages.count).to be old_mailbox_size
        expect(mailbox.messages(reload: true).count).to be new_mailbox_size
      end
    end

    it '#count' do
      expect(mailbox.messages.count).to be @mailbox_size
    end
  end
end
{'fraction_non_alphanumeric': 0.099577266322217, 'fraction_numerical': 0.0023485204321277596, 'mean_word_length': 2.7237762237762237, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '112475', 'n_tokens_mistral': 687, 'n_tokens_neox': 680, 'n_words': 148}