<commit_before>class DummyUser
  include ActiveModel::Validations
  include Comable::CartOwner
end

describe Comable::CartOwner do
  let(:quantity) { 2 }
  let(:order_items) { build_list(:order_item, 5, quantity: quantity) }

  subject { DummyUser.new }

  before { allow(subject).to receive(:cart_items).and_return(order_items) }

  it 'has cart items' do
    expect(subject.cart.count).to eq(order_items.count * quantity)
  end

  context 'with errors' do
    let(:stock) { build(:stock, :unstocked) }
    let(:cart_item) { subject.cart_items.first }

    before { allow(cart_item).to receive(:stock).and_return(stock) }
    before { cart_item.valid? }

    it 'has cart with errors' do
      expect(subject.cart.errors.full_messages.first).to include(stock.name)
    end
  end
end
<commit_msg>Fix to pass the test of CartOwner<commit_after>class DummyUser
  include ActiveModel::Validations
  include Comable::CartOwner
end

describe Comable::CartOwner do
  let(:quantity) { 2 }
  let(:order_items) { build_list(:order_item, 5, quantity: quantity) }

  subject { DummyUser.new }

  before { allow(subject).to receive(:cart_items).and_return(order_items) }

  it 'has cart items' do
    expect(subject.cart.count).to eq(order_items.count * quantity)
  end

  context 'with errors' do
    let(:stock) { create(:stock, :unstocked, :with_product) }
    let(:cart_item) { subject.cart_items.first }

    before { allow(cart_item).to receive(:stock).and_return(stock) }
    before { cart_item.valid? }

    it 'has cart with errors' do
      expect(subject.cart.errors.full_messages.first).to include(stock.name)
    end
  end
end

{'fraction_non_alphanumeric': 0.11916461916461916, 'fraction_numerical': 0.002457002457002457, 'mean_word_length': 4.221153846153846, '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': '1883719', 'n_tokens_mistral': 543, 'n_tokens_neox': 524, 'n_words': 119}