Sha256: c5823c21ffd6c1eff04c91d3d330b446ff807959d80ac68bff27abe582eb24c9

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 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 = "249.00"
    order_item = FastshopCatalog::Entity::OrderItem.new
    order_item.sku = 'SODPFC70A'
    order_item.quantity = 1
    order_item.price = "249.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"=>{"fas:Quantidade"=>1, "fas:Sku"=>"SODPFC70A", "fas:ValorUnitario"=>"249.00"}}], "fas:Numero"=>"1560", "fas:ValorTotal"=>"249.00"}}
  end

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

  describe "check" do
    it "should check that the order is ok" do

      savon.expects(:retorna_dados).with(:message => order_fixture).returns(fixture)
      service = FastshopCatalog::CheckAvailabilityService.new
      result = service.check(order)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fastshop_catalog-0.0.3 spec/fastshop_catalog/check_availability_service_spec.rb