savon 2.13.1 → 2.14.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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -1
  3. data/lib/savon/builder.rb +4 -3
  4. data/lib/savon/model.rb +3 -3
  5. data/lib/savon/options.rb +1 -1
  6. data/lib/savon/response.rb +3 -3
  7. data/lib/savon/string_utils.rb +17 -0
  8. data/lib/savon/version.rb +1 -1
  9. data/lib/savon.rb +1 -0
  10. metadata +17 -76
  11. data/.gitignore +0 -16
  12. data/.yardopts +0 -6
  13. data/CONTRIBUTING.md +0 -42
  14. data/Gemfile +0 -8
  15. data/RELEASING.md +0 -10
  16. data/lib/savon/core_ext/string.rb +0 -30
  17. data/savon.gemspec +0 -47
  18. data/spec/fixtures/gzip/message.gz +0 -0
  19. data/spec/fixtures/response/another_soap_fault.xml +0 -14
  20. data/spec/fixtures/response/authentication.xml +0 -14
  21. data/spec/fixtures/response/empty_soap_fault.xml +0 -13
  22. data/spec/fixtures/response/f5.xml +0 -39
  23. data/spec/fixtures/response/header.xml +0 -13
  24. data/spec/fixtures/response/list.xml +0 -18
  25. data/spec/fixtures/response/multi_ref.xml +0 -39
  26. data/spec/fixtures/response/no_body.xml +0 -1
  27. data/spec/fixtures/response/soap_fault.xml +0 -8
  28. data/spec/fixtures/response/soap_fault12.xml +0 -18
  29. data/spec/fixtures/response/soap_fault_funky.xml +0 -8
  30. data/spec/fixtures/response/taxcloud.xml +0 -1
  31. data/spec/fixtures/ssl/client_cert.pem +0 -16
  32. data/spec/fixtures/ssl/client_encrypted_key.pem +0 -30
  33. data/spec/fixtures/ssl/client_encrypted_key_cert.pem +0 -24
  34. data/spec/fixtures/ssl/client_key.pem +0 -15
  35. data/spec/fixtures/wsdl/authentication.xml +0 -63
  36. data/spec/fixtures/wsdl/betfair.xml +0 -2981
  37. data/spec/fixtures/wsdl/brand.xml +0 -624
  38. data/spec/fixtures/wsdl/edialog.xml +0 -15416
  39. data/spec/fixtures/wsdl/elements_in_types.xml +0 -43
  40. data/spec/fixtures/wsdl/interhome.xml +0 -2137
  41. data/spec/fixtures/wsdl/lower_camel.xml +0 -52
  42. data/spec/fixtures/wsdl/multiple_namespaces.xml +0 -92
  43. data/spec/fixtures/wsdl/multiple_types.xml +0 -60
  44. data/spec/fixtures/wsdl/no_message_tag.xml +0 -1267
  45. data/spec/fixtures/wsdl/taxcloud.xml +0 -934
  46. data/spec/fixtures/wsdl/team_software.xml +0 -1
  47. data/spec/fixtures/wsdl/vies.xml +0 -176
  48. data/spec/fixtures/wsdl/wasmuth.xml +0 -153
  49. data/spec/integration/support/application.rb +0 -114
  50. data/spec/integration/support/server.rb +0 -85
  51. data/spec/integration/zipcode_example_spec.rb +0 -39
  52. data/spec/savon/builder_spec.rb +0 -138
  53. data/spec/savon/client_spec.rb +0 -272
  54. data/spec/savon/core_ext/string_spec.rb +0 -38
  55. data/spec/savon/features/message_tag_spec.rb +0 -62
  56. data/spec/savon/http_error_spec.rb +0 -57
  57. data/spec/savon/log_message_spec.rb +0 -51
  58. data/spec/savon/message_spec.rb +0 -61
  59. data/spec/savon/mock_spec.rb +0 -175
  60. data/spec/savon/model_spec.rb +0 -183
  61. data/spec/savon/multipart_request_spec.rb +0 -46
  62. data/spec/savon/observers_spec.rb +0 -93
  63. data/spec/savon/operation_spec.rb +0 -207
  64. data/spec/savon/options_spec.rb +0 -1154
  65. data/spec/savon/qualified_message_spec.rb +0 -102
  66. data/spec/savon/request_logger_spec.rb +0 -38
  67. data/spec/savon/request_spec.rb +0 -581
  68. data/spec/savon/response_spec.rb +0 -276
  69. data/spec/savon/soap_fault_spec.rb +0 -147
  70. data/spec/savon/softlayer_spec.rb +0 -42
  71. data/spec/spec_helper.rb +0 -31
  72. data/spec/support/adapters.rb +0 -49
  73. data/spec/support/endpoint.rb +0 -26
  74. data/spec/support/fixture.rb +0 -40
  75. data/spec/support/integration.rb +0 -10
  76. data/spec/support/stdout.rb +0 -26
@@ -1,207 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
- require "integration/support/server"
4
- require "json"
5
- require "ostruct"
6
-
7
- RSpec.describe Savon::Operation do
8
-
9
- let(:globals) { Savon::GlobalOptions.new(:endpoint => @server.url(:repeat), :log => false) }
10
- let(:wsdl) { Wasabi::Document.new Fixture.wsdl(:taxcloud) }
11
-
12
- let(:no_wsdl) {
13
- wsdl = Wasabi::Document.new
14
-
15
- wsdl.endpoint = "http://example.com"
16
- wsdl.namespace = "http://v1.example.com"
17
-
18
- wsdl
19
- }
20
-
21
- def new_operation(operation_name, wsdl, globals)
22
- Savon::Operation.create(operation_name, wsdl, globals)
23
- end
24
-
25
- before :all do
26
- @server = IntegrationServer.run
27
- end
28
-
29
- after :all do
30
- @server.stop
31
- end
32
-
33
- describe ".create with a WSDL" do
34
- it "returns a new operation" do
35
- operation = new_operation(:verify_address, wsdl, globals)
36
- expect(operation).to be_a(Savon::Operation)
37
- end
38
-
39
- it "raises if the operation name is not a Symbol" do
40
- expect { new_operation("not a symbol", wsdl, globals) }.
41
- to raise_error(ArgumentError, /Expected the first parameter \(the name of the operation to call\) to be a symbol/)
42
- end
43
-
44
- it "raises if the operation is not available for the service" do
45
- expect { new_operation(:no_such_operation, wsdl, globals) }.
46
- to raise_error(Savon::UnknownOperationError, /Unable to find SOAP operation: :no_such_operation/)
47
- end
48
-
49
- it "raises if the endpoint cannot be reached" do
50
- message = "Error!"
51
- response = HTTPI::Response.new(500, {}, message)
52
- error = Wasabi::Resolver::HTTPError.new(message, response)
53
- Wasabi::Document.any_instance.stubs(:soap_actions).raises(error)
54
-
55
- expect { new_operation(:verify_address, wsdl, globals) }.
56
- to raise_error(Savon::HTTPError, /#{message}/)
57
- end
58
- end
59
-
60
- describe ".create without a WSDL" do
61
- it "returns a new operation" do
62
- operation = new_operation(:verify_address, no_wsdl, globals)
63
- expect(operation).to be_a(Savon::Operation)
64
- end
65
- end
66
-
67
- describe "#build" do
68
- it "returns the Builder" do
69
- operation = new_operation(:verify_address, wsdl, globals)
70
- builder = operation.build(:message => { :test => 'message' })
71
-
72
- expect(builder).to be_a(Savon::Builder)
73
- expect(builder.to_s).to include('<tns:VerifyAddress><tns:test>message</tns:test></tns:VerifyAddress>')
74
- end
75
- end
76
-
77
- describe "#call" do
78
- it "returns a response object" do
79
- operation = new_operation(:verify_address, wsdl, globals)
80
- expect(operation.call).to be_a(Savon::Response)
81
- end
82
-
83
- it "uses the global :endpoint option for the request" do
84
- globals.endpoint("http://v1.example.com")
85
- HTTPI::Request.any_instance.expects(:url=).with("http://v1.example.com")
86
-
87
- operation = new_operation(:verify_address, wsdl, globals)
88
-
89
- # stub the actual request
90
- http_response = HTTPI::Response.new(200, {}, "")
91
- operation.expects(:call_with_logging).returns(http_response)
92
-
93
- operation.call
94
- end
95
-
96
- it "falls back to use the WSDL's endpoint if the :endpoint option was not set" do
97
- globals_without_endpoint = Savon::GlobalOptions.new(:log => false)
98
- HTTPI::Request.any_instance.expects(:url=).with(wsdl.endpoint)
99
-
100
- operation = new_operation(:verify_address, wsdl, globals_without_endpoint)
101
-
102
- # stub the actual request
103
- http_response = HTTPI::Response.new(200, {}, "")
104
- operation.expects(:call_with_logging).returns(http_response)
105
-
106
- operation.call
107
- end
108
-
109
- it "sets the Content-Length header" do
110
- # XXX: probably the worst spec ever written. refactor! [dh, 2013-01-05]
111
- http_request = HTTPI::Request.new
112
- http_request.headers.expects(:[]=).with("Content-Length", "723")
113
- Savon::SOAPRequest.any_instance.expects(:build).returns(http_request)
114
-
115
- new_operation(:verify_address, wsdl, globals).call
116
- end
117
-
118
- it "passes the local :soap_action option to the request builder" do
119
- globals.endpoint @server.url(:inspect_request)
120
- soap_action = "http://v1.example.com/VerifyAddress"
121
-
122
- operation = new_operation(:verify_address, wsdl, globals)
123
- response = operation.call(:soap_action => soap_action)
124
-
125
- actual_soap_action = inspect_request(response).soap_action
126
- expect(actual_soap_action).to eq(%("#{soap_action}"))
127
- end
128
-
129
- it "uses the local :cookies option" do
130
- globals.endpoint @server.url(:inspect_request)
131
- cookies = [HTTPI::Cookie.new("some-cookie=choc-chip")]
132
-
133
- HTTPI::Request.any_instance.expects(:set_cookies).with(cookies)
134
-
135
- operation = new_operation(:verify_address, wsdl, globals)
136
- operation.call(:cookies => cookies)
137
- end
138
-
139
- it "passes nil to the request builder if the :soap_action was set to nil" do
140
- globals.endpoint @server.url(:inspect_request)
141
-
142
- operation = new_operation(:verify_address, wsdl, globals)
143
- response = operation.call(:soap_action => nil)
144
-
145
- actual_soap_action = inspect_request(response).soap_action
146
- expect(actual_soap_action).to be_nil
147
- end
148
-
149
- it "gets the SOAP action from the WSDL if available" do
150
- globals.endpoint @server.url(:inspect_request)
151
-
152
- operation = new_operation(:verify_address, wsdl, globals)
153
- response = operation.call
154
-
155
- actual_soap_action = inspect_request(response).soap_action
156
- expect(actual_soap_action).to eq('"http://taxcloud.net/VerifyAddress"')
157
- end
158
-
159
- it "falls back to Gyoku if both option and WSDL are not available" do
160
- globals.endpoint @server.url(:inspect_request)
161
-
162
- operation = new_operation(:authenticate, no_wsdl, globals)
163
- response = operation.call
164
-
165
- actual_soap_action = inspect_request(response).soap_action
166
- expect(actual_soap_action).to eq(%("authenticate"))
167
- end
168
-
169
- it "handle multipart response" do
170
- globals.endpoint @server.url(:multipart)
171
- operation = new_operation(:example, no_wsdl, globals)
172
- response = operation.call do
173
- attachments [
174
- { filename: 'x1.xml', content: '<xml>abc</xml>'},
175
- { filename: 'x2.xml', content: '<xml>cde</xml>'},
176
- ]
177
- end
178
-
179
- expect(response.multipart?).to be true
180
- expect(response.header).to eq 'response header'
181
- expect(response.body).to eq 'response body'
182
- expect(response.attachments.first.content_id).to eq 'attachment1'
183
- end
184
-
185
- it "simple request is not multipart" do
186
- operation = new_operation(:example, no_wsdl, globals)
187
- response = operation.call
188
-
189
- expect(response.multipart?).to be false
190
- expect(response.attachments).to be_empty
191
- end
192
- end
193
-
194
- describe "#request" do
195
- it "returns the request" do
196
- operation = new_operation(:verify_address, wsdl, globals)
197
- request = operation.request
198
-
199
- expect(request.body).to include('<tns:VerifyAddress></tns:VerifyAddress>')
200
- end
201
- end
202
-
203
- def inspect_request(response)
204
- hash = JSON.parse(response.http.body)
205
- OpenStruct.new(hash)
206
- end
207
- end