<commit_before>require 'spec_helper'

describe ZohoInvoice::Invoice do

  describe "searching by customer" do
    before do
      @client = ZohoInvoice::Client.new(default_credentials)
    end

    it "should return an array if a customer has a single invoice" do
      invoice_test('/api/view/invoices/customer/1234', 'successful_single_customer_response', 1, /Draft|Open|Closed|Overdue|Void/, :find_by_customer_id, @client, '1234')
    end

    it "should return an array if a customer has multiple invoices" do
      invoice_test('/api/view/invoices/customer/1234', 'successful_multiple_customer_response', 2, /Draft|Open|Closed|Overdue|Void/, :find_by_customer_id, @client, '1234')
    end

    it "should return an empty array if a customer doesn't have any invoices" do
      invoice_test('/api/view/invoices/customer/1234', 'successful_empty_customer_response', 0, //, :find_by_customer_id, @client, '1234')
    end

    it "should return an error if theres an error" do
      error_test('/api/view/invoices/customer/1234', '500_internal_server_error', :find_by_customer_id, 'Invalid value passed for XMLString', '2', '0', 500, @client, '1234')
    end

    it "should return a hash if multiple customers are searched for" do
      multiple_invoice_test('invoice_array', 2, :find_by_multiple_customer_ids, :find_by_customer_id, @client, [1234, 5678])
    end
  end

  describe "searching by customer (unpaid)" do
    before do
      @client = ZohoInvoice::Client.new(default_credentials)
    end

    it "should return an array if a customer has a single unpaid invoice" do
      invoice_test('/api/view/invoices/unpaid/customer/1234', 'successful_unpaid_single_customer_response', 1, /Open|Overdue/, :find_unpaid_by_customer_id, @client, '1234')
    end

    it "should return an array if a customer has multiple unpaid invoices" do
      invoice_test('/api/view/invoices/unpaid/customer/1234', 'successful_unpaid_multiple_customer_response', 2, /Open|Overdue/, :find_unpaid_by_customer_id, @client, '1234')
    end

    it "should return an empty array if a customer doesn't have any unpaid invoices" do
      invoice_test('/api/view/invoices/unpaid/customer/1234', 'successful_unpaid_empty_customer_response', 0, //, :find_unpaid_by_customer_id, @client, '1234')
    end

    it "should return an error if theres an error" do
      error_test('/api/view/invoices/unpaid/customer/1234', '500_internal_server_error', :find_unpaid_by_customer_id, 'Invalid value passed for XMLString', '2', '0', 500, @client, '1234')
    end

     it "should return a hash if multiple customers are searched for" do
      multiple_invoice_test('invoice_array', 2, :find_unpaid_by_multiple_customer_ids, :find_unpaid_by_customer_id, @client, [1234, 5678])
    end
  end

end<commit_msg>Fixed tests.<commit_after>require 'spec_helper'

describe ZohoInvoice::Invoice do

  describe "searching by customer" do
    before do
      @client = ZohoInvoice::Client.new(default_credentials)
    end

    it "should return an array if a customer has a single invoice" do
      invoice_test('/api/invoices/customer/1234', 'successful_single_customer_response', 1, /Draft|Open|Closed|Overdue|Void/, :find_by_customer_id, @client, '1234')
    end

    it "should return an array if a customer has multiple invoices" do
      invoice_test('/api/invoices/customer/1234', 'successful_multiple_customer_response', 2, /Draft|Open|Closed|Overdue|Void/, :find_by_customer_id, @client, '1234')
    end

    it "should return an empty array if a customer doesn't have any invoices" do
      invoice_test('/api/invoices/customer/1234', 'successful_empty_customer_response', 0, //, :find_by_customer_id, @client, '1234')
    end

    it "should return an error if theres an error" do
      error_test('/api/invoices/customer/1234', '500_internal_server_error', :find_by_customer_id, 'Invalid value passed for XMLString', '2', '0', 500, @client, '1234')
    end

    it "should return a hash if multiple customers are searched for" do
      multiple_invoice_test('invoice_array', 2, :find_by_multiple_customer_ids, :find_by_customer_id, @client, [1234, 5678])
    end
  end

  describe "searching by customer (unpaid)" do
    before do
      @client = ZohoInvoice::Client.new(default_credentials)
    end

    it "should return an array if a customer has a single unpaid invoice" do
      invoice_test('/api/invoices/unpaid/customer/1234', 'successful_unpaid_single_customer_response', 1, /Open|Overdue/, :find_unpaid_by_customer_id, @client, '1234')
    end

    it "should return an array if a customer has multiple unpaid invoices" do
      invoice_test('/api/invoices/unpaid/customer/1234', 'successful_unpaid_multiple_customer_response', 2, /Open|Overdue/, :find_unpaid_by_customer_id, @client, '1234')
    end

    it "should return an empty array if a customer doesn't have any unpaid invoices" do
      invoice_test('/api/invoices/unpaid/customer/1234', 'successful_unpaid_empty_customer_response', 0, //, :find_unpaid_by_customer_id, @client, '1234')
    end

    it "should return an error if theres an error" do
      error_test('/api/invoices/unpaid/customer/1234', '500_internal_server_error', :find_unpaid_by_customer_id, 'Invalid value passed for XMLString', '2', '0', 500, @client, '1234')
    end

     it "should return a hash if multiple customers are searched for" do
      multiple_invoice_test('invoice_array', 2, :find_unpaid_by_multiple_customer_ids, :find_unpaid_by_customer_id, @client, [1234, 5678])
    end
  end

end
{'fraction_non_alphanumeric': 0.10364857505899437, 'fraction_numerical': 0.03775639862043928, 'mean_word_length': 4.582573454913881, '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': '5811092', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1739, 'n_words': 488}