savon 0.6.7 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. data/CHANGELOG +17 -4
  2. data/README.textile +14 -25
  3. data/Rakefile +7 -30
  4. data/lib/savon.rb +2 -1
  5. data/lib/savon/client.rb +13 -15
  6. data/lib/savon/core_ext.rb +1 -1
  7. data/lib/savon/core_ext/hash.rb +3 -6
  8. data/lib/savon/request.rb +26 -20
  9. data/lib/savon/soap.rb +33 -17
  10. data/lib/savon/wsdl.rb +19 -8
  11. data/spec/endpoint_helper.rb +14 -53
  12. data/spec/fixtures/response/response_fixture.rb +32 -0
  13. data/spec/fixtures/response/xml/authentication.xml +14 -0
  14. data/spec/fixtures/{soap_fault.xml → response/xml/soap_fault.xml} +0 -0
  15. data/spec/fixtures/{soap_fault12.xml → response/xml/soap_fault12.xml} +0 -0
  16. data/spec/fixtures/wsdl/wsdl_fixture.rb +37 -0
  17. data/spec/fixtures/wsdl/xml/authentication.xml +63 -0
  18. data/spec/fixtures/wsdl/xml/namespaced_actions.xml +307 -0
  19. data/spec/fixtures/wsdl/xml/no_namespace.xml +115 -0
  20. data/spec/http_stubs.rb +11 -11
  21. data/spec/savon/client_spec.rb +46 -41
  22. data/spec/savon/core_ext/datetime_spec.rb +2 -2
  23. data/spec/savon/core_ext/hash_spec.rb +10 -10
  24. data/spec/savon/core_ext/object_spec.rb +2 -2
  25. data/spec/savon/core_ext/string_spec.rb +2 -2
  26. data/spec/savon/core_ext/symbol_spec.rb +1 -1
  27. data/spec/savon/core_ext/uri_spec.rb +1 -1
  28. data/spec/savon/request_spec.rb +5 -3
  29. data/spec/savon/response_spec.rb +7 -7
  30. data/spec/savon/savon_spec.rb +3 -4
  31. data/spec/savon/soap_spec.rb +13 -5
  32. data/spec/savon/wsdl_spec.rb +63 -20
  33. data/spec/spec_helper.rb +3 -2
  34. metadata +16 -14
  35. data/VERSION +0 -1
  36. data/spec/fixtures/multiple_user_response.xml +0 -22
  37. data/spec/fixtures/user_fixture.rb +0 -62
  38. data/spec/fixtures/user_response.xml +0 -15
  39. data/spec/fixtures/user_wsdl.xml +0 -124
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe Savon::SOAP do
4
4
  before do
5
5
  @soap = Savon::SOAP.new
6
- @soap.action = UserFixture.operations[:find_user][:action]
6
+ @soap.action = WSDLFixture.authentication(:operations)[:authenticate][:action]
7
7
  end
8
8
 
9
9
  it "contains the SOAP namespace for each supported SOAP version" do
@@ -36,7 +36,7 @@ describe Savon::SOAP do
36
36
  end
37
37
 
38
38
  it "is has both getter and setter for the SOAP action" do
39
- @soap.action.should == UserFixture.operations[:find_user][:action]
39
+ @soap.action.should == WSDLFixture.authentication(:operations)[:authenticate][:action]
40
40
 
41
41
  @soap.action = "someAction"
42
42
  @soap.action.should == "someAction"
@@ -76,6 +76,14 @@ describe Savon::SOAP do
76
76
  end
77
77
  end
78
78
 
79
+ it "has both getter and setter for the SOAP endpoint" do
80
+ @soap.endpoint.should be_nil
81
+
82
+ soap_endpoint = URI EndpointHelper.soap_endpoint
83
+ @soap.endpoint = soap_endpoint
84
+ @soap.endpoint.should == soap_endpoint
85
+ end
86
+
79
87
  it "has a getter for the SOAP version to use which defaults to SOAP 1.1" do
80
88
  @soap.version.should == Savon::SOAP.version
81
89
  end
@@ -89,12 +97,12 @@ describe Savon::SOAP do
89
97
  after { Savon::SOAP.version = 1 }
90
98
 
91
99
  it "returns the XML for a SOAP request" do
92
- @soap.namespaces["xmlns:wsdl"] = "http://v1_0.ws.user.example.com"
100
+ @soap.namespaces["xmlns:wsdl"] = "http://v1_0.ws.auth.order.example.com/"
93
101
  @soap.body = { :id => 666 }
94
102
 
95
- @soap.to_xml.should include 'xmlns:wsdl="http://v1_0.ws.user.example.com"'
103
+ @soap.to_xml.should include 'xmlns:wsdl="http://v1_0.ws.auth.order.example.com/"'
96
104
  @soap.to_xml.should include 'xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"'
97
- @soap.to_xml.should include '<wsdl:findUser><id>666</id></wsdl:findUser>'
105
+ @soap.to_xml.should include '<wsdl:authenticate><id>666</id></wsdl:authenticate>'
98
106
  end
99
107
 
100
108
  it "caches the XML, returning the same Object every time" do
@@ -1,37 +1,80 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Savon::WSDL do
4
- before do
5
- @wsdl = Savon::WSDL.new Savon::Request.new(EndpointHelper.wsdl_endpoint)
6
- end
4
+ describe "a common WSDL document" do
5
+ before { @wsdl = new_wsdl }
7
6
 
8
- it "is initialized with a Savon::Request object" do
9
- Savon::WSDL.new Savon::Request.new(EndpointHelper.wsdl_endpoint)
10
- end
7
+ it "is initialized with a Savon::Request object" do
8
+ Savon::WSDL.new Savon::Request.new(EndpointHelper.wsdl_endpoint)
9
+ end
11
10
 
12
- it "has a getter for the namespace URI" do
13
- @wsdl.namespace_uri.should == UserFixture.namespace_uri
14
- end
11
+ it "has a getter for the namespace URI" do
12
+ @wsdl.namespace_uri.should == WSDLFixture.authentication(:namespace_uri)
13
+ end
14
+
15
+ it "has a getter for returning an Array of available SOAP actions" do
16
+ WSDLFixture.authentication(:operations).keys.each do |soap_action|
17
+ @wsdl.soap_actions.should include soap_action
18
+ end
19
+ end
20
+
21
+ it "has a getter for returning a Hash of available SOAP operations" do
22
+ @wsdl.operations.should == WSDLFixture.authentication(:operations)
23
+ end
24
+
25
+ it "responds to SOAP actions while still behaving as usual otherwise" do
26
+ WSDLFixture.authentication(:operations).keys.each do |soap_action|
27
+ @wsdl.respond_to?(soap_action).should be_true
28
+ end
29
+
30
+ @wsdl.respond_to?(:object_id).should be_true
31
+ @wsdl.respond_to?(:some_undefined_method).should be_false
32
+ end
15
33
 
16
- it "has a getter for returning an Array of available SOAP actions" do
17
- UserFixture.soap_actions.each do |soap_action|
18
- @wsdl.soap_actions.should include soap_action
34
+ it "returns the raw WSDL document for to_s" do
35
+ @wsdl.to_s.should == WSDLFixture.authentication
19
36
  end
20
37
  end
21
38
 
22
- it "has a getter for returning a Hash of available SOAP operations" do
23
- @wsdl.operations.should == UserFixture.operations
39
+ describe "a WSDL document having core sections without a namespace" do
40
+ before { @wsdl = new_wsdl :no_namespace }
41
+
42
+ it "returns the namespace URI" do
43
+ @wsdl.namespace_uri.should == WSDLFixture.no_namespace(:namespace_uri)
44
+ end
45
+
46
+ it "returns an Array of available SOAP actions" do
47
+ WSDLFixture.no_namespace(:operations).keys.each do |soap_action|
48
+ @wsdl.soap_actions.should include soap_action
49
+ end
50
+ end
51
+
52
+ it "returns a Hash of SOAP operations" do
53
+ @wsdl.operations.should == WSDLFixture.no_namespace(:operations)
54
+ end
24
55
  end
25
56
 
26
- it "responds to SOAP actions while still behaving as usual otherwise" do
27
- @wsdl.respond_to?(UserFixture.soap_actions.first).should be_true
57
+ describe "a WSDL document with namespaced SOAP actions" do
58
+ before { @wsdl = new_wsdl :namespaced_actions }
28
59
 
29
- @wsdl.respond_to?(:object_id).should be_true
30
- @wsdl.respond_to?(:some_undefined_method).should be_false
60
+ it "returns the namespace URI" do
61
+ @wsdl.namespace_uri.should == WSDLFixture.namespaced_actions(:namespace_uri)
62
+ end
63
+
64
+ it "returns an Array of available SOAP actions" do
65
+ WSDLFixture.namespaced_actions(:operations).keys.each do |soap_action|
66
+ @wsdl.soap_actions.should include soap_action
67
+ end
68
+ end
69
+
70
+ it "returns a Hash of SOAP operations" do
71
+ @wsdl.operations.should == WSDLFixture.namespaced_actions(:operations)
72
+ end
31
73
  end
32
74
 
33
- it "returns the raw WSDL document for to_s" do
34
- @wsdl.to_s.should == UserFixture.user_wsdl
75
+ def new_wsdl(fixture = nil)
76
+ endpoint = fixture ? EndpointHelper.wsdl_endpoint(fixture) : EndpointHelper.wsdl_endpoint
77
+ Savon::WSDL.new Savon::Request.new(endpoint)
35
78
  end
36
79
 
37
80
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require "rubygems"
2
- gem "rspec", ">= 1.2.8"
2
+ require "rake"
3
3
  require "spec"
4
4
  require "mocha"
5
+ require "fakeweb"
5
6
 
6
7
  Spec::Runner.configure do |config|
7
8
  config.mock_with :mocha
@@ -10,6 +11,6 @@ end
10
11
  require "savon"
11
12
  Savon::Request.log = false
12
13
 
13
- require "fixtures/user_fixture"
14
+ FileList["spec/fixtures/**/*.rb"].each { |fixture| require fixture }
14
15
  require "endpoint_helper"
15
16
  require "http_stubs"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-17 00:00:00 +01:00
12
+ date: 2010-01-01 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -62,7 +62,7 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: 1.2.7
64
64
  version:
65
- description: Heavy metal Ruby SOAP client library
65
+ description:
66
66
  email: me@rubiii.com
67
67
  executables: []
68
68
 
@@ -72,30 +72,25 @@ extra_rdoc_files:
72
72
  - README.textile
73
73
  files:
74
74
  - CHANGELOG
75
- - README.textile
76
75
  - Rakefile
77
- - VERSION
78
- - lib/savon.rb
76
+ - README.textile
79
77
  - lib/savon/client.rb
80
- - lib/savon/core_ext.rb
81
78
  - lib/savon/core_ext/datetime.rb
82
79
  - lib/savon/core_ext/hash.rb
83
80
  - lib/savon/core_ext/object.rb
84
81
  - lib/savon/core_ext/string.rb
85
82
  - lib/savon/core_ext/symbol.rb
86
83
  - lib/savon/core_ext/uri.rb
84
+ - lib/savon/core_ext.rb
87
85
  - lib/savon/request.rb
88
86
  - lib/savon/response.rb
89
87
  - lib/savon/soap.rb
90
88
  - lib/savon/wsdl.rb
91
89
  - lib/savon/wsse.rb
90
+ - lib/savon.rb
92
91
  - spec/endpoint_helper.rb
93
- - spec/fixtures/multiple_user_response.xml
94
- - spec/fixtures/soap_fault.xml
95
- - spec/fixtures/soap_fault12.xml
96
- - spec/fixtures/user_fixture.rb
97
- - spec/fixtures/user_response.xml
98
- - spec/fixtures/user_wsdl.xml
92
+ - spec/fixtures/response/response_fixture.rb
93
+ - spec/fixtures/wsdl/wsdl_fixture.rb
99
94
  - spec/http_stubs.rb
100
95
  - spec/savon/client_spec.rb
101
96
  - spec/savon/core_ext/datetime_spec.rb
@@ -111,6 +106,12 @@ files:
111
106
  - spec/savon/wsdl_spec.rb
112
107
  - spec/savon/wsse_spec.rb
113
108
  - spec/spec_helper.rb
109
+ - spec/fixtures/response/xml/authentication.xml
110
+ - spec/fixtures/response/xml/soap_fault.xml
111
+ - spec/fixtures/response/xml/soap_fault12.xml
112
+ - spec/fixtures/wsdl/xml/authentication.xml
113
+ - spec/fixtures/wsdl/xml/namespaced_actions.xml
114
+ - spec/fixtures/wsdl/xml/no_namespace.xml
114
115
  has_rdoc: true
115
116
  homepage: http://github.com/rubiii/savon
116
117
  licenses: []
@@ -145,7 +146,8 @@ specification_version: 3
145
146
  summary: Heavy metal Ruby SOAP client library
146
147
  test_files:
147
148
  - spec/endpoint_helper.rb
148
- - spec/fixtures/user_fixture.rb
149
+ - spec/fixtures/response/response_fixture.rb
150
+ - spec/fixtures/wsdl/wsdl_fixture.rb
149
151
  - spec/http_stubs.rb
150
152
  - spec/savon/client_spec.rb
151
153
  - spec/savon/core_ext/datetime_spec.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.6.7
@@ -1,22 +0,0 @@
1
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
2
- <soap:Body>
3
- <ns2:findUserResponse xmlns:ns2="http://v1_0.ws.user.example.com">
4
- <return>
5
- <id>666</id>
6
- <email>thedude@example.com</email>
7
- <username>thedude</username>
8
- <firstname>The</firstname>
9
- <lastname>Dude</lastname>
10
- <registered>2000-01-22T22:11:21</registered>
11
- </return>
12
- <return>
13
- <id>999</id>
14
- <email>anotherdude@example.com</email>
15
- <username>anotherdude</username>
16
- <firstname>Another</firstname>
17
- <lastname>Dude</lastname>
18
- <registered>1984-05-26T11:22:12</registered>
19
- </return>
20
- </ns2:findUserResponse>
21
- </soap:Body>
22
- </soap:Envelope>
@@ -1,62 +0,0 @@
1
- class UserFixture
2
-
3
- @namespace_uri = "http://v1_0.ws.user.example.com"
4
- @operations = {
5
- :user_find_by_id => { :action => "User.FindById", :input => "User.FindById" },
6
- :find_user => { :action => "findUser", :input => "findUser" }
7
- }
8
-
9
- @datetime_string = "2010-11-22T11:22:33"
10
- @datetime_object = DateTime.parse @datetime_string
11
-
12
- @response_hash = {
13
- :ns2 => "http://v1_0.ws.user.example.com",
14
- :return => {
15
- :active => true,
16
- :firstname => "The",
17
- :lastname => "Dude",
18
- :email => "thedude@example.com",
19
- :id => "666",
20
- :registered => @datetime_object,
21
- :username => "thedude"
22
- }
23
- }
24
-
25
- class << self
26
-
27
- attr_accessor :namespace_uri, :operations,
28
- :datetime_string, :datetime_object, :response_hash
29
-
30
- def soap_actions
31
- @operations.keys
32
- end
33
-
34
- def user_wsdl
35
- load_fixture :user_wsdl
36
- end
37
-
38
- def user_response
39
- load_fixture :user_response
40
- end
41
-
42
- def multiple_user_response
43
- load_fixture :multiple_user_response
44
- end
45
-
46
- def soap_fault
47
- load_fixture :soap_fault
48
- end
49
-
50
- def soap_fault12
51
- load_fixture :soap_fault12
52
- end
53
-
54
- private
55
-
56
- def load_fixture(file)
57
- file_path = File.join File.dirname(__FILE__), "#{file}.xml"
58
- IO.readlines(file_path, "").to_s
59
- end
60
-
61
- end
62
- end
@@ -1,15 +0,0 @@
1
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
2
- <soap:Body>
3
- <ns2:findUserResponse xmlns:ns2="http://v1_0.ws.user.example.com">
4
- <return>
5
- <id>666</id>
6
- <email>thedude@example.com</email>
7
- <username>thedude</username>
8
- <firstname>The</firstname>
9
- <lastname>Dude</lastname>
10
- <registered>2010-11-22T11:22:33</registered>
11
- <active>true</active>
12
- </return>
13
- </ns2:findUserResponse>
14
- </soap:Body>
15
- </soap:Envelope>
@@ -1,124 +0,0 @@
1
- <wsdl:definitions
2
- name="UserWebService"
3
- targetNamespace="http://v1_0.ws.user.example.com"
4
- xmlns:ns1="http://cxf.apache.org/bindings/xformat"
5
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
6
- xmlns:tns="http://v1_0.ws.user.example.com"
7
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
8
- xmlns:xsd="http://www.w3.org/2001/XMLSchema">
9
-
10
- <wsdl:types>
11
- <xs:schema
12
- attributeFormDefault="unqualified"
13
- elementFormDefault="unqualified"
14
- targetNamespace="http://v1_0.ws.user.example.com"
15
- xmlns:tns="http://v1_0.ws.user.example.com"
16
- xmlns:xs="http://www.w3.org/2001/XMLSchema">
17
- <xs:element name="findUser" type="tns:findUser" />
18
- <xs:element name="User.FindById" type="tns:findUser" />
19
- <xs:element name="findUserRequest" type="tns:findUserRequest" />
20
- <xs:element name="baseFindUserRequest" type="tns:baseFindUserRequest" />
21
- <xs:element name="idCredential" type="tns:idCredential" />
22
- <xs:element name="emailCredential" type="tns:emailCredential" />
23
- <xs:element name="findUserResponse" type="tns:findUserResponse" />
24
- <xs:element name="User.FindByIdResponse" type="tns:findUserResponse" />
25
- <xs:element name="userResponse" type="tns:userResponse" />
26
-
27
- <xs:complexType name="findUser">
28
- <xs:sequence>
29
- <xs:element minOccurs="1" name="requestData" type="tns:findUserRequest" />
30
- </xs:sequence>
31
- </xs:complexType>
32
- <xs:complexType name="findUserRequest">
33
- <xs:complexContent>
34
- <xs:extension base="tns:baseFindUserRequest">
35
- <xs:sequence>
36
- <xs:element minOccurs="0" name="mandant" type="tns:mandant" />
37
- </xs:sequence>
38
- </xs:extension>
39
- </xs:complexContent>
40
- </xs:complexType>
41
- <xs:complexType name="baseFindUserRequest">
42
- <xs:choice>
43
- <xs:element ref="tns:idCredential" />
44
- <xs:element ref="tns:emailCredential" />
45
- </xs:choice>
46
- </xs:complexType>
47
- <xs:complexType name="idCredential">
48
- <xs:sequence>
49
- <xs:element name="id" type="xs:string" />
50
- <xs:element name="token" type="xs:string" />
51
- </xs:sequence>
52
- </xs:complexType>
53
- <xs:complexType name="emailCredential">
54
- <xs:sequence>
55
- <xs:element name="email" type="xs:string" />
56
- <xs:element name="token" type="xs:string" />
57
- </xs:sequence>
58
- </xs:complexType>
59
- <xs:complexType name="findUserResponse">
60
- <xs:sequence>
61
- <xs:element minOccurs="0" name="return" type="tns:userResponse" />
62
- </xs:sequence>
63
- </xs:complexType>
64
- <xs:complexType name="userResponse">
65
- <xs:sequence>
66
- <xs:element minOccurs="0" name="id" type="xs:string" />
67
- <xs:element minOccurs="0" name="email" type="xs:string" />
68
- <xs:element minOccurs="0" name="username" type="xs:string" />
69
- <xs:element minOccurs="0" name="firstname" type="xs:string" />
70
- <xs:element minOccurs="0" name="lastname" type="xs:string" />
71
- </xs:sequence>
72
- </xs:complexType>
73
- </xs:schema>
74
- </wsdl:types>
75
-
76
- <wsdl:message name="findUser">
77
- <wsdl:part element="tns:findUser" name="parameters"></wsdl:part>
78
- </wsdl:message>
79
- <wsdl:message name="findUserResponse">
80
- <wsdl:part element="tns:findUserResponse" name="parameters"></wsdl:part>
81
- </wsdl:message>
82
-
83
- <wsdl:message name="User.FindById">
84
- <wsdl:part element="tns:findUser" name="parameters"></wsdl:part>
85
- </wsdl:message>
86
- <wsdl:message name="User.FindByIdResponse">
87
- <wsdl:part element="tns:findUserResponse" name="parameters"></wsdl:part>
88
- </wsdl:message>
89
-
90
- <wsdl:portType name="UserWebService">
91
- <wsdl:operation name="findUser">
92
- <wsdl:input message="tns:findUser" name="findUser"></wsdl:input>
93
- <wsdl:output message="tns:findUserResponse" name="findUserResponse"></wsdl:output>
94
- </wsdl:operation>
95
- </wsdl:portType>
96
-
97
- <wsdl:binding name="UserWebServiceSoapBinding" type="tns:UserWebService">
98
- <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
99
- <wsdl:operation name="findUser">
100
- <soap:operation soapAction="" style="document" />
101
- <wsdl:input name="findUser">
102
- <soap:body use="literal" />
103
- </wsdl:input>
104
- <wsdl:output name="findUserResponse">
105
- <soap:body use="literal" />
106
- </wsdl:output>
107
- </wsdl:operation>
108
- <wsdl:operation name="User.FindById">
109
- <soap:operation soapAction="" style="document" />
110
- <wsdl:input name="User.FindById">
111
- <soap:body use="literal" />
112
- </wsdl:input>
113
- <wsdl:output name="User.FindByIdResponse">
114
- <soap:body use="literal" />
115
- </wsdl:output>
116
- </wsdl:operation>
117
- </wsdl:binding>
118
-
119
- <wsdl:service name="UserWebService">
120
- <wsdl:port binding="tns:UserWebServiceSoapBinding" name="UserWebServicePort">
121
- <soap:address location="http://example.com/user/1.0/UserService" />
122
- </wsdl:port>
123
- </wsdl:service>
124
- </wsdl:definitions>