savon 2.13.1 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -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 +35 -81
  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,276 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- RSpec.describe Savon::Response do
5
-
6
- let(:globals) { Savon::GlobalOptions.new }
7
- let(:locals) { Savon::LocalOptions.new }
8
-
9
- describe ".new" do
10
- it "should raise a Savon::Fault in case of a SOAP fault" do
11
- expect { soap_fault_response }.to raise_error(Savon::SOAPFault)
12
- end
13
-
14
- it "should not raise a Savon::Fault in case the default is turned off" do
15
- globals[:raise_errors] = false
16
- expect { soap_fault_response }.not_to raise_error
17
- end
18
-
19
- it "should raise a Savon::HTTP::Error in case of an HTTP error" do
20
- expect { soap_response :code => 500 }.to raise_error(Savon::HTTPError)
21
- end
22
-
23
- it "should not raise a Savon::HTTP::Error in case the default is turned off" do
24
- globals[:raise_errors] = false
25
- soap_response :code => 500
26
- end
27
- end
28
-
29
- describe "#success?" do
30
- before { globals[:raise_errors] = false }
31
-
32
- it "should return true if the request was successful" do
33
- expect(soap_response).to be_a_success
34
- end
35
-
36
- it "should return false if there was a SOAP fault" do
37
- expect(soap_fault_response).not_to be_a_success
38
- end
39
-
40
- it "should return false if there was an HTTP error" do
41
- expect(http_error_response).not_to be_a_success
42
- end
43
- end
44
-
45
- describe "#soap_fault?" do
46
- before { globals[:raise_errors] = false }
47
-
48
- it "should not return true in case the response seems to be ok" do
49
- expect(soap_response.soap_fault?).to be_falsey
50
- end
51
-
52
- it "should return true in case of a SOAP fault" do
53
- expect(soap_fault_response.soap_fault?).to be_truthy
54
- end
55
- end
56
-
57
- describe "#soap_fault" do
58
- before { globals[:raise_errors] = false }
59
-
60
- it "should return nil in case the response seems to be ok" do
61
- expect(soap_response.soap_fault).to be_nil
62
- end
63
-
64
- it "should return a SOAPFault in case of a SOAP fault" do
65
- expect(soap_fault_response.soap_fault).to be_a(Savon::SOAPFault)
66
- end
67
- end
68
-
69
- describe "#http_error?" do
70
- before { globals[:raise_errors] = false }
71
-
72
- it "should not return true in case the response seems to be ok" do
73
- expect(soap_response.http_error?).not_to be_truthy
74
- end
75
-
76
- it "should return true in case of an HTTP error" do
77
- expect(soap_response(:code => 500).http_error?).to be_truthy
78
- end
79
- end
80
-
81
- describe "#http_error" do
82
- before { globals[:raise_errors] = false }
83
-
84
- it "should return nil in case the response seems to be ok" do
85
- expect(soap_response.http_error).to be_nil
86
- end
87
-
88
- it "should return a HTTPError in case of an HTTP error" do
89
- expect(soap_response(:code => 500).http_error).to be_a(Savon::HTTPError)
90
- end
91
- end
92
-
93
- describe "#header" do
94
- it "should return the SOAP response header as a Hash" do
95
- response = soap_response :body => Fixture.response(:header)
96
- expect(response.header).to include(:session_number => "ABCD1234")
97
- end
98
-
99
- it 'respects the global :strip_namespaces option' do
100
- globals[:strip_namespaces] = false
101
-
102
- response_with_header = soap_response(:body => Fixture.response(:header))
103
- header = response_with_header.header
104
-
105
- expect(header).to be_a(Hash)
106
-
107
- # notice: :session_number is a snake_case Symbol without namespaces,
108
- # but the Envelope and Header elements are qualified.
109
- expect(header.keys).to include(:session_number)
110
- end
111
-
112
- it 'respects the global :convert_response_tags_to option' do
113
- globals[:convert_response_tags_to] = lambda { |key| key.upcase }
114
-
115
- response_with_header = soap_response(:body => Fixture.response(:header))
116
- header = response_with_header.header
117
-
118
- expect(header).to be_a(Hash)
119
- expect(header.keys).to include('SESSIONNUMBER')
120
- end
121
-
122
- it 'respects the global :convert_attributes_to option' do
123
- globals[:convert_attributes_to] = lambda { |k,v| [] }
124
-
125
- response_with_header = soap_response(:body => Fixture.response(:header))
126
- header = response_with_header.header
127
-
128
- expect(header).to be_a(Hash)
129
- expect(header.keys).to include(:session_number)
130
- end
131
-
132
- it "should throw an exception when the response header isn't parsable" do
133
- expect { invalid_soap_response.header }.to raise_error Savon::InvalidResponseError
134
- end
135
- end
136
-
137
- %w(body to_hash).each do |method|
138
- describe "##{method}" do
139
- it "should return the SOAP response body as a Hash" do
140
- expect(soap_response.send(method)[:authenticate_response][:return]).to eq(
141
- Fixture.response_hash(:authentication)[:authenticate_response][:return]
142
- )
143
- end
144
-
145
- it "should return a Hash for a SOAP multiRef response" do
146
- hash = soap_response(:body => Fixture.response(:multi_ref)).send(method)
147
-
148
- expect(hash[:list_response]).to be_a(Hash)
149
- expect(hash[:multi_ref]).to be_an(Array)
150
- end
151
-
152
- it "should add existing namespaced elements as an array" do
153
- hash = soap_response(:body => Fixture.response(:list)).send(method)
154
-
155
- expect(hash[:multi_namespaced_entry_response][:history]).to be_a(Hash)
156
- expect(hash[:multi_namespaced_entry_response][:history][:case]).to be_an(Array)
157
- end
158
-
159
- it 'respects the global :strip_namespaces option' do
160
- globals[:strip_namespaces] = false
161
-
162
- body = soap_response.body
163
-
164
- expect(body).to be_a(Hash)
165
- expect(body.keys).to include(:"ns2:authenticate_response")
166
- end
167
-
168
- it 'respects the global :convert_response_tags_to option' do
169
- globals[:convert_response_tags_to] = lambda { |key| key.upcase }
170
-
171
- body = soap_response.body
172
-
173
- expect(body).to be_a(Hash)
174
- expect(body.keys).to include('AUTHENTICATERESPONSE')
175
- end
176
- end
177
- end
178
-
179
- describe "#to_array" do
180
- context "when the given path exists" do
181
- it "should return an Array containing the path value" do
182
- expect(soap_response.to_array(:authenticate_response, :return)).to eq(
183
- [Fixture.response_hash(:authentication)[:authenticate_response][:return]]
184
- )
185
- end
186
-
187
- it "should properly return FalseClass values [#327]" do
188
- body = Gyoku.xml(:envelope => { :body => { :return => { :success => false } } })
189
- expect(soap_response(:body => body).to_array(:return, :success)).to eq([false])
190
- end
191
- end
192
-
193
- context "when the given path returns nil" do
194
- it "should return an empty Array" do
195
- expect(soap_response.to_array(:authenticate_response, :undefined)).to eq([])
196
- end
197
- end
198
-
199
- context "when the given path does not exist at all" do
200
- it "should return an empty Array" do
201
- expect(soap_response.to_array(:authenticate_response, :some, :undefined, :path)).to eq([])
202
- end
203
- end
204
- end
205
-
206
- describe "#hash" do
207
- it "should return the complete SOAP response XML as a Hash" do
208
- response = soap_response :body => Fixture.response(:header)
209
- expect(response.hash[:envelope][:header][:session_number]).to eq("ABCD1234")
210
- end
211
- end
212
-
213
- describe "#to_xml" do
214
- it "should return the raw SOAP response body" do
215
- expect(soap_response.to_xml).to eq(Fixture.response(:authentication))
216
- end
217
- end
218
-
219
- describe "#doc" do
220
- it "returns a Nokogiri::XML::Document for the SOAP response XML" do
221
- expect(soap_response.doc).to be_a(Nokogiri::XML::Document)
222
- end
223
- end
224
-
225
- describe "#xpath" do
226
- it "permits XPath access to elements in the request" do
227
- expect(soap_response.xpath("//client").first.inner_text).to eq("radclient")
228
- expect(soap_response.xpath("//ns2:authenticateResponse/return/success").first.inner_text).to eq("true")
229
- end
230
- end
231
-
232
- describe '#find' do
233
- it 'delegates to Nori#find to find child elements inside the Envelope' do
234
- result = soap_response.find('Body', 'authenticateResponse', 'return')
235
-
236
- expect(result).to be_a(Hash)
237
- expect(result.keys).to include(:authentication_value)
238
- end
239
-
240
- it 'fails correctly when envelope contains only string' do
241
- response = soap_response({ :body => Fixture.response(:no_body) })
242
- expect { response.find('Body') }.to raise_error Savon::InvalidResponseError
243
- end
244
- end
245
-
246
- describe "#http" do
247
- it "should return the HTTPI::Response" do
248
- expect(soap_response.http).to be_an(HTTPI::Response)
249
- end
250
- end
251
-
252
- def soap_response(options = {})
253
- defaults = { :code => 200, :headers => {}, :body => Fixture.response(:authentication) }
254
- response = defaults.merge options
255
- http_response = HTTPI::Response.new(response[:code], response[:headers], response[:body])
256
-
257
- Savon::Response.new(http_response, globals, locals)
258
- end
259
-
260
- def soap_fault_response
261
- soap_response :code => 500, :body => Fixture.response(:soap_fault)
262
- end
263
-
264
- def http_error_response
265
- soap_response :code => 404, :body => "Not found"
266
- end
267
-
268
- def invalid_soap_response(options = {})
269
- defaults = { :code => 200, :headers => {}, :body => "I'm not SOAP" }
270
- response = defaults.merge options
271
- http_response = HTTPI::Response.new(response[:code], response[:headers], response[:body])
272
-
273
- Savon::Response.new(http_response, globals, locals)
274
- end
275
-
276
- end
@@ -1,147 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- RSpec.describe Savon::SOAPFault do
5
- let(:soap_fault) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault)), nori }
6
- let(:empty_soap_fault) { Savon::SOAPFault.new new_response(:body => Fixture.response(:empty_soap_fault)), nori }
7
- let(:soap_fault2) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault12)), nori }
8
- let(:soap_fault_funky) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault_funky)), nori }
9
- let(:soap_fault_nc) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault)), nori_no_convert }
10
- let(:soap_fault_nc2) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault12)), nori_no_convert }
11
- let(:another_soap_fault) { Savon::SOAPFault.new new_response(:body => Fixture.response(:another_soap_fault)), nori }
12
- let(:soap_fault_no_body) { Savon::SOAPFault.new new_response(:body => {}), nori }
13
- let(:no_fault) { Savon::SOAPFault.new new_response, nori }
14
-
15
- let(:nori) { Nori.new(:strip_namespaces => true, :convert_tags_to => lambda { |tag| tag.snakecase.to_sym }) }
16
- let(:nori_no_convert) { Nori.new(:strip_namespaces => true, :convert_tags_to => nil) }
17
-
18
- it "inherits from Savon::Error" do
19
- expect(Savon::SOAPFault.ancestors).to include(Savon::Error)
20
- end
21
-
22
- describe "#http" do
23
- it "returns the HTTPI::Response" do
24
- expect(soap_fault.http).to be_an(HTTPI::Response)
25
- end
26
- end
27
-
28
- describe ".present?" do
29
- it "returns true if the HTTP response contains a SOAP 1.1 fault" do
30
- http = new_response(:body => Fixture.response(:soap_fault))
31
- expect(Savon::SOAPFault.present? http).to be_truthy
32
- end
33
-
34
- it "returns true if the HTTP response contains a SOAP 1.1 fault with empty fault tags" do
35
- http = new_response(:body => Fixture.response(:empty_soap_fault))
36
- expect(Savon::SOAPFault.present? http).to be_truthy
37
- end
38
-
39
- it "returns true if the HTTP response contains a SOAP 1.2 fault" do
40
- http = new_response(:body => Fixture.response(:soap_fault12))
41
- expect(Savon::SOAPFault.present? http).to be_truthy
42
- end
43
-
44
- it "returns true if the HTTP response contains a SOAP fault with different namespaces" do
45
- http = new_response(:body => Fixture.response(:another_soap_fault))
46
- expect(Savon::SOAPFault.present? http).to be_truthy
47
- end
48
-
49
- it "returns false unless the HTTP response contains a SOAP fault" do
50
- expect(Savon::SOAPFault.present? new_response).to be_falsey
51
- end
52
- end
53
-
54
- [:message, :to_s].each do |method|
55
- describe "##{method}" do
56
- it "returns a SOAP 1.1 fault message" do
57
- expect(soap_fault.send method).to eq("(soap:Server) Fault occurred while processing.")
58
- end
59
-
60
- it "returns an empty fault message" do
61
- expect(empty_soap_fault.send method).to eq(nil)
62
- end
63
-
64
- it "returns a SOAP 1.2 fault message" do
65
- expect(soap_fault2.send method).to eq("(soap:Sender) Sender Timeout")
66
- end
67
-
68
- it "returns a SOAP fault message (with different namespaces)" do
69
- expect(another_soap_fault.send method).to eq("(ERR_NO_SESSION) Wrong session message")
70
- end
71
-
72
- it "works even if the keys are different in a SOAP 1.1 fault message" do
73
- expect(soap_fault_nc.send method).to eq("(soap:Server) Fault occurred while processing.")
74
- end
75
-
76
- it "works even if the keys are different in a SOAP 1.2 fault message" do
77
- expect(soap_fault_nc2.send method).to eq("(soap:Sender) Sender Timeout")
78
- end
79
-
80
- it "works even if the keys are different in a funky SOAP fault message" do
81
- expect(soap_fault_funky.send method).to eq("(42) The Answer to Life The Universe And Everything")
82
- end
83
- end
84
- end
85
-
86
- describe "#to_hash" do
87
- it "returns the SOAP response as a Hash unless a SOAP fault is present" do
88
- expect(no_fault.to_hash[:authenticate_response][:return][:success]).to be_truthy
89
- end
90
-
91
- it "returns a SOAP 1.1 fault as a Hash" do
92
- expected = {
93
- :fault => {
94
- :faultstring => "Fault occurred while processing.",
95
- :faultcode => "soap:Server"
96
- }
97
- }
98
-
99
- expect(soap_fault.to_hash).to eq(expected)
100
- end
101
-
102
- it "returns a SOAP 1.2 fault as a Hash" do
103
- expected = {
104
- :fault => {
105
- :detail => { :max_time => "P5M" },
106
- :reason => { :text => "Sender Timeout" },
107
- :code => { :value => "soap:Sender", :subcode => { :value => "m:MessageTimeout" } }
108
- }
109
- }
110
-
111
- expect(soap_fault2.to_hash).to eq(expected)
112
- end
113
-
114
- it "works even if the keys are different" do
115
- expected = {
116
- "Fault" => {
117
- "Code" => {
118
- "Value" => "soap:Sender",
119
- "Subcode"=> {
120
- "Value" => "m:MessageTimeout"
121
- }
122
- },
123
- "Reason" => {
124
- "Text" => "Sender Timeout"
125
- },
126
- "Detail" => {
127
- "MaxTime" => "P5M"
128
- }
129
- }
130
- }
131
-
132
- expect(soap_fault_nc2.to_hash).to eq(expected)
133
- end
134
-
135
- it "returns empty hash" do
136
- expect(soap_fault_no_body.to_hash).to eq({})
137
- end
138
- end
139
-
140
- def new_response(options = {})
141
- defaults = { :code => 500, :headers => {}, :body => Fixture.response(:authentication) }
142
- response = defaults.merge options
143
-
144
- HTTPI::Response.new response[:code], response[:headers], response[:body]
145
- end
146
-
147
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- RSpec.describe Savon::Builder do
5
-
6
- subject(:builder) { Savon::Builder.new(:create_object, wsdl, globals, locals) }
7
-
8
- let(:globals) { Savon::GlobalOptions.new }
9
- # let(:locals) { Savon::LocalOptions.new }
10
- let(:wsdl) { Wasabi::Document.new Fixture.wsdl(:brand) }
11
- let(:no_wsdl) { Wasabi::Document.new }
12
-
13
- describe "#to_s" do
14
- it "defaults to include the default envelope namespace of :env" do
15
- message = {
16
- :message=>{
17
- :template_object=>{
18
- :longName=>"Zertico LLC Reseller"
19
- }
20
- }
21
- }
22
-
23
- expected_namespaces = {
24
- 'xmlns' => "http://schemas.xmlsoap.org/wsdl/",
25
- 'xmlns:xsd' => "http://www.w3.org/2001/XMLSchema",
26
- 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
27
- 'xmlns:tns' => "http://api.service.softlayer.com/soap/v3/",
28
- 'xmlns:env' => "http://schemas.xmlsoap.org/soap/envelope/",
29
- 'xmlns:soap' => "http://schemas.xmlsoap.org/wsdl/soap/",
30
- 'xmlns:soap-enc' => "http://schemas.xmlsoap.org/soap/encoding/",
31
- 'xmlns:wsdl' => "http://schemas.xmlsoap.org/wsdl/"
32
- }
33
-
34
- locals = Savon::LocalOptions.new(message)
35
- builder = Savon::Builder.new(:create_object, wsdl, globals, locals)
36
-
37
- envelope = Nokogiri::XML(builder.to_s).xpath('./env:Envelope').first
38
-
39
- expect(envelope.namespaces).to match(expected_namespaces)
40
- end
41
- end
42
- end
data/spec/spec_helper.rb DELETED
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
- require "bundler"
3
- require "byebug"
4
- Bundler.setup(:default, :development)
5
-
6
- unless RUBY_PLATFORM =~ /java/
7
- require "simplecov"
8
- SimpleCov.start do
9
- add_filter "spec"
10
- end
11
- end
12
-
13
- require "savon"
14
- require "rspec"
15
-
16
- # don't have HTTPI lazy-load HTTPClient, because then
17
- # it can't actually be refered to inside the specs.
18
- require "httpclient"
19
-
20
- support_files = File.expand_path("spec/support/**/*.rb")
21
- Dir[support_files].sort.each { |file| require file }
22
-
23
- RSpec.configure do |config|
24
- config.include SpecSupport
25
- config.mock_with :mocha
26
- config.order = "random"
27
- config.example_status_persistence_file_path = ".rspec_status"
28
- config.disable_monkey_patching!
29
- end
30
-
31
- HTTPI.log = false
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'httpi/adapter/httpclient'
3
-
4
- # Proxy adapter. Records all requests and passes them to HTTPClient
5
- class AdapterForTest < HTTPI::Adapter::Base
6
-
7
- register :adapter_for_test
8
-
9
- def initialize(request)
10
- @@requests ||= []
11
- @@requests.push request
12
- @request = request
13
- @worker = HTTPI::Adapter::HTTPClient.new(request)
14
- end
15
-
16
- def client
17
- @worker.client
18
- end
19
-
20
- def request(method)
21
- @@methods ||= []
22
- @@methods.push method
23
- @worker.request(method)
24
- end
25
-
26
- end
27
-
28
- # Fake adapter with request recording.
29
- # Takes path from url and returns fixture WSDL with that name.
30
- class FakeAdapterForTest < HTTPI::Adapter::Base
31
-
32
- register :fake_adapter_for_test
33
-
34
- def initialize(request)
35
- @@requests ||= []
36
- @@requests.push request
37
- @request = request
38
- end
39
-
40
- attr_reader :client
41
-
42
- def request(method)
43
- @@methods ||= []
44
- @@methods.push method
45
- target = @request.url.path.to_sym
46
- HTTPI::Response.new(200, {}, Fixture.wsdl(target))
47
- end
48
-
49
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
- class Endpoint
3
- class << self
4
-
5
- # Returns the WSDL endpoint for a given +type+ of request.
6
- def wsdl(type = nil)
7
- case type
8
- when :no_namespace then "http://nons.example.com/Service?wsdl"
9
- when :namespaced_actions then "http://nsactions.example.com/Service?wsdl"
10
- when :geotrust then "https://test-api.geotrust.com/webtrust/query.jws?WSDL"
11
- else soap(type)
12
- end
13
- end
14
-
15
- # Returns the SOAP endpoint for a given +type+ of request.
16
- def soap(type = nil)
17
- case type
18
- when :soap_fault then "http://soapfault.example.com/Service?wsdl"
19
- when :http_error then "http://httperror.example.com/Service?wsdl"
20
- when :invalid then "http://invalid.example.com/Service?wsdl"
21
- else "http://example.com/validation/1.0/AuthenticationService"
22
- end
23
- end
24
-
25
- end
26
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
- class Fixture
3
-
4
- TYPES = { :gzip => "gz", :response => "xml", :wsdl => "xml" }
5
-
6
- class << self
7
-
8
- def [](type, fixture)
9
- fixtures(type)[fixture] ||= read_file type, fixture
10
- end
11
-
12
- def response_hash(fixture)
13
- @response_hash ||= {}
14
- @response_hash[fixture] ||= nori.parse(response(fixture))[:envelope][:body]
15
- end
16
-
17
- TYPES.each do |type, ext|
18
- define_method(type) { |fixture| self[type, fixture] }
19
- end
20
-
21
- private
22
-
23
- def nori
24
- Nori.new(:strip_namespaces => true, :convert_tags_to => lambda { |tag| tag.snakecase.to_sym })
25
- end
26
-
27
- def fixtures(type)
28
- @fixtures ||= {}
29
- @fixtures[type] ||= {}
30
- end
31
-
32
- def read_file(type, fixture)
33
- path = File.expand_path "../../fixtures/#{type}/#{fixture}.#{TYPES[type]}", __FILE__
34
- raise ArgumentError, "Unable to load: #{path}" unless File.exist? path
35
-
36
- File.read path
37
- end
38
-
39
- end
40
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- module SpecSupport
3
-
4
- def call_and_fail_gracefully(client, *args, &block)
5
- client.call(*args, &block)
6
- rescue Savon::SOAPFault => e
7
- puts e.message
8
- end
9
-
10
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
- module SpecSupport
3
-
4
- def mock_stdout
5
- original_stdout = $stdout
6
-
7
- stdout = StringIO.new
8
- $stdout = stdout
9
-
10
- yield
11
-
12
- $stdout = original_stdout
13
- stdout
14
- end
15
-
16
- def silence_stdout
17
- original_stdout = $stdout
18
- $stdout = StringIO.new
19
-
20
- result = yield
21
-
22
- $stdout = original_stdout
23
- result
24
- end
25
-
26
- end