Sha256: 7fc746e536214d0d71233fd14e7781545df0b650e24aefb1db9713c24416e3c6

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

require "test_helper"
# rake test TEST=test/business_central/object/aged_account_payable_test.rb

class BusinessCentral::Object::AgedAccountPayableTest < Minitest::Test
  def setup
    @company_id = '123456'
    @client = BusinessCentral::Client.new
    @aged_account_payable = @client.aged_account_payable(company_id: @company_id)
  end

  def test_find_all
    stub_request(:get, /agedAccountsPayable/)
      .to_return(
        status: 200, 
        body: {
          'value': [
            {
              name: 'vendor1'
            }
          ]
        }.to_json
      )

    
    response = @aged_account_payable.find_all
    assert_equal response.first[:name], 'vendor1'
  end

  def test_find_by_id
    test_id = '123'
    stub_request(:get, /agedAccountsPayable\(#{test_id}\)/)
      .to_return(
        status: 200, 
        body: {
          name: 'vendor2'
        }.to_json
      )

    response = @aged_account_payable.find_by_id(test_id)
    assert_equal response[:name], 'vendor2'
  end

  def test_create
    assert_raises BusinessCentral::NoSupportedMethod do
      @aged_account_payable.create({})
    end
  end

  def test_update
    assert_raises BusinessCentral::NoSupportedMethod do
      @aged_account_payable.update('123', {})
    end
  end

  def test_delete
    assert_raises BusinessCentral::NoSupportedMethod do
      @aged_account_payable.destroy('123')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
business-central-1.0.3 test/business_central/object/aged_account_payable_test.rb
business-central-1.0.2 test/business_central/object/aged_account_payable_test.rb
business-central-1.0.1 test/business_central/object/aged_account_payable_test.rb