<commit_before>require 'spec_helper'

describe Omniorder::Orderable do
  let(:order) { Omniorder::Order.new }

  describe '#add_product_by_code' do
    it 'adds a product to the order when one is found' do
      product = Omniorder::Product.new(:code => 'CODE1')

      expect(Omniorder::Product).to receive(:find_by_code).
        with('CODE1').
        and_return(product)

      order.add_product_by_code('CODE1')

      order_product = order.order_products.first
      expect(order_product.quantity).to eq(1)
      expect(order_product.product).to eq(product)
    end

    it 'does nothing when no matching product is found' do
      expect(Omniorder::Product).to receive(:find_by_code)
        .with('CODE1')
        .and_return(nil)

      order.add_product_by_code('CODE1')

      expect(order.order_products.count).to eq(0)
    end
  end
end<commit_msg>Revert "Attempt to fix specs with Rubinius"<commit_after>require 'spec_helper'

describe Omniorder::Orderable do
  let(:order) { Omniorder::Order.new }

  describe '#add_product_by_code' do
    it 'adds a product to the order when one is found' do
      product = Omniorder::Product.new(:code => 'CODE1')

      expect(Omniorder::Product).to receive(:find_by_code)
        .with('CODE1')
        .and_return(product)

      order.add_product_by_code('CODE1')

      order_product = order.order_products.first
      expect(order_product.quantity).to eq(1)
      expect(order_product.product).to eq(product)
    end

    it 'does nothing when no matching product is found' do
      expect(Omniorder::Product).to receive(:find_by_code)
        .with('CODE1')
        .and_return(nil)

      order.add_product_by_code('CODE1')

      expect(order.order_products.count).to eq(0)
    end
  end
end
{'fraction_non_alphanumeric': 0.11187214611872145, 'fraction_numerical': 0.007990867579908675, 'mean_word_length': 3.393483709273183, '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': '5593711', 'n_tokens_mistral': 579, 'n_tokens_neox': 568, 'n_words': 119}