Sha256: a38680a3409ba1008e13a20eb334417c9f5059438d05e3805367337fc8bb6a94

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

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

  let(:resource) { Moysklad::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 Moysklad::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 Moysklad::Entities::StockTO
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
moysklad-0.3.0 spec/lib/moysklad/resources/stock_spec.rb
moysklad-0.2.1 spec/lib/moysklad/resources/stock_spec.rb
moysklad-0.2.0 spec/lib/moysklad/resources/stock_spec.rb
moysklad-0.1.5 spec/lib/moysklad/resources/stock_spec.rb
moysklad-0.1.4 spec/lib/moysklad/resources/stock_spec.rb
moysklad-0.1.3 spec/lib/moysklad/resources/stock_spec.rb