soap-object 0.2 → 0.3
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.
- data/ChangeLog +5 -0
- data/lib/soap-object/factory.rb +22 -0
- data/lib/soap-object/version.rb +1 -1
- data/lib/soap-object.rb +3 -2
- data/spec/lib/soap_object_spec.rb +26 -0
- metadata +5 -4
data/ChangeLog
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
module SoapObject
|
3
|
+
module Factory
|
4
|
+
|
5
|
+
def using(cls, &block)
|
6
|
+
@the_service = find_service(cls)
|
7
|
+
block.call @the_service if block
|
8
|
+
@the_service
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def find_service(cls)
|
14
|
+
services[cls] = cls.new unless services[cls]
|
15
|
+
services[cls]
|
16
|
+
end
|
17
|
+
|
18
|
+
def services
|
19
|
+
@services ||= {}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/soap-object/version.rb
CHANGED
data/lib/soap-object.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'savon'
|
2
2
|
require 'soap-object/version'
|
3
3
|
require 'soap-object/class_methods'
|
4
|
+
require 'soap-object/factory'
|
4
5
|
|
5
6
|
#
|
6
7
|
# module to make it simpler to tests SOAP web services. The goal is
|
@@ -25,7 +26,7 @@ require 'soap-object/class_methods'
|
|
25
26
|
# view all of the options.
|
26
27
|
#
|
27
28
|
module SoapObject
|
28
|
-
attr_reader :wsdl
|
29
|
+
attr_reader :wsdl, :response
|
29
30
|
|
30
31
|
def initialize
|
31
32
|
@client = Savon.client(client_properties)
|
@@ -55,7 +56,7 @@ module SoapObject
|
|
55
56
|
|
56
57
|
def method_missing(*args)
|
57
58
|
method = args.shift
|
58
|
-
@response = @client.call(method, {message: args.
|
59
|
+
@response = @client.call(method, {message: args.shift})
|
59
60
|
body_for(method)
|
60
61
|
end
|
61
62
|
|
@@ -14,6 +14,10 @@ class TestServiceWithWsdl
|
|
14
14
|
log_level :error
|
15
15
|
end
|
16
16
|
|
17
|
+
class TestWorld
|
18
|
+
include SoapObject::Factory
|
19
|
+
end
|
20
|
+
|
17
21
|
|
18
22
|
describe SoapObject do
|
19
23
|
let(:client) { double('client') }
|
@@ -66,6 +70,28 @@ describe SoapObject do
|
|
66
70
|
end
|
67
71
|
end
|
68
72
|
|
73
|
+
context "when using the factory to create to service" do
|
74
|
+
let(:world) { TestWorld.new }
|
75
|
+
|
76
|
+
it "should create a valid service object" do
|
77
|
+
service = world.using(TestServiceWithWsdl)
|
78
|
+
service.should be_instance_of TestServiceWithWsdl
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should create a valid service and invoke a block" do
|
82
|
+
world.using(TestServiceWithWsdl) do |service|
|
83
|
+
service.should be_instance_of TestServiceWithWsdl
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should create the service the first time we use it" do
|
88
|
+
obj = TestServiceWithWsdl.new
|
89
|
+
TestServiceWithWsdl.should_receive(:new).once.and_return(obj)
|
90
|
+
world.using(TestServiceWithWsdl)
|
91
|
+
world.using(TestServiceWithWsdl)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
69
95
|
context "when calling methods on the service" do
|
70
96
|
before do
|
71
97
|
Savon.should_receive(:client).and_return(client)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soap-object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- features/wsdl/airport.asmx.wsdl.xml
|
83
83
|
- lib/soap-object.rb
|
84
84
|
- lib/soap-object/class_methods.rb
|
85
|
+
- lib/soap-object/factory.rb
|
85
86
|
- lib/soap-object/version.rb
|
86
87
|
- soap-object.gemspec
|
87
88
|
- spec/lib/soap_object_spec.rb
|
@@ -100,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
101
|
version: '0'
|
101
102
|
segments:
|
102
103
|
- 0
|
103
|
-
hash:
|
104
|
+
hash: 2116803590669444452
|
104
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
106
|
none: false
|
106
107
|
requirements:
|
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
110
|
version: '0'
|
110
111
|
segments:
|
111
112
|
- 0
|
112
|
-
hash:
|
113
|
+
hash: 2116803590669444452
|
113
114
|
requirements: []
|
114
115
|
rubyforge_project:
|
115
116
|
rubygems_version: 1.8.25
|