correios-sro-xml 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/.gitignore +25 -0
  2. data/CHANGELOG.rdoc +14 -8
  3. data/Gemfile +1 -12
  4. data/README.rdoc +181 -35
  5. data/Rakefile +13 -35
  6. data/correios-sro-xml.gemspec +24 -80
  7. data/lib/correios-sro-xml.rb +4 -4
  8. data/lib/correios/sro.rb +11 -0
  9. data/lib/correios/sro/destination.rb +16 -0
  10. data/lib/correios/sro/event.rb +31 -0
  11. data/lib/correios/sro/object.rb +13 -0
  12. data/lib/correios/sro/parser.rb +5 -5
  13. data/lib/correios/sro/tracker.rb +43 -0
  14. data/lib/correios/sro/version.rb +1 -6
  15. data/lib/correios/sro/web_service.rb +64 -11
  16. data/misc/correios_sro_xml_manual_v1.5.pdf +0 -0
  17. data/spec/correios/sro/event_spec.rb +15 -0
  18. data/spec/correios/sro/parser_spec.rb +44 -44
  19. data/spec/correios/sro/tracker_spec.rb +116 -0
  20. data/spec/correios/sro/web_service_spec.rb +10 -4
  21. data/spec/correios/sro_spec.rb +22 -0
  22. data/spec/spec_helper.rb +3 -5
  23. data/spec/support/mock_request.rb +22 -0
  24. data/spec/support/responses/failure_response_not_found.xml +6 -0
  25. data/spec/support/responses/{success-response-many-objects.xml → success_response_many_objects.xml} +0 -0
  26. data/spec/support/responses/{success-response-many-objects-international.xml → success_response_many_objects_international.xml} +0 -0
  27. data/spec/support/responses/{success-response-one-object.xml → success_response_one_object.xml} +0 -0
  28. metadata +54 -59
  29. data/Gemfile.lock +0 -62
  30. data/lib/correios/sro/destino.rb +0 -16
  31. data/lib/correios/sro/evento.rb +0 -31
  32. data/lib/correios/sro/objeto.rb +0 -13
  33. data/lib/correios/sro/rastreador.rb +0 -43
  34. data/spec/correios/sro/evento_spec.rb +0 -15
  35. data/spec/correios/sro/rastreador_spec.rb +0 -53
  36. data/spec/support/fake_request.rb +0 -21
@@ -1,15 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- describe Correios::SRO::Evento do
5
- let(:evento) { Correios::SRO::Evento.new }
6
-
7
- [:recebedor, :documento, :comentario].each do |method|
8
- describe "##{method}=" do
9
- it "strips string" do
10
- evento.send("#{method}=", " Texto. ")
11
- evento.send(method).should == "Texto."
12
- end
13
- end
14
- end
15
- end
@@ -1,53 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- describe Correios::SRO::Rastreador do
5
- describe ".new" do
6
- context "creates with default value of" do
7
- before(:each) { @sro = Correios::SRO::Rastreador.new }
8
-
9
- { :tipo => :lista,
10
- :resultado => :ultimo,
11
- :objetos => []
12
- }.each do |attr, value|
13
- it attr do
14
- @sro.send(attr).should == value
15
- end
16
- end
17
- end
18
-
19
- { :usuario => "USUARIO",
20
- :senha => "SENHA",
21
- :tipo => :intervalo,
22
- :resultado => :todos
23
- }.each do |attr, value|
24
- context "when #{attr} is supplied" do
25
- it "sets #{attr}" do
26
- sro = Correios::SRO::Rastreador.new(attr => value)
27
- sro.send(attr).should == value
28
- end
29
- end
30
-
31
- context "when #{attr} is supplied in a block" do
32
- it "sets #{attr}" do
33
- sro = Correios::SRO::Rastreador.new { |f| f.send("#{attr}=", value) }
34
- sro.send(attr).should == value
35
- end
36
- end
37
- end
38
- end
39
-
40
- describe "#consultar" do
41
- before :each do
42
- fake_request_for :success_response_many_objects
43
- @sro = Correios::SRO::Rastreador.new :usuario => "USUARIO", :senha => "SENHA"
44
- end
45
-
46
- it "sets objetos" do
47
- @sro.consultar("SQ458226057B", "RA132678652BR")
48
- @sro.objetos.size.should == 2
49
- @sro.objetos.first.should == "SQ458226057B"
50
- @sro.objetos.last.should == "RA132678652BR"
51
- end
52
- end
53
- end
@@ -1,21 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- def fake_request_for(response)
4
- FakeWeb.register_uri(:post,
5
- Regexp.new("http://websro.correios.com.br/sro_bin/sroii_xml.eventos"),
6
- :status => 200,
7
- :body => body_for(response))
8
- end
9
-
10
- def body_for(response)
11
- case response
12
- when :success_response_one_object
13
- File.open(File.dirname(__FILE__) + "/responses/success-response-one-object.xml").read
14
- when :success_response_many_objects
15
- File.open(File.dirname(__FILE__) + "/responses/success-response-many-objects.xml").read
16
- when :success_response_many_objects_international
17
- File.open(File.dirname(__FILE__) + "/responses/success-response-many-objects-international.xml").read
18
- else
19
- response
20
- end
21
- end