<commit_before>require 'spec_helper'

RSpec.describe SpreeAmazonMws::Orders do
  subject(:orders) { SpreeAmazonMws::Orders.new }
  let(:payment_method) { FactoryGirl.create(:amazon_mfn_payment_method) }
  let(:client) { orders.send(:client) }
  let(:get_order_file) { File.read ENGINE_ROOT.join('spec', 'fixtures', 'get_order.xml') }
  let(:list_orders_file) { File.read ENGINE_ROOT.join('spec', 'fixtures', 'list_orders.xml') }
  let(:list_order_items_file) { File.read ENGINE_ROOT.join('spec', 'fixtures', 'list_order_items.xml') }

  before do
    allow(Spree::PaymentMethod).to receive(:find_by).with(type: 'Spree::Gateway::AmazonMFN').and_return(payment_method)
  end

  describe "#get_order" do
    subject { super().get_order('a1b2c4d5') }
    before do
      Excon.stub({ url: client.aws_endpoint, method: :post }, { body: get_order_file, status: 200, headers: { 'Content-Type' => 'text/xml' } })
    end
    it { is_expected.to be_a Peddler::XMLResponseParser }
  end

  describe "#list_orders" do
    before do
      Excon.stub({ url: client.aws_endpoint, method: :post }, { body: list_orders_file, status: 200, headers: { 'Content-Type' => 'text/xml' } })
    end
    let(:time) { 1.day.ago }
    let(:list_orders) { orders.list_orders(created_after: time) }
    subject { list_orders }
    it { is_expected.to be_a Peddler::XMLResponseParser }
  end
end<commit_msg>spec updated to the current api<commit_after>require 'spec_helper'

RSpec.describe SpreeAmazonMws::Orders do
  subject(:orders) { SpreeAmazonMws::Orders.new }
  let(:payment_method) { FactoryGirl.create(:amazon_mfn_payment_method) }
  let(:client) { orders.send(:client) }
  let(:get_order_file) { File.read ENGINE_ROOT.join('spec', 'fixtures', 'get_order.xml') }
  let(:list_orders_file) { File.read ENGINE_ROOT.join('spec', 'fixtures', 'list_orders.xml') }
  let(:list_order_items_file) { File.read ENGINE_ROOT.join('spec', 'fixtures', 'list_order_items.xml') }

  before do
    allow(Spree::PaymentMethod).to receive(:find_by).with(type: 'Spree::Gateway::AmazonMFN').and_return(payment_method)
  end

  describe "#get_order" do
    subject { super().get_order('a1b2c4d5') }
    before do
      Excon.stub({ url: client.aws_endpoint, method: :post }, { body: get_order_file, status: 200, headers: { 'Content-Type' => 'text/xml' } })
    end
    it { is_expected.to be_a Peddler::XMLResponseParser }
  end

  describe "#get_orders" do
    before do
      Excon.stub({ url: client.aws_endpoint, method: :post }, { body: list_orders_file, status: 200, headers: { 'Content-Type' => 'text/xml' } })
    end
    let(:time) { 1.day.ago }
    let(:get_orders) { orders.get_orders(created_after: time) }
    subject { get_orders }
    it { is_expected.to be_a Peddler::XMLResponseParser }
  end

  describe "#get_order_items" do
    before do
      Excon.stub({ url: client.aws_endpoint, method: :post }, { body: list_order_items_file, status: 200, headers: { 'Content-Type' => 'text/xml' } })
    end
    let(:time) { 1.day.ago }
    let(:get_order_items) { orders.get_order_items(created_after: time) }
    subject { get_order_items }
    it { is_expected.to be_a Peddler::XMLResponseParser }
  end
end
{'fraction_non_alphanumeric': 0.14807813484562066, 'fraction_numerical': 0.008191556395715185, 'mean_word_length': 4.599647266313933, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 11}, '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': '3003785', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1115, 'n_words': 210}