Sha256: 0a570202442dca39e95ec18fe44b17efa84803d57e0f96051db9085f872f822a

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require "spec_helper"

describe FastshopCatalog::CatalogService do

  include Savon::SpecHelper
  before(:all) { savon.mock! }
  after(:all)  { savon.unmock! }

  let(:contract_number) do
    "1234567890"
  end
  
  let(:service) do
    service = FastshopCatalog::CatalogService.new
  end

  let(:fixture) do
    File.read("spec/fixtures/catalog_service_successful_response.xml")
  end

  let(:fixture_wrong_contract) do
    File.read("spec/fixtures/catalog_service_wrong_contract_response.xml")
  end

  describe "search" do

    it "should return the list with the expected size" do
      savon.expects(:busca_catalogo).with(:message => {'tns:contrato' => contract_number}).returns(fixture)
      result = service.search(contract_number)
      expect(result.length).to eq(866)
    end

    it "should return wrong contract exception" do
      savon.expects(:busca_catalogo).with(:message => {'tns:contrato' => 'lixo'}).returns(fixture_wrong_contract)
      expect{service.search('lixo')}.to raise_error(FastshopCatalog::ServiceException) do |e|
        expect(e.code).to eq(2)
        expect(e.description).to eq('Contrato invalido')
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fastshop_catalog-0.0.1 spec/fastshop_catalog/catalog_service_spec.rb