savon 0.3.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +68 -0
- data/Rakefile +9 -7
- data/VERSION +1 -1
- data/lib/savon.rb +33 -34
- data/lib/savon/client.rb +96 -0
- data/lib/savon/core_ext.rb +6 -0
- data/lib/savon/core_ext/datetime.rb +8 -0
- data/lib/savon/core_ext/hash.rb +65 -0
- data/lib/savon/core_ext/object.rb +14 -0
- data/lib/savon/core_ext/string.rb +41 -0
- data/lib/savon/core_ext/symbol.rb +8 -0
- data/lib/savon/core_ext/uri.rb +10 -0
- data/lib/savon/request.rb +103 -0
- data/lib/savon/soap.rb +71 -0
- data/lib/savon/validation.rb +57 -0
- data/lib/savon/wsdl.rb +39 -41
- data/lib/savon/wsse.rb +111 -0
- data/spec/fixtures/multiple_user_response.xml +22 -0
- data/spec/fixtures/soap_fault.xml +0 -0
- data/spec/fixtures/user_fixture.rb +42 -0
- data/spec/fixtures/user_response.xml +4 -2
- data/spec/fixtures/user_wsdl.xml +0 -0
- data/spec/http_stubs.rb +20 -0
- data/spec/savon/client_spec.rb +144 -0
- data/spec/savon/core_ext/datetime_spec.rb +12 -0
- data/spec/savon/core_ext/hash_spec.rb +146 -0
- data/spec/savon/core_ext/object_spec.rb +26 -0
- data/spec/savon/core_ext/string_spec.rb +52 -0
- data/spec/savon/core_ext/symbol_spec.rb +11 -0
- data/spec/savon/core_ext/uri_spec.rb +15 -0
- data/spec/savon/request_spec.rb +93 -0
- data/spec/savon/savon_spec.rb +37 -0
- data/spec/savon/soap_spec.rb +101 -0
- data/spec/savon/validation_spec.rb +88 -0
- data/spec/savon/wsdl_spec.rb +17 -46
- data/spec/savon/wsse_spec.rb +169 -0
- data/spec/spec_helper.rb +7 -92
- data/spec/spec_helper_methods.rb +29 -0
- metadata +68 -20
- data/README.rdoc +0 -62
- data/lib/savon/service.rb +0 -151
- data/spec/savon/service_spec.rb +0 -76
data/spec/savon/service_spec.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "spec_helper")
|
2
|
-
|
3
|
-
describe Savon::Service do
|
4
|
-
include SpecHelper
|
5
|
-
|
6
|
-
# initialize
|
7
|
-
describe "initialize" do
|
8
|
-
it "raises an ArgumentError when called with an invalid endpoint" do
|
9
|
-
["", nil, "invalid", 123].each do |argument|
|
10
|
-
lambda { Savon::Service.new(argument) }.should raise_error(ArgumentError)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it "raises an ArgumentError when called with an invalid version" do
|
15
|
-
["", nil, "invalid", 123].each do |argument|
|
16
|
-
lambda { Savon::Service.new("http://example.com", argument) }.
|
17
|
-
should raise_error(ArgumentError)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# wsdl
|
23
|
-
describe "wsdl" do
|
24
|
-
before { @service = new_service_instance }
|
25
|
-
|
26
|
-
it "returns an instance of Savon::WSDL" do
|
27
|
-
@service.wsdl.should be_a(Savon::WSDL)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns the exact same Savon::WSDL instance every time" do
|
31
|
-
@service.wsdl.should equal(@service.wsdl)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# method_missing
|
36
|
-
describe "method_missing" do
|
37
|
-
before { @service = new_service_instance }
|
38
|
-
|
39
|
-
it "raises a NoMethodError when called with an invalid soap_action" do
|
40
|
-
lambda { @service.invalid_action }.should raise_error(NoMethodError)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "by default returns content from the response using the '//return' XPath" do
|
44
|
-
@service.find_user.should == { :firstname => "The", :lastname => "Dude",
|
45
|
-
:email => "thedude@example.com", :username => "thedude", :id => "123" }
|
46
|
-
end
|
47
|
-
|
48
|
-
it "returns the content of the response starting at a custom XPath" do
|
49
|
-
@service.find_user(nil, "//email").should == "thedude@example.com"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "returns nil if a given XPath does not match anything from the SOAP response" do
|
53
|
-
@service.find_user(nil, "//doesNotMatchAnything").should be_nil
|
54
|
-
end
|
55
|
-
|
56
|
-
it "raises a Savon::SOAPFault in case of a SOAP fault" do
|
57
|
-
@service = new_service_instance(:soap_fault => true)
|
58
|
-
lambda { @service.find_user }.should raise_error(Savon::SOAPFault)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "raises a Savon::HTTPError in case the server returned an error code and no SOAP fault" do
|
62
|
-
@service = new_service_instance(:http_error => true)
|
63
|
-
lambda { @service.find_user }.should raise_error(Savon::HTTPError)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "raises a Savon::SOAPFault in case the server returned an error code and a SOAP fault" do
|
67
|
-
@service = new_service_instance(:soap_fault => true, :http_error => true)
|
68
|
-
lambda { @service.find_user }.should raise_error(Savon::SOAPFault)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "returns the raw response body when :pure_response was set to +true+" do
|
72
|
-
@service.pure_response = true
|
73
|
-
@service.find_user.should == UserFixture.user_response
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|