Sha256: 783b1b10bb903cbe42cdec982b7e15392aa8aabaf682c882a10aab7cd5ec5301

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

# encoding: utf-8
require "spec_helper"

describe FastshopCatalog::CheckAvailabilityService do

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

  let(:order) do
    order = FastshopCatalog::Entity::Order.new
    order.contract_code = '1234567890'
    order.zip_code = '02029001'
    order.document = '73978898160'
    order.number = '1560'
    order.total_amount = "69.00"
    order_item = FastshopCatalog::Entity::OrderItem.new
    order_item.sku = 'IVIEP314RED'
    order_item.quantity = 1
    order_item.price = "69.00"
    order.items = [order_item]
    order
  end
  
  let(:order_fixture) do
    {"tns:dadosPedido"=>{"fas:Cep"=>"02029001", "fas:Contrato"=>"1234567890", "fas:Cpf"=>"73978898160", "fas:Itens"=>[{"fas:PedidoItensEntity"=>{"tns:Quantidade"=>1, "tns:Sku"=>"IVIEP314RED", "tns:ValorUnitario"=>"69.00"}}], "fas:Numero"=>"1560", "fas:ValorTotal"=>"69.00"}}
  end

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

  describe "check" do
    it "should check that the order is not available" do

      savon.expects(:retorna_dados).with(:message => order_fixture).returns(fixture)
      service = FastshopCatalog::CheckAvailabilityService.new
      expect{service.check(order)}.to raise_error(FastshopCatalog::ServiceException) do |e|
        expect(e.code).to eq(36)
        expect(e.description).to eq('Pedido indisponível')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fastshop_catalog-0.0.2 spec/fastshop_catalog/check_availability_service_spec.rb
fastshop_catalog-0.0.1 spec/fastshop_catalog/check_availability_service_spec.rb