fastshop_catalog 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +20 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +52 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +69 -0
  8. data/Rakefile +5 -0
  9. data/fastshop_catalog.gemspec +25 -0
  10. data/lib/fastshop_catalog/base_entity.rb +30 -0
  11. data/lib/fastshop_catalog/base_service.rb +71 -0
  12. data/lib/fastshop_catalog/catalog_service.rb +17 -0
  13. data/lib/fastshop_catalog/check_availability_service.rb +23 -0
  14. data/lib/fastshop_catalog/crypto.rb +41 -0
  15. data/lib/fastshop_catalog/entity/address.rb +30 -0
  16. data/lib/fastshop_catalog/entity/business_unity.rb +9 -0
  17. data/lib/fastshop_catalog/entity/order.rb +12 -0
  18. data/lib/fastshop_catalog/entity/order_item.rb +7 -0
  19. data/lib/fastshop_catalog/entity/participant.rb +15 -0
  20. data/lib/fastshop_catalog/external_dne_service.rb +17 -0
  21. data/lib/fastshop_catalog/order_placement_service.rb +20 -0
  22. data/lib/fastshop_catalog/order_status_service.rb +18 -0
  23. data/lib/fastshop_catalog/participant_service.rb +20 -0
  24. data/lib/fastshop_catalog/product_service.rb +17 -0
  25. data/lib/fastshop_catalog/service_exception.rb +11 -0
  26. data/lib/fastshop_catalog/time.rb +15 -0
  27. data/lib/fastshop_catalog/version.rb +3 -0
  28. data/lib/fastshop_catalog.rb +20 -0
  29. data/password_util.rb +48 -0
  30. data/spec/.DS_Store +0 -0
  31. data/spec/fastshop_catalog/.DS_Store +0 -0
  32. data/spec/fastshop_catalog/base_service_spec.rb +44 -0
  33. data/spec/fastshop_catalog/catalog_service_spec.rb +43 -0
  34. data/spec/fastshop_catalog/check_availability_service_spec.rb +44 -0
  35. data/spec/fastshop_catalog/external_dne_service_spec.rb +60 -0
  36. data/spec/fastshop_catalog/integration/catalog_service_integration_spec.rb +15 -0
  37. data/spec/fastshop_catalog/integration/check_availability_service_integration_spec.rb +30 -0
  38. data/spec/fastshop_catalog/integration/external_dne_service_integration_spec.rb +12 -0
  39. data/spec/fastshop_catalog/integration/order_placement_service_integration_spec.rb +41 -0
  40. data/spec/fastshop_catalog/integration/order_status_service_integration_spec.rb +31 -0
  41. data/spec/fastshop_catalog/integration/participant_service_integration_spec.rb +34 -0
  42. data/spec/fastshop_catalog/integration/product_service_integration_spec.rb +23 -0
  43. data/spec/fastshop_catalog/order_placement_service_spec.rb +60 -0
  44. data/spec/fastshop_catalog/order_status_service_spec.rb +62 -0
  45. data/spec/fastshop_catalog/participant_factory.rb +40 -0
  46. data/spec/fastshop_catalog/participant_service_spec.rb +60 -0
  47. data/spec/fastshop_catalog/product_service_spec.rb +60 -0
  48. data/spec/fixtures/catalog_service_successful_response.xml +11 -0
  49. data/spec/fixtures/catalog_service_wrong_contract_response.xml +10 -0
  50. data/spec/fixtures/check_availability_not_available_response.xml +11 -0
  51. data/spec/fixtures/external_dne_service_successful_response.xml +11 -0
  52. data/spec/fixtures/external_dne_service_wrong_contract_response.xml +11 -0
  53. data/spec/fixtures/external_dne_service_wrong_zip_response.xml +11 -0
  54. data/spec/fixtures/order_placement_cart_not_identified.xml +11 -0
  55. data/spec/fixtures/order_placement_successful_delivery_payload.json +4 -0
  56. data/spec/fixtures/order_placement_successful_payload.json +1 -0
  57. data/spec/fixtures/order_status_service_order_not_found_response.xml +11 -0
  58. data/spec/fixtures/order_status_service_successful_response.xml +11 -0
  59. data/spec/fixtures/participant_service_successful_response.xml +11 -0
  60. data/spec/fixtures/participant_service_successful_token_response.xml +11 -0
  61. data/spec/fixtures/participant_successful_payload.json +1 -0
  62. data/spec/fixtures/product_service_successful_response.xml +11 -0
  63. data/spec/fixtures/product_service_wrong_contract_response.xml +11 -0
  64. data/spec/fixtures/product_service_wrong_sku_response.xml +11 -0
  65. data/spec/spec_helper.rb +10 -0
  66. data/wsdls/catalog.wsdl +49 -0
  67. data/wsdls/participante.wsdl +52 -0
  68. 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