savon-multipart 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a46264c37ca1a22ed9ef5e852dbbedeee173de2
4
- data.tar.gz: de5f926dde79583c307d768ddad351fc4881c17a
3
+ metadata.gz: 5b2646fc41ff720bd7228d8c05f4300972e64686
4
+ data.tar.gz: 885ce75c4025dd8e64ee5fe7a430599caf534049
5
5
  SHA512:
6
- metadata.gz: 908ce3d97c78d5eb4d64fe30f863dd6b4f4f17867375e2e5b918ab9193fab6c993f637dc83151329605a17557279c7b902e83f7115e4c221620a4f94e1e30887
7
- data.tar.gz: 52126a00b9e7197b16bb862582e7a434d1502a6076475b06669e82be5fdb72b2f271d38dcb527eb666f1dcbbfda8167c1c0964a71a16cf312f1d38af39d07b39
6
+ metadata.gz: fb7660f083792e8452663715fdd6624bbf1d01cab3469e72b12ff6b9146de5660d0a976b6f9df9f2c4f4c5e69b508b5efcbf38aeb96be6ea37b88ba560c0de9b
7
+ data.tar.gz: b7496671d6a550a9d9ae0c079f5bce6ae45371dd1141a1925698749a3a3552fecf8dd5b23d58015e928069520eb3297d9756b53b392f578bd9f3a6c828c48649
data/.travis.yml CHANGED
@@ -3,7 +3,8 @@ language: "ruby"
3
3
  script: "bundle exec rake"
4
4
  rvm:
5
5
  - 1.9.3
6
- - 2.0.0
6
+ - 2.0
7
7
  - 2.1
8
+ - 2.2
8
9
  - jruby-19mode
9
10
  - rbx-2
data/CHANGELOG.md CHANGED
@@ -1,12 +1,18 @@
1
- ## 0.9.7
1
+ ## 2.1.0 (current)
2
2
 
3
- * Initial version. Adds multipart support (SOAP with Attachments) to Savon v0.9.7.
4
- Please test and provide feedback so we can merge this into Savon proper.
3
+ * Drops support for ruby 1.8.7
4
+
5
+ ## 2.0.2
6
+ * Removes hardcoded version lock on Mail gem
5
7
 
6
8
  ## 2.0.0
7
9
  * Rewrite of savon-multipart to work with Savon 2.0+
8
10
  This includes all of the existing functionality in savon-multipart
9
11
  for savon1, but in a way that will be easier to maintain.
10
12
 
11
- # 2.0.2 (Current)
12
- * Removes hardcoded version lock on Mail gem
13
+ ## 0.9.7
14
+
15
+ * Initial version. Adds multipart support (SOAP with Attachments) to Savon v0.9.7.
16
+ Please test and provide feedback so we can merge this into Savon proper.
17
+
18
+
data/README.md CHANGED
@@ -4,25 +4,20 @@ Savon Multipart [![Build Status](https://secure.travis-ci.org/savonrb/savon-mult
4
4
  Adds multipart support (SOAP with Attachments) to [Savon](https://github.com/savonrb/savon).
5
5
  Please test and provide feedback so we can support as many multipart-soap messages as possible.
6
6
 
7
+ Installation
8
+ ------------
7
9
 
8
- Savon2
9
- ------
10
-
11
- Recently Savon launched a rewrite that broke compatibility with savon-multipart. If you're using savon
12
- version 1, this should just work, but if you'd like to use Savon2, you will probably want to specify
13
- something like this in your Gemfile
14
-
10
+ Savon Multipart is available through [Rubygems](http://rubygems.org/gems/savon-multipart) and can be installed via:
15
11
 
16
12
  ```
17
- gem 'savon-multipart', :git => 'https://github.com/tjarratt/savon-multipart.git', :branch => 'savon2'
13
+ $ gem install savon-multipart
18
14
  ```
19
15
 
20
-
21
- Installation
16
+ Usage
22
17
  ------------
23
18
 
24
- Savon Multipart is available through [Rubygems](http://rubygems.org/gems/savon-multipart) and can be installed via:
19
+ Just require the gem 'savon-multipart', which automatically requires 'savon' as well:
25
20
 
26
21
  ```
27
- $ gem install savon-multipart
22
+ require 'savon-multipart'
28
23
  ```
@@ -1,5 +1,5 @@
1
1
  module Savon
2
2
  module Multipart
3
- VERSION = "2.0.2"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "http://savonrb.com"
12
12
  s.summary = "Heavy metal Ruby SOAP client with multipart support"
13
13
  s.description = "Adds multipart support (SOAP with Attachments) to Savon"
14
+ s.required_ruby_version = '>= 1.9.2'
14
15
 
15
16
  s.rubyforge_project = s.name
16
17
 
@@ -0,0 +1,7 @@
1
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
2
+ Content-Type: text/xml; charset=UTF-8
3
+ Content-Transfer-Encoding: binary
4
+ Content-ID: <0.1bccd0fe5cc64dd5b5910cd3cc23a762332ffb50bdd8fe1b@apache.org>
5
+
6
+ <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault xmlns:axis2ns1="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>axis2ns1:Client</faultcode><faultstring>The service cannot be found for the endpoint reference (EPR) http://110.74.218.219:8080/EngineWS/services/SoapGWAppImp.SoapGWAppImpHttpSoap12Endpoint/</faultstring><detail /></soapenv:Fault></soapenv:Body></soapenv:Envelope>
7
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
@@ -2,70 +2,73 @@ require 'savon-multipart'
2
2
 
3
3
  describe Savon::Multipart::Response do
4
4
 
5
- before do
6
- @header = { "Content-Type" => 'multipart/related; boundary="--==_mimepart_4d416ae62fd32_201a8043814c4724"; charset=UTF-8; type="text/xml"' }
7
- path = File.expand_path("../../../fixtures/response/multipart.txt", __FILE__)
8
- raise ArgumentError, "Unable to load: #{path}" unless File.exist? path
9
- @body = File.read(path)
10
- end
5
+ let(:header) {{ "Content-Type" => 'multipart/related; boundary="--==_mimepart_4d416ae62fd32_201a8043814c4724"; charset=UTF-8; type="text/xml"' }}
6
+ let(:body) { File.read(path) }
7
+ let(:response) { soap_response(:headers => header, :body => body) }
11
8
 
12
- it "parses without Exception" do
13
- response = soap_response :headers => @header, :body => @body
14
- expect(response.xml.strip).to eq('<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:wsdl="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns1:TransactionID soapenv:actor="" soapenv:mustUnderstand="1" xsi:type="xsd:string" xmlns:ns1="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">2011012713535811111111111</ns1:TransactionID></soapenv:Header><soapenv:Body><SubmitReq xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2"><MM7Version>5.3.0</MM7Version><SenderIdentification><VASPID>messaging</VASPID><VASID>ADM</VASID><SenderAddress><ShortCode>1111</ShortCode></SenderAddress></SenderIdentification><Recipients><To><Number>11111111111</Number></To></Recipients><ServiceCode>1</ServiceCode><MessageClass>Personal</MessageClass><ExpiryDate>2011-01-28T13:53:58Z</ExpiryDate><DeliveryReport>false</DeliveryReport><ReadReply>false</ReadReply><Priority>Normal</Priority><Subject>Test MMS via Savon</Subject><ChargedParty>Sender</ChargedParty><Content href="cid:attachment_1" allowAdaptations="true"/></SubmitReq></soapenv:Body></soapenv:Envelope>')
15
- expect(response.parts.length).to eq(2)
16
- expect(response.parts[1].parts.length).to eq(3)
17
- expect(response.parts[1].parts[2].body.decoded.strip).to eq("This is a test message from Github")
18
- end
9
+ def soap_response(options = {})
10
+ defaults = { :code => 200, :headers => {}, :body => "" }
11
+ response = defaults.merge options
12
+ globals = {
13
+ :multipart => true,
14
+ :raise_errors => true,
15
+ :convert_response_tags_to => lambda { |tag| tag.snakecase.to_sym}
16
+ }
17
+ http = HTTPI::Response.new(response[:code], response[:headers], response[:body])
19
18
 
20
- it "returns a String from the #xml method" do
21
- body = File.read(File.expand_path('../../../fixtures/response/simple_multipart.txt', __FILE__))
22
- response = soap_response :headers => @header, :body => body
23
- expect(response.xml.class).to eq(String)
19
+ Savon::Multipart::Response.new(http, globals, {})
24
20
  end
25
21
 
26
- it "returns a Hash from the #body method" do
27
- body = File.read(File.expand_path('../../../fixtures/response/simple_multipart.txt', __FILE__))
28
- response = soap_response :headers => @header, :body => body
29
- expect(response.body.class).to eq(Hash)
30
- expect(response.body).to eq({:submit_req => true})
31
- end
22
+ context "multipart" do
23
+ let(:path) { File.expand_path("../../../fixtures/response/multipart.txt", __FILE__) }
32
24
 
33
- it "returns the attachments" do
34
- response = soap_response :headers => @header, :body => @body
35
- expect(response.attachments.size).to eq(1)
36
- end
25
+ it "parses without Exception" do
26
+ expect(response.xml.strip).to eq('<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:wsdl="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns1:TransactionID soapenv:actor="" soapenv:mustUnderstand="1" xsi:type="xsd:string" xmlns:ns1="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">2011012713535811111111111</ns1:TransactionID></soapenv:Header><soapenv:Body><SubmitReq xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2"><MM7Version>5.3.0</MM7Version><SenderIdentification><VASPID>messaging</VASPID><VASID>ADM</VASID><SenderAddress><ShortCode>1111</ShortCode></SenderAddress></SenderIdentification><Recipients><To><Number>11111111111</Number></To></Recipients><ServiceCode>1</ServiceCode><MessageClass>Personal</MessageClass><ExpiryDate>2011-01-28T13:53:58Z</ExpiryDate><DeliveryReport>false</DeliveryReport><ReadReply>false</ReadReply><Priority>Normal</Priority><Subject>Test MMS via Savon</Subject><ChargedParty>Sender</ChargedParty><Content href="cid:attachment_1" allowAdaptations="true"/></SubmitReq></soapenv:Body></soapenv:Envelope>')
27
+ expect(response.parts.length).to eq(2)
28
+ expect(response.parts[1].parts.length).to eq(3)
29
+ expect(response.parts[1].parts[2].body.decoded.strip).to eq("This is a test message from Github")
30
+ end
37
31
 
38
- it "parses soap messages without attachments too" do
39
- header = { 'Content-Type' => 'text/html; charset=utf-8'}
40
- body = File.read(File.expand_path('../../../fixtures/response/not_multipart.txt', __FILE__))
41
- response = soap_response :headers => header, :body => body
32
+ it "returns the attachments" do
33
+ expect(response.attachments.size).to eq(1)
34
+ end
42
35
 
43
- expect(response.xml.chomp).to eq('<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:wsdl="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns1:TransactionID soapenv:actor="" soapenv:mustUnderstand="1" xsi:type="xsd:string" xmlns:ns1="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">2011012713535811111111111</ns1:TransactionID></soapenv:Header><soapenv:Body><SubmitReq xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2"><MM7Version>5.3.0</MM7Version><SenderIdentification><VASPID>messaging</VASPID><VASID>ADM</VASID><SenderAddress><ShortCode>1111</ShortCode></SenderAddress></SenderIdentification><Recipients><To><Number>11111111111</Number></To></Recipients><ServiceCode>1</ServiceCode><MessageClass>Personal</MessageClass><ExpiryDate>2011-01-28T13:53:58Z</ExpiryDate><DeliveryReport>false</DeliveryReport><ReadReply>false</ReadReply><Priority>Normal</Priority><Subject>Test MMS via Savon</Subject><ChargedParty>Sender</ChargedParty><Content href="cid:attachment_1" allowAdaptations="true"/></SubmitReq></soapenv:Body></soapenv:Envelope>')
44
- expect(response.parts.size).to eq(0)
45
- expect(response.attachments.size).to eq(0)
36
+ it "only parses the SOAP body once" do
37
+ Mail::Part.stub(:new).and_return(double(Mail::Part).as_null_object)
38
+ expect(Mail::Part).to receive(:new).exactly(1).times
39
+ 5.times { response.attachments }
40
+ end
46
41
  end
47
42
 
48
- it "only parses the SOAP body once" do
49
- response = soap_response :headers => @header, :body => @body
50
- response.xml
43
+ context "simple multipart" do
44
+ let(:path) { File.expand_path('../../../fixtures/response/simple_multipart.txt', __FILE__) }
51
45
 
52
- counter = 0
53
- subbed_parse_body = lambda { counter += 1 }
54
- response.class.send(:define_method, :parse_body, subbed_parse_body)
55
- 5.times { response.attachments }
46
+ it "returns a String from the #xml method" do
47
+ expect(response.xml.class).to eq(String)
48
+ end
56
49
 
57
- expect(counter).to eq(0)
50
+ it "returns a Hash from the #body method" do
51
+ expect(response.body.class).to eq(Hash)
52
+ expect(response.body).to eq({:submit_req => true})
53
+ end
58
54
  end
59
55
 
60
- def soap_response(options = {})
61
- defaults = { :code => 200, :headers => {}, :body => "" }
62
- response = defaults.merge options
63
- globals = {
64
- :multipart => true,
65
- :convert_response_tags_to => lambda { |tag| tag.snakecase.to_sym}
66
- }
67
- http = HTTPI::Response.new(response[:code], response[:headers], response[:body])
56
+ context "not multipart" do
57
+ let(:path) { File.expand_path('../../../fixtures/response/not_multipart.txt', __FILE__) }
58
+ let(:header) { { 'Content-Type' => 'text/html; charset=utf-8'} }
68
59
 
69
- Savon::Multipart::Response.new(http, globals, {})
60
+ it "parses soap messages without attachments too" do
61
+ expect(response.xml.chomp).to eq('<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:wsdl="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns1:TransactionID soapenv:actor="" soapenv:mustUnderstand="1" xsi:type="xsd:string" xmlns:ns1="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">2011012713535811111111111</ns1:TransactionID></soapenv:Header><soapenv:Body><SubmitReq xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2"><MM7Version>5.3.0</MM7Version><SenderIdentification><VASPID>messaging</VASPID><VASID>ADM</VASID><SenderAddress><ShortCode>1111</ShortCode></SenderAddress></SenderIdentification><Recipients><To><Number>11111111111</Number></To></Recipients><ServiceCode>1</ServiceCode><MessageClass>Personal</MessageClass><ExpiryDate>2011-01-28T13:53:58Z</ExpiryDate><DeliveryReport>false</DeliveryReport><ReadReply>false</ReadReply><Priority>Normal</Priority><Subject>Test MMS via Savon</Subject><ChargedParty>Sender</ChargedParty><Content href="cid:attachment_1" allowAdaptations="true"/></SubmitReq></soapenv:Body></soapenv:Envelope>')
62
+ expect(response.parts.size).to eq(0)
63
+ expect(response.attachments.size).to eq(0)
64
+ end
65
+ end
66
+
67
+ context "soap errors" do
68
+ let(:path) { File.expand_path('../../../fixtures/response/soap_fault.txt', __FILE__) }
69
+
70
+ it "handles them correctly" do
71
+ expect { response }.to raise_error(Savon::SOAPFault, /The service cannot be found/)
72
+ end
70
73
  end
71
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon-multipart
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Westin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-09 00:00:00.000000000 Z
12
+ date: 2015-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -132,6 +132,7 @@ files:
132
132
  - spec/fixtures/response/multipart.txt
133
133
  - spec/fixtures/response/not_multipart.txt
134
134
  - spec/fixtures/response/simple_multipart.txt
135
+ - spec/fixtures/response/soap_fault.txt
135
136
  - spec/savon/soap/response_spec.rb
136
137
  homepage: http://savonrb.com
137
138
  licenses: []
@@ -144,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
145
  requirements:
145
146
  - - ">="
146
147
  - !ruby/object:Gem::Version
147
- version: '0'
148
+ version: 1.9.2
148
149
  required_rubygems_version: !ruby/object:Gem::Requirement
149
150
  requirements:
150
151
  - - ">="