soap-object 0.5.1 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +20 -20
- data/.rspec +1 -1
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/ChangeLog +38 -33
- data/Gemfile +11 -11
- data/Guardfile +17 -17
- data/LICENSE.txt +21 -21
- data/README.md +42 -42
- data/Rakefile +21 -21
- data/cucumber.yml +6 -6
- data/features/basic_functionality.feature +40 -40
- data/features/step_definitions/basic_functionality_steps.rb +89 -89
- data/features/support/env.rb +5 -5
- data/features/wsdl/uszip.asmx.wsdl.xml +394 -394
- data/lib/soap-object.rb +120 -114
- data/lib/soap-object/class_methods.rb +111 -111
- data/lib/soap-object/factory.rb +22 -22
- data/lib/soap-object/version.rb +5 -5
- data/soap-object.gemspec +24 -24
- data/spec/lib/soap_object_spec.rb +125 -108
- data/spec/spec_helper.rb +6 -6
- metadata +13 -11
data/lib/soap-object/factory.rb
CHANGED
@@ -1,22 +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
|
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
@@ -1,5 +1,5 @@
|
|
1
|
-
module Soap
|
2
|
-
module Object
|
3
|
-
VERSION = "0.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module Soap
|
2
|
+
module Object
|
3
|
+
VERSION = "0.6"
|
4
|
+
end
|
5
|
+
end
|
data/soap-object.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'soap-object/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |gem|
|
7
|
-
gem.name = "soap-object"
|
8
|
-
gem.version = Soap::Object::VERSION
|
9
|
-
gem.authors = ["Jeffrey S. Morgan"]
|
10
|
-
gem.email = ["jeff.morgan@leandog.com"]
|
11
|
-
gem.description = %q{Wrapper around SOAP service calls to make it easy to test}
|
12
|
-
gem.summary = %q{Wrapper around SOAP service calls to make it easy to test}
|
13
|
-
gem.homepage = "http://github.com/cheezy/soap-object"
|
14
|
-
|
15
|
-
gem.files = `git ls-files`.split($/)
|
16
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = ["lib"]
|
19
|
-
|
20
|
-
gem.add_dependency 'savon', '>= 2.2.0'
|
21
|
-
|
22
|
-
gem.add_development_dependency 'rspec', '>= 2.12.0'
|
23
|
-
gem.add_development_dependency 'cucumber', '>= 1.2.0'
|
24
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'soap-object/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "soap-object"
|
8
|
+
gem.version = Soap::Object::VERSION
|
9
|
+
gem.authors = ["Jeffrey S. Morgan", "Doug Morgan"]
|
10
|
+
gem.email = ["jeff.morgan@leandog.com", "douglas.morgan3405@gmail.com"]
|
11
|
+
gem.description = %q{Wrapper around SOAP service calls to make it easy to test}
|
12
|
+
gem.summary = %q{Wrapper around SOAP service calls to make it easy to test}
|
13
|
+
gem.homepage = "http://github.com/cheezy/soap-object"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'savon', '>= 2.2.0'
|
21
|
+
|
22
|
+
gem.add_development_dependency 'rspec', '>= 2.12.0'
|
23
|
+
gem.add_development_dependency 'cucumber', '>= 1.2.0'
|
24
|
+
end
|
@@ -1,108 +1,125 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class TestServiceWithWsdl
|
4
|
-
include SoapObject
|
5
|
-
|
6
|
-
wsdl 'http://blah.com'
|
7
|
-
proxy 'http://proxy.com:8080'
|
8
|
-
open_timeout 10
|
9
|
-
read_timeout 20
|
10
|
-
soap_header 'Token' => 'secret'
|
11
|
-
encoding 'UTF-16'
|
12
|
-
basic_auth 'steve', 'secret'
|
13
|
-
digest_auth 'digest', 'auth'
|
14
|
-
log_level :error
|
15
|
-
end
|
16
|
-
|
17
|
-
class
|
18
|
-
include SoapObject
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
it "should create
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestServiceWithWsdl
|
4
|
+
include SoapObject
|
5
|
+
|
6
|
+
wsdl 'http://blah.com'
|
7
|
+
proxy 'http://proxy.com:8080'
|
8
|
+
open_timeout 10
|
9
|
+
read_timeout 20
|
10
|
+
soap_header 'Token' => 'secret'
|
11
|
+
encoding 'UTF-16'
|
12
|
+
basic_auth 'steve', 'secret'
|
13
|
+
digest_auth 'digest', 'auth'
|
14
|
+
log_level :error
|
15
|
+
end
|
16
|
+
|
17
|
+
class TestServiceWithOutLogging
|
18
|
+
include SoapObject
|
19
|
+
end
|
20
|
+
|
21
|
+
class TestWorld
|
22
|
+
include SoapObject::Factory
|
23
|
+
end
|
24
|
+
|
25
|
+
describe SoapObject do
|
26
|
+
let(:client) { double('client') }
|
27
|
+
let(:subject) { TestServiceWithWsdl.new }
|
28
|
+
|
29
|
+
context "when creating new instances" do
|
30
|
+
before do
|
31
|
+
allow(Savon).to receive(:client).and_return(client)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should initialize the client using the wsdl" do
|
35
|
+
expect(subject.send(:client_properties)[:wsdl]).to eq('http://blah.com')
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should know when it is connected to service" do
|
39
|
+
expect(subject).to be_connected
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should allow one to setup a proxy" do
|
43
|
+
expect(subject.send(:client_properties)[:proxy]).to eq('http://proxy.com:8080')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should allow one to set an open timeout" do
|
47
|
+
expect(subject.send(:client_properties)[:open_timeout]).to eq(10)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should allow one to set a read timeout" do
|
51
|
+
expect(subject.send(:client_properties)[:read_timeout]).to eq(20)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should allow one to set a soap header" do
|
55
|
+
expect(subject.send(:client_properties)[:soap_header]).to eq({'Token' => 'secret'})
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should allow one to set the encoding" do
|
59
|
+
expect(subject.send(:client_properties)[:encoding]).to eq('UTF-16')
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should allow one to use basic authentication" do
|
63
|
+
expect(subject.send(:client_properties)[:basic_auth]).to eq(['steve', 'secret'])
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should allow one to use digest authentication" do
|
67
|
+
expect(subject.send(:client_properties)[:digest_auth]).to eq(['digest', 'auth'])
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should disable logging when no logging level set" do
|
71
|
+
expect(TestServiceWithOutLogging.new.send(:client_properties)[:log]).to eq(false)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should enable logging when logging level set" do
|
75
|
+
expect(subject.send(:client_properties)[:log]).to eq(true)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should allow one to set the log level" do
|
79
|
+
expect(subject.send(:client_properties)[:log_level]).to eq(:error)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when using the factory to create to service" do
|
85
|
+
let(:world) { TestWorld.new }
|
86
|
+
|
87
|
+
it "should create a valid service object" do
|
88
|
+
service = world.using(TestServiceWithWsdl)
|
89
|
+
expect(service).to be_instance_of TestServiceWithWsdl
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should create a valid service and invoke a block" do
|
93
|
+
world.using(TestServiceWithWsdl) do |service|
|
94
|
+
expect(service).to be_instance_of TestServiceWithWsdl
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should create the service the first time we use it" do
|
99
|
+
obj = TestServiceWithWsdl.new
|
100
|
+
expect(TestServiceWithWsdl).to receive(:new).once.and_return(obj)
|
101
|
+
world.using(TestServiceWithWsdl)
|
102
|
+
world.using(TestServiceWithWsdl)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "when calling methods on the service" do
|
107
|
+
let(:response) { double('response') }
|
108
|
+
|
109
|
+
before do
|
110
|
+
expect(Savon).to receive(:client).and_return(client)
|
111
|
+
expect(response).to receive(:to_xml)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should make a valid request" do
|
115
|
+
expect(client).to receive(:call).with(:fake_call, message: {data_key: 'some_value'}).and_return(response)
|
116
|
+
subject.fake_call data_key: 'some_value'
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should make a valid request with custom xml" do
|
120
|
+
expected_xml = "<xml><envelope/><data></data></envelope></xml>"
|
121
|
+
expect(client).to receive(:call).with(anything, xml: expected_xml).and_return(response)
|
122
|
+
subject.fake_call expected_xml
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
|
4
|
-
require 'rspec'
|
5
|
-
require 'soap-object'
|
6
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'soap-object'
|
6
|
+
|
metadata
CHANGED
@@ -1,60 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soap-object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey S. Morgan
|
8
|
+
- Doug Morgan
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: savon
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- - '>='
|
18
|
+
- - ! '>='
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: 2.2.0
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- - '>='
|
25
|
+
- - ! '>='
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: 2.2.0
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: rspec
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- - '>='
|
32
|
+
- - ! '>='
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: 2.12.0
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- - '>='
|
39
|
+
- - ! '>='
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: 2.12.0
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: cucumber
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
|
-
- - '>='
|
46
|
+
- - ! '>='
|
46
47
|
- !ruby/object:Gem::Version
|
47
48
|
version: 1.2.0
|
48
49
|
type: :development
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
|
-
- - '>='
|
53
|
+
- - ! '>='
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: 1.2.0
|
55
56
|
description: Wrapper around SOAP service calls to make it easy to test
|
56
57
|
email:
|
57
58
|
- jeff.morgan@leandog.com
|
59
|
+
- douglas.morgan3405@gmail.com
|
58
60
|
executables: []
|
59
61
|
extensions: []
|
60
62
|
extra_rdoc_files: []
|
@@ -90,17 +92,17 @@ require_paths:
|
|
90
92
|
- lib
|
91
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
94
|
requirements:
|
93
|
-
- - '>='
|
95
|
+
- - ! '>='
|
94
96
|
- !ruby/object:Gem::Version
|
95
97
|
version: '0'
|
96
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
99
|
requirements:
|
98
|
-
- - '>='
|
100
|
+
- - ! '>='
|
99
101
|
- !ruby/object:Gem::Version
|
100
102
|
version: '0'
|
101
103
|
requirements: []
|
102
104
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.0
|
105
|
+
rubygems_version: 2.3.0
|
104
106
|
signing_key:
|
105
107
|
specification_version: 4
|
106
108
|
summary: Wrapper around SOAP service calls to make it easy to test
|