Sha256: df18de241300f0f7b0c69a754b38334cf62be288fa35eeae71b13dbfd5e3873f

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

describe Moysklad::Entities::Good do
  let(:good_uuid) { 'eb77ad57-2e22-11e4-4030-002590a28eca' }

  let(:raw_response) { File.new "./spec/fixtures/Good_#{good_uuid}.raw" }
  let(:raw_features_list_response) { File.new "./spec/fixtures/Feature_list.raw" }

  before do
    stub_request(:get, "https://online.moysklad.ru/exchange/rest/ms/xml/Good/#{good_uuid}").to_return(raw_response)
    stub_request(:get, "https://online.moysklad.ru/exchange/rest/ms/xml/Feature/list?start=0").to_return(raw_features_list_response)
  end

  let(:goods_resource) { Moysklad::Resources::Goods.indexed client: client }
  let(:good) { goods_resource.get good_uuid }

  describe 'features' do
    let(:features) { good.features universe }

    it do
      expect(features).to be_a Array
      expect(features.count).to eq 3
    end

    context do
      subject { features.first }
      it do
        expect(subject).to be_a Moysklad::Entities::Feature
      end
    end
  end

  it 'to_xml' do
    expect(subject.to_xml).to be_a String
    expect(subject.to_xml).to include "<?xml"
    expect(subject.to_xml).to include "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
  end

  describe 'attribute' do
    it do
      expect(good.attributes).to be_a Array
      expect(good.attributes.first).to be_a Moysklad::Entities::Attribute
    end
  end

  describe 'image' do
    let(:xml) { File.read './spec/fixtures/good_with_image.xml' }
    subject { described_class.parse xml }

    it do
      expect(subject.images.image.count).to eq 1
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moysklad-0.3.0 spec/lib/moysklad/entities/good_spec.rb