fastshop_catalog 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +52 -0
- data/LICENSE.txt +22 -0
- data/README.md +69 -0
- data/Rakefile +5 -0
- data/fastshop_catalog.gemspec +25 -0
- data/lib/fastshop_catalog/base_entity.rb +30 -0
- data/lib/fastshop_catalog/base_service.rb +71 -0
- data/lib/fastshop_catalog/catalog_service.rb +17 -0
- data/lib/fastshop_catalog/check_availability_service.rb +23 -0
- data/lib/fastshop_catalog/crypto.rb +41 -0
- data/lib/fastshop_catalog/entity/address.rb +30 -0
- data/lib/fastshop_catalog/entity/business_unity.rb +9 -0
- data/lib/fastshop_catalog/entity/order.rb +12 -0
- data/lib/fastshop_catalog/entity/order_item.rb +7 -0
- data/lib/fastshop_catalog/entity/participant.rb +15 -0
- data/lib/fastshop_catalog/external_dne_service.rb +17 -0
- data/lib/fastshop_catalog/order_placement_service.rb +20 -0
- data/lib/fastshop_catalog/order_status_service.rb +18 -0
- data/lib/fastshop_catalog/participant_service.rb +20 -0
- data/lib/fastshop_catalog/product_service.rb +17 -0
- data/lib/fastshop_catalog/service_exception.rb +11 -0
- data/lib/fastshop_catalog/time.rb +15 -0
- data/lib/fastshop_catalog/version.rb +3 -0
- data/lib/fastshop_catalog.rb +20 -0
- data/password_util.rb +48 -0
- data/spec/.DS_Store +0 -0
- data/spec/fastshop_catalog/.DS_Store +0 -0
- data/spec/fastshop_catalog/base_service_spec.rb +44 -0
- data/spec/fastshop_catalog/catalog_service_spec.rb +43 -0
- data/spec/fastshop_catalog/check_availability_service_spec.rb +44 -0
- data/spec/fastshop_catalog/external_dne_service_spec.rb +60 -0
- data/spec/fastshop_catalog/integration/catalog_service_integration_spec.rb +15 -0
- data/spec/fastshop_catalog/integration/check_availability_service_integration_spec.rb +30 -0
- data/spec/fastshop_catalog/integration/external_dne_service_integration_spec.rb +12 -0
- data/spec/fastshop_catalog/integration/order_placement_service_integration_spec.rb +41 -0
- data/spec/fastshop_catalog/integration/order_status_service_integration_spec.rb +31 -0
- data/spec/fastshop_catalog/integration/participant_service_integration_spec.rb +34 -0
- data/spec/fastshop_catalog/integration/product_service_integration_spec.rb +23 -0
- data/spec/fastshop_catalog/order_placement_service_spec.rb +60 -0
- data/spec/fastshop_catalog/order_status_service_spec.rb +62 -0
- data/spec/fastshop_catalog/participant_factory.rb +40 -0
- data/spec/fastshop_catalog/participant_service_spec.rb +60 -0
- data/spec/fastshop_catalog/product_service_spec.rb +60 -0
- data/spec/fixtures/catalog_service_successful_response.xml +11 -0
- data/spec/fixtures/catalog_service_wrong_contract_response.xml +10 -0
- data/spec/fixtures/check_availability_not_available_response.xml +11 -0
- data/spec/fixtures/external_dne_service_successful_response.xml +11 -0
- data/spec/fixtures/external_dne_service_wrong_contract_response.xml +11 -0
- data/spec/fixtures/external_dne_service_wrong_zip_response.xml +11 -0
- data/spec/fixtures/order_placement_cart_not_identified.xml +11 -0
- data/spec/fixtures/order_placement_successful_delivery_payload.json +4 -0
- data/spec/fixtures/order_placement_successful_payload.json +1 -0
- data/spec/fixtures/order_status_service_order_not_found_response.xml +11 -0
- data/spec/fixtures/order_status_service_successful_response.xml +11 -0
- data/spec/fixtures/participant_service_successful_response.xml +11 -0
- data/spec/fixtures/participant_service_successful_token_response.xml +11 -0
- data/spec/fixtures/participant_successful_payload.json +1 -0
- data/spec/fixtures/product_service_successful_response.xml +11 -0
- data/spec/fixtures/product_service_wrong_contract_response.xml +11 -0
- data/spec/fixtures/product_service_wrong_sku_response.xml +11 -0
- data/spec/spec_helper.rb +10 -0
- data/wsdls/catalog.wsdl +49 -0
- data/wsdls/participante.wsdl +52 -0
- metadata +202 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe FastshopCatalog::ProductService do
|
5
|
+
|
6
|
+
include Savon::SpecHelper
|
7
|
+
before(:all) { savon.mock! }
|
8
|
+
after(:all) { savon.unmock! }
|
9
|
+
|
10
|
+
let(:contract_number) do
|
11
|
+
"1234567890"
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:service) do
|
15
|
+
service = FastshopCatalog::ProductService.new
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:sku) do
|
19
|
+
'A5IMT237'
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:fixture) do
|
23
|
+
File.read("spec/fixtures/product_service_successful_response.xml")
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:fixture_wrong_contract) do
|
27
|
+
File.read("spec/fixtures/product_service_wrong_contract_response.xml")
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:fixture_wrong_sku) do
|
31
|
+
File.read("spec/fixtures/product_service_wrong_sku_response.xml")
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "search" do
|
35
|
+
|
36
|
+
it "should return the list with the expected size" do
|
37
|
+
savon.expects(:busca_produto).with(:message => {'tns:contrato' => contract_number, 'tns:sku' => sku }).returns(fixture)
|
38
|
+
result = service.search(contract_number, sku)
|
39
|
+
expect(result['Nome']).to eq("Alto Falante Ultra Portátil Prata - Altec Lansing - IMT237 ")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return wrong contract exception" do
|
43
|
+
savon.expects(:busca_produto).with(:message => {'tns:contrato' => 'lixo', 'tns:sku' => sku}).returns(fixture_wrong_contract)
|
44
|
+
expect{service.search('lixo', sku)}.to raise_error(FastshopCatalog::ServiceException) do |e|
|
45
|
+
expect(e.code).to eq(2)
|
46
|
+
expect(e.description).to eq('Contrato invalido')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return wrong sku exception" do
|
51
|
+
savon.expects(:busca_produto).with(:message => {'tns:contrato' => 'lixo', 'tns:sku' => sku}).returns(fixture_wrong_sku)
|
52
|
+
expect{service.search('lixo', sku)}.to raise_error(FastshopCatalog::ServiceException) do |e|
|
53
|
+
expect(e.code).to eq(43)
|
54
|
+
expect(e.description).to eq('Produto invalido')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|