savon 2.13.0 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -1
  3. data/README.md +2 -4
  4. data/lib/savon/builder.rb +7 -3
  5. data/lib/savon/model.rb +3 -3
  6. data/lib/savon/options.rb +1 -1
  7. data/lib/savon/response.rb +3 -3
  8. data/lib/savon/string_utils.rb +17 -0
  9. data/lib/savon/version.rb +1 -1
  10. data/lib/savon.rb +1 -0
  11. metadata +15 -103
  12. data/.gitignore +0 -16
  13. data/.yardopts +0 -6
  14. data/CONTRIBUTING.md +0 -42
  15. data/Gemfile +0 -8
  16. data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc.png +0 -0
  17. data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
  18. data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_both.png +0 -0
  19. data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc.png +0 -0
  20. data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
  21. data/coverage/assets/0.12.3/application.css +0 -1
  22. data/coverage/assets/0.12.3/application.js +0 -7
  23. data/coverage/assets/0.12.3/colorbox/border.png +0 -0
  24. data/coverage/assets/0.12.3/colorbox/controls.png +0 -0
  25. data/coverage/assets/0.12.3/colorbox/loading.gif +0 -0
  26. data/coverage/assets/0.12.3/colorbox/loading_background.png +0 -0
  27. data/coverage/assets/0.12.3/favicon_green.png +0 -0
  28. data/coverage/assets/0.12.3/favicon_red.png +0 -0
  29. data/coverage/assets/0.12.3/favicon_yellow.png +0 -0
  30. data/coverage/assets/0.12.3/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  31. data/coverage/assets/0.12.3/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  32. data/coverage/assets/0.12.3/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  33. data/coverage/assets/0.12.3/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  34. data/coverage/assets/0.12.3/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  35. data/coverage/assets/0.12.3/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  36. data/coverage/assets/0.12.3/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  37. data/coverage/assets/0.12.3/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  38. data/coverage/assets/0.12.3/images/ui-icons_222222_256x240.png +0 -0
  39. data/coverage/assets/0.12.3/images/ui-icons_2e83ff_256x240.png +0 -0
  40. data/coverage/assets/0.12.3/images/ui-icons_454545_256x240.png +0 -0
  41. data/coverage/assets/0.12.3/images/ui-icons_888888_256x240.png +0 -0
  42. data/coverage/assets/0.12.3/images/ui-icons_cd0a0a_256x240.png +0 -0
  43. data/coverage/assets/0.12.3/loading.gif +0 -0
  44. data/coverage/assets/0.12.3/magnify.png +0 -0
  45. data/coverage/index.html +0 -21518
  46. data/lib/savon/core_ext/string.rb +0 -30
  47. data/savon.gemspec +0 -47
  48. data/spec/fixtures/gzip/message.gz +0 -0
  49. data/spec/fixtures/response/another_soap_fault.xml +0 -14
  50. data/spec/fixtures/response/authentication.xml +0 -14
  51. data/spec/fixtures/response/empty_soap_fault.xml +0 -13
  52. data/spec/fixtures/response/f5.xml +0 -39
  53. data/spec/fixtures/response/header.xml +0 -13
  54. data/spec/fixtures/response/list.xml +0 -18
  55. data/spec/fixtures/response/multi_ref.xml +0 -39
  56. data/spec/fixtures/response/no_body.xml +0 -1
  57. data/spec/fixtures/response/soap_fault.xml +0 -8
  58. data/spec/fixtures/response/soap_fault12.xml +0 -18
  59. data/spec/fixtures/response/soap_fault_funky.xml +0 -8
  60. data/spec/fixtures/response/taxcloud.xml +0 -1
  61. data/spec/fixtures/ssl/client_cert.pem +0 -16
  62. data/spec/fixtures/ssl/client_encrypted_key.pem +0 -30
  63. data/spec/fixtures/ssl/client_encrypted_key_cert.pem +0 -24
  64. data/spec/fixtures/ssl/client_key.pem +0 -15
  65. data/spec/fixtures/wsdl/authentication.xml +0 -63
  66. data/spec/fixtures/wsdl/betfair.xml +0 -2981
  67. data/spec/fixtures/wsdl/brand.xml +0 -624
  68. data/spec/fixtures/wsdl/edialog.xml +0 -15416
  69. data/spec/fixtures/wsdl/elements_in_types.xml +0 -43
  70. data/spec/fixtures/wsdl/interhome.xml +0 -2137
  71. data/spec/fixtures/wsdl/lower_camel.xml +0 -52
  72. data/spec/fixtures/wsdl/multiple_namespaces.xml +0 -92
  73. data/spec/fixtures/wsdl/multiple_types.xml +0 -60
  74. data/spec/fixtures/wsdl/no_message_tag.xml +0 -1267
  75. data/spec/fixtures/wsdl/taxcloud.xml +0 -934
  76. data/spec/fixtures/wsdl/team_software.xml +0 -1
  77. data/spec/fixtures/wsdl/vies.xml +0 -176
  78. data/spec/fixtures/wsdl/wasmuth.xml +0 -153
  79. data/spec/integration/support/application.rb +0 -114
  80. data/spec/integration/support/server.rb +0 -85
  81. data/spec/integration/zipcode_example_spec.rb +0 -39
  82. data/spec/savon/builder_spec.rb +0 -138
  83. data/spec/savon/client_spec.rb +0 -272
  84. data/spec/savon/core_ext/string_spec.rb +0 -38
  85. data/spec/savon/features/message_tag_spec.rb +0 -62
  86. data/spec/savon/http_error_spec.rb +0 -57
  87. data/spec/savon/log_message_spec.rb +0 -51
  88. data/spec/savon/message_spec.rb +0 -61
  89. data/spec/savon/mock_spec.rb +0 -175
  90. data/spec/savon/model_spec.rb +0 -183
  91. data/spec/savon/multipart_request_spec.rb +0 -46
  92. data/spec/savon/observers_spec.rb +0 -93
  93. data/spec/savon/operation_spec.rb +0 -207
  94. data/spec/savon/options_spec.rb +0 -1154
  95. data/spec/savon/qualified_message_spec.rb +0 -102
  96. data/spec/savon/request_logger_spec.rb +0 -38
  97. data/spec/savon/request_spec.rb +0 -581
  98. data/spec/savon/response_spec.rb +0 -276
  99. data/spec/savon/soap_fault_spec.rb +0 -147
  100. data/spec/savon/softlayer_spec.rb +0 -28
  101. data/spec/spec_helper.rb +0 -31
  102. data/spec/support/adapters.rb +0 -49
  103. data/spec/support/endpoint.rb +0 -26
  104. data/spec/support/fixture.rb +0 -40
  105. data/spec/support/integration.rb +0 -10
  106. 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