savon 0.8.0.beta.4 → 0.8.0

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 (42) hide show
  1. data/CHANGELOG.md +95 -80
  2. data/lib/savon/core_ext/hash.rb +0 -87
  3. data/lib/savon/core_ext/object.rb +0 -10
  4. data/lib/savon/core_ext/string.rb +0 -17
  5. data/lib/savon/soap/xml.rb +28 -8
  6. data/lib/savon/version.rb +1 -1
  7. data/savon.gemspec +3 -1
  8. data/spec/fixtures/response/{xml/another_soap_fault.xml → another_soap_fault.xml} +0 -0
  9. data/spec/fixtures/response/{xml/authentication.xml → authentication.xml} +0 -0
  10. data/spec/fixtures/response/{xml/list.xml → list.xml} +0 -0
  11. data/spec/fixtures/response/{xml/multi_ref.xml → multi_ref.xml} +0 -0
  12. data/spec/fixtures/response/{xml/soap_fault.xml → soap_fault.xml} +0 -0
  13. data/spec/fixtures/response/{xml/soap_fault12.xml → soap_fault12.xml} +0 -0
  14. data/spec/fixtures/wsdl/{xml/authentication.xml → authentication.xml} +0 -0
  15. data/spec/fixtures/wsdl/{xml/geotrust.xml → geotrust.xml} +0 -0
  16. data/spec/fixtures/wsdl/{xml/namespaced_actions.xml → namespaced_actions.xml} +0 -0
  17. data/spec/fixtures/wsdl/{xml/no_namespace.xml → no_namespace.xml} +0 -0
  18. data/spec/savon/client_spec.rb +8 -8
  19. data/spec/savon/core_ext/hash_spec.rb +0 -126
  20. data/spec/savon/core_ext/object_spec.rb +0 -15
  21. data/spec/savon/core_ext/string_spec.rb +0 -22
  22. data/spec/savon/http/error_spec.rb +1 -1
  23. data/spec/savon/soap/fault_spec.rb +4 -4
  24. data/spec/savon/soap/request_spec.rb +1 -1
  25. data/spec/savon/soap/response_spec.rb +6 -5
  26. data/spec/savon/soap/xml_spec.rb +33 -5
  27. data/spec/savon/wsdl/document_spec.rb +3 -3
  28. data/spec/savon/wsdl/parser_spec.rb +1 -1
  29. data/spec/savon/wsdl/request_spec.rb +1 -1
  30. data/spec/spec_helper.rb +3 -9
  31. data/spec/support/fixture.rb +37 -0
  32. metadata +56 -39
  33. data/lib/savon/core_ext/array.rb +0 -45
  34. data/lib/savon/core_ext/datetime.rb +0 -19
  35. data/lib/savon/core_ext/symbol.rb +0 -16
  36. data/spec/fixtures/gzip/gzip_response_fixture.rb +0 -7
  37. data/spec/fixtures/response/response_fixture.rb +0 -40
  38. data/spec/fixtures/wsdl/wsdl_fixture.rb +0 -43
  39. data/spec/fixtures/wsdl/wsdl_fixture.yml +0 -42
  40. data/spec/savon/core_ext/array_spec.rb +0 -49
  41. data/spec/savon/core_ext/datetime_spec.rb +0 -21
  42. data/spec/savon/core_ext/symbol_spec.rb +0 -12
@@ -37,7 +37,7 @@ describe Savon::SOAP::Request do
37
37
 
38
38
  describe "#response" do
39
39
  it "should execute an HTTP POST request and return a Savon::SOAP::Response" do
40
- HTTPI.expects(:post).returns(HTTPI::Response.new 200, {}, ResponseFixture.authentication)
40
+ HTTPI.expects(:post).returns(HTTPI::Response.new 200, {}, Fixture.response(:authentication))
41
41
  request.response.should be_a(Savon::SOAP::Response)
42
42
  end
43
43
  end
@@ -119,7 +119,7 @@ describe Savon::SOAP::Response do
119
119
  describe "#to_hash" do
120
120
  it "should return the SOAP response body as a Hash" do
121
121
  soap_response.to_hash[:authenticate_response][:return].should ==
122
- ResponseFixture.authentication(:to_hash)
122
+ Fixture.response_hash(:authentication)[:authenticate_response][:return]
123
123
  end
124
124
  end
125
125
 
@@ -128,7 +128,8 @@ describe Savon::SOAP::Response do
128
128
 
129
129
  context "when the given path exists" do
130
130
  it "should return an Array containing the path value" do
131
- response.to_array(:authenticate_response, :return).should == [ResponseFixture.authentication(:to_hash)]
131
+ response.to_array(:authenticate_response, :return).should ==
132
+ [Fixture.response_hash(:authentication)[:authenticate_response][:return]]
132
133
  end
133
134
  end
134
135
 
@@ -147,7 +148,7 @@ describe Savon::SOAP::Response do
147
148
 
148
149
  describe "#to_xml" do
149
150
  it "should return the raw SOAP response body" do
150
- soap_response.to_xml.should == ResponseFixture.authentication
151
+ soap_response.to_xml.should == Fixture.response(:authentication)
151
152
  end
152
153
  end
153
154
 
@@ -158,14 +159,14 @@ describe Savon::SOAP::Response do
158
159
  end
159
160
 
160
161
  def soap_response(options = {})
161
- defaults = { :code => 200, :headers => {}, :body => ResponseFixture.authentication }
162
+ defaults = { :code => 200, :headers => {}, :body => Fixture.response(:authentication) }
162
163
  response = defaults.merge options
163
164
 
164
165
  Savon::SOAP::Response.new HTTPI::Response.new(response[:code], response[:headers], response[:body])
165
166
  end
166
167
 
167
168
  def soap_fault_response
168
- soap_response :body => ResponseFixture.soap_fault
169
+ soap_response :body => Fixture.response(:soap_fault)
169
170
  end
170
171
 
171
172
  def http_error_response
@@ -5,20 +5,26 @@ describe Savon::SOAP::XML do
5
5
 
6
6
  describe ".to_hash" do
7
7
  it "should return a given SOAP response body as a Hash" do
8
- hash = Savon::SOAP::XML.to_hash ResponseFixture.authentication
9
- hash[:authenticate_response][:return].should ==
10
- ResponseFixture.authentication(:to_hash)
8
+ hash = Savon::SOAP::XML.to_hash Fixture.response(:authentication)
9
+ hash[:authenticate_response][:return].should == {
10
+ :success => true,
11
+ :authentication_value => {
12
+ :token_hash => "AAAJxA;cIedoT;mY10ExZwG6JuKgp2OYKxow==",
13
+ :token => "a68d1d6379b62ff339a0e0c69ed4d9cf",
14
+ :client => "radclient"
15
+ }
16
+ }
11
17
  end
12
18
 
13
19
  it "should return a Hash for a SOAP multiRef response" do
14
- hash = Savon::SOAP::XML.to_hash ResponseFixture.multi_ref
20
+ hash = Savon::SOAP::XML.to_hash Fixture.response(:multi_ref)
15
21
 
16
22
  hash[:list_response].should be_a(Hash)
17
23
  hash[:multi_ref].should be_an(Array)
18
24
  end
19
25
 
20
26
  it "should add existing namespaced elements as an array" do
21
- hash = Savon::SOAP::XML.to_hash ResponseFixture.list
27
+ hash = Savon::SOAP::XML.to_hash Fixture.response(:list)
22
28
 
23
29
  hash[:multi_namespaced_entry_response][:history].should be_a(Hash)
24
30
  hash[:multi_namespaced_entry_response][:history][:case].should be_an(Array)
@@ -82,6 +88,17 @@ describe Savon::SOAP::XML do
82
88
  end
83
89
  end
84
90
 
91
+ describe "#env_namespace" do
92
+ it "should default to :env" do
93
+ xml.env_namespace.should == :env
94
+ end
95
+
96
+ it "should set the SOAP envelope namespace" do
97
+ xml.env_namespace = :soapenv
98
+ xml.env_namespace.should == :soapenv
99
+ end
100
+ end
101
+
85
102
  describe "#namespaces" do
86
103
  it "should default to a Hash containing the namespace for SOAP 1.1" do
87
104
  xml.namespaces.should == { "xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/" }
@@ -137,6 +154,10 @@ describe Savon::SOAP::XML do
137
154
  xml.to_xml.should match(/^<\?xml version="1.0" encoding="UTF-8"\?>/)
138
155
  end
139
156
 
157
+ it "should use default SOAP envelope namespace" do
158
+ xml.to_xml.should include("<env:Envelope", "<env:Body")
159
+ end
160
+
140
161
  it "should add the xsd namespace" do
141
162
  uri = "http://www.w3.org/2001/XMLSchema"
142
163
  xml.to_xml.should match(/<env:Envelope (.*)xmlns:xsd="#{uri}"(.*)>/)
@@ -198,6 +219,13 @@ describe Savon::SOAP::XML do
198
219
  end
199
220
  end
200
221
 
222
+ context "with the SOAP envelope namespace set to an empty String" do
223
+ it "should not add a namespace to SOAP envelope tags" do
224
+ xml.env_namespace = ""
225
+ xml.to_xml.should include("<Envelope", "<Body")
226
+ end
227
+ end
228
+
201
229
  context "using the #namespace and #namespace_identifier" do
202
230
  it "should contain the specified namespace" do
203
231
  xml.namespace_identifier = :wsdl
@@ -51,7 +51,7 @@ describe Savon::WSDL::Document do
51
51
 
52
52
  describe "#document" do
53
53
  it "should return the raw WSDL document" do
54
- wsdl.document.should == WSDLFixture.load
54
+ wsdl.document.should == Fixture.wsdl(:authentication)
55
55
  end
56
56
 
57
57
  it "should be memoized" do
@@ -64,7 +64,7 @@ describe Savon::WSDL::Document do
64
64
  let(:wsdl) { Savon::WSDL::Document.new HTTPI::Request.new, Endpoint.wsdl }
65
65
 
66
66
  before do
67
- response = HTTPI::Response.new(200, {}, WSDLFixture.load)
67
+ response = HTTPI::Response.new(200, {}, Fixture.wsdl(:authentication))
68
68
  HTTPI.stubs(:get).returns(response)
69
69
  end
70
70
 
@@ -73,7 +73,7 @@ describe Savon::WSDL::Document do
73
73
 
74
74
  context "with a local document" do
75
75
  let(:wsdl) do
76
- wsdl = "spec/fixtures/wsdl/xml/authentication.xml"
76
+ wsdl = "spec/fixtures/wsdl/authentication.xml"
77
77
  Savon::WSDL::Document.new HTTPI::Request.new, wsdl
78
78
  end
79
79
 
@@ -71,7 +71,7 @@ describe Savon::WSDL::Parser do
71
71
 
72
72
  def new_parser(fixture)
73
73
  parser = Savon::WSDL::Parser.new
74
- REXML::Document.parse_stream WSDLFixture.load(fixture), parser
74
+ REXML::Document.parse_stream Fixture[:wsdl, fixture], parser
75
75
  parser
76
76
  end
77
77
 
@@ -6,7 +6,7 @@ describe Savon::WSDL::Request do
6
6
 
7
7
  describe "#response" do
8
8
  it "execute an HTTP GET request and return the HTTPI::Response" do
9
- response = HTTPI::Response.new 200, {}, ResponseFixture.authentication
9
+ response = HTTPI::Response.new 200, {}, Fixture.response(:authentication)
10
10
  HTTPI.expects(:get).with(http_request).returns(response)
11
11
  request.response.should == response
12
12
  end
@@ -1,8 +1,5 @@
1
- require "rspec"
2
- require "mocha"
3
-
4
- spec = File.expand_path("..", __FILE__)
5
- $:.unshift spec unless $:.include? spec
1
+ require "bundler"
2
+ Bundler.require :default, :development
6
3
 
7
4
  RSpec.configure do |config|
8
5
  config.mock_with :mocha
@@ -13,8 +10,5 @@ require "savon"
13
10
  # Disable logging for specs.
14
11
  Savon.log = false
15
12
 
16
- # Requires fixtures.
17
- Dir[File.expand_path("../fixtures/**/*.rb", __FILE__)].each { |file| require file }
18
-
19
- # Requires supporting files.
20
13
  require "support/endpoint"
14
+ require "support/fixture"
@@ -0,0 +1,37 @@
1
+ class Fixture
2
+
3
+ TYPES = { :gzip => "gz", :response => "xml", :wsdl => "xml" }
4
+
5
+ class << self
6
+
7
+ def [](type, fixture)
8
+ fixtures(type)[fixture] ||= read_file type, fixture
9
+ end
10
+
11
+ def response_hash(fixture)
12
+ @response_hash ||= {}
13
+ @response_hash[fixture] ||= Savon::SOAP::XML.to_hash response(fixture)
14
+ end
15
+
16
+ TYPES.each do |type, ext|
17
+ define_method type do |fixture|
18
+ self[type, fixture]
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def fixtures(type)
25
+ @fixtures ||= {}
26
+ @fixtures[type] ||= {}
27
+ end
28
+
29
+ def read_file(type, fixture)
30
+ path = File.expand_path "../../fixtures/#{type}/#{fixture}.#{TYPES[type]}", __FILE__
31
+ raise ArgumentError, "Unable to load: #{path}" unless File.exist? path
32
+
33
+ File.read path
34
+ end
35
+
36
+ end
37
+ end
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196267
5
- prerelease: true
4
+ hash: 63
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
9
  - 0
10
- - beta
11
- - 4
12
- version: 0.8.0.beta.4
10
+ version: 0.8.0
13
11
  platform: ruby
14
12
  authors:
15
13
  - Daniel Harrington
@@ -17,7 +15,7 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2010-11-26 00:00:00 +01:00
18
+ date: 2010-12-20 00:00:00 +01:00
21
19
  default_executable:
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
@@ -60,18 +58,34 @@ dependencies:
60
58
  requirements:
61
59
  - - ">="
62
60
  - !ruby/object:Gem::Version
63
- hash: 1
61
+ hash: 11
64
62
  segments:
65
63
  - 0
66
64
  - 7
67
- - 1
68
- version: 0.7.1
65
+ - 4
66
+ version: 0.7.4
69
67
  type: :runtime
70
68
  version_requirements: *id003
71
69
  - !ruby/object:Gem::Dependency
72
- name: rspec
70
+ name: gyoku
73
71
  prerelease: false
74
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 27
78
+ segments:
79
+ - 0
80
+ - 1
81
+ - 0
82
+ version: 0.1.0
83
+ type: :runtime
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: rspec
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
75
89
  none: false
76
90
  requirements:
77
91
  - - ~>
@@ -83,11 +97,25 @@ dependencies:
83
97
  - 0
84
98
  version: 2.0.0
85
99
  type: :development
86
- version_requirements: *id004
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: autotest
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ type: :development
114
+ version_requirements: *id006
87
115
  - !ruby/object:Gem::Dependency
88
116
  name: mocha
89
117
  prerelease: false
90
- requirement: &id005 !ruby/object:Gem::Requirement
118
+ requirement: &id007 !ruby/object:Gem::Requirement
91
119
  none: false
92
120
  requirements:
93
121
  - - ~>
@@ -99,7 +127,7 @@ dependencies:
99
127
  - 7
100
128
  version: 0.9.7
101
129
  type: :development
102
- version_requirements: *id005
130
+ version_requirements: *id007
103
131
  description: Savon is the heavy metal Ruby SOAP client.
104
132
  email: me@rubiii.com
105
133
  executables: []
@@ -120,12 +148,9 @@ files:
120
148
  - autotest/discover.rb
121
149
  - lib/savon.rb
122
150
  - lib/savon/client.rb
123
- - lib/savon/core_ext/array.rb
124
- - lib/savon/core_ext/datetime.rb
125
151
  - lib/savon/core_ext/hash.rb
126
152
  - lib/savon/core_ext/object.rb
127
153
  - lib/savon/core_ext/string.rb
128
- - lib/savon/core_ext/symbol.rb
129
154
  - lib/savon/error.rb
130
155
  - lib/savon/global.rb
131
156
  - lib/savon/http/error.rb
@@ -140,28 +165,21 @@ files:
140
165
  - lib/savon/wsdl/request.rb
141
166
  - lib/savon/wsse.rb
142
167
  - savon.gemspec
143
- - spec/fixtures/gzip/gzip_response_fixture.rb
144
168
  - spec/fixtures/gzip/message.gz
145
- - spec/fixtures/response/response_fixture.rb
146
- - spec/fixtures/response/xml/another_soap_fault.xml
147
- - spec/fixtures/response/xml/authentication.xml
148
- - spec/fixtures/response/xml/list.xml
149
- - spec/fixtures/response/xml/multi_ref.xml
150
- - spec/fixtures/response/xml/soap_fault.xml
151
- - spec/fixtures/response/xml/soap_fault12.xml
152
- - spec/fixtures/wsdl/wsdl_fixture.rb
153
- - spec/fixtures/wsdl/wsdl_fixture.yml
154
- - spec/fixtures/wsdl/xml/authentication.xml
155
- - spec/fixtures/wsdl/xml/geotrust.xml
156
- - spec/fixtures/wsdl/xml/namespaced_actions.xml
157
- - spec/fixtures/wsdl/xml/no_namespace.xml
169
+ - spec/fixtures/response/another_soap_fault.xml
170
+ - spec/fixtures/response/authentication.xml
171
+ - spec/fixtures/response/list.xml
172
+ - spec/fixtures/response/multi_ref.xml
173
+ - spec/fixtures/response/soap_fault.xml
174
+ - spec/fixtures/response/soap_fault12.xml
175
+ - spec/fixtures/wsdl/authentication.xml
176
+ - spec/fixtures/wsdl/geotrust.xml
177
+ - spec/fixtures/wsdl/namespaced_actions.xml
178
+ - spec/fixtures/wsdl/no_namespace.xml
158
179
  - spec/savon/client_spec.rb
159
- - spec/savon/core_ext/array_spec.rb
160
- - spec/savon/core_ext/datetime_spec.rb
161
180
  - spec/savon/core_ext/hash_spec.rb
162
181
  - spec/savon/core_ext/object_spec.rb
163
182
  - spec/savon/core_ext/string_spec.rb
164
- - spec/savon/core_ext/symbol_spec.rb
165
183
  - spec/savon/http/error_spec.rb
166
184
  - spec/savon/savon_spec.rb
167
185
  - spec/savon/soap/fault_spec.rb
@@ -175,6 +193,7 @@ files:
175
193
  - spec/savon/wsse_spec.rb
176
194
  - spec/spec_helper.rb
177
195
  - spec/support/endpoint.rb
196
+ - spec/support/fixture.rb
178
197
  has_rdoc: true
179
198
  homepage: http://github.com/rubiii/savon
180
199
  licenses: []
@@ -196,14 +215,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
215
  required_rubygems_version: !ruby/object:Gem::Requirement
197
216
  none: false
198
217
  requirements:
199
- - - ">"
218
+ - - ">="
200
219
  - !ruby/object:Gem::Version
201
- hash: 25
220
+ hash: 3
202
221
  segments:
203
- - 1
204
- - 3
205
- - 1
206
- version: 1.3.1
222
+ - 0
223
+ version: "0"
207
224
  requirements: []
208
225
 
209
226
  rubyforge_project: savon
@@ -1,45 +0,0 @@
1
- require "builder"
2
-
3
- require "savon/core_ext/object"
4
- require "savon/core_ext/string"
5
- require "savon/core_ext/hash"
6
- require "savon/core_ext/datetime"
7
-
8
- module Savon
9
- module CoreExt
10
- module Array
11
-
12
- # Translates the Array into SOAP compatible XML. See: Hash.to_soap_xml.
13
- def to_soap_xml(key, escape_xml = true, attributes = {})
14
- xml = Builder::XmlMarkup.new
15
-
16
- each_with_index do |item, index|
17
- attrs = tag_attributes attributes, index
18
- case item
19
- when ::Hash then xml.tag!(key, attrs) { xml << item.to_soap_xml }
20
- when NilClass then xml.tag!(key, "xsi:nil" => "true")
21
- else xml.tag!(key, attrs) { xml << (escape_xml ? item.to_soap_value : item.to_soap_value!) }
22
- end
23
- end
24
-
25
- xml.target!
26
- end
27
-
28
- private
29
-
30
- # Takes a Hash of +attributes+ and the +index+ for which to return attributes
31
- # for duplicate tags.
32
- def tag_attributes(attributes, index)
33
- return {} if attributes.empty?
34
-
35
- attributes.inject({}) do |hash, (key, value)|
36
- value = value[index] if value.kind_of? ::Array
37
- hash.merge key => value
38
- end
39
- end
40
-
41
- end
42
- end
43
- end
44
-
45
- Array.send :include, Savon::CoreExt::Array