Sha256: f72cc077a1eb49d996fa7b6044fc5bcbff20df391f839c44ef324d283965d0f3

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe AmoCRM::Resources::Stock do
  it 'should be loaded' do
    expect(AmoCRM::Resources::Stock).to be_a Class
  end

  let(:resource) { AmoCRM::Resources::Stock.new client: client }

  describe do
    it 'should get list' do
      expect(resource.send(:list_path)).to  eq "exchange/rest/stock/xml"
    end
  end

  describe 'listWithConsignments' do
    subject { resource.listWithConsignments }
    before do
      stub_stock_rest_with_consignments
    end
    it do
      expect(subject.count).to eq 879
    end

    context 'stock item' do
      subject { resource.listWithConsignments.first }

      it do
        expect(subject).to be_a AmoCRM::Entities::StockTO
      end

      it do
        expect(subject.consignmentName).to_not be_empty
      end

      it do
        expect(subject.consignmentUuid).to_not be_empty
      end
    end
  end

  describe 'no consignments' do
    let(:count) { 516 }
    subject { resource }

    before do
      stub_stock_rest
    end

    it do
      expect(subject.page.count).to eq count
    end

    it do
      expect(subject.all.count).to eq count
    end

    it do
      expect(subject.all.first).to be_a AmoCRM::Entities::StockTO
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amo_crm-0.2.2 spec/lib/amocrm/resources/stock_spec.rb