soap-object 0.5.1 → 0.6

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.
@@ -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
@@ -1,5 +1,5 @@
1
- module Soap
2
- module Object
3
- VERSION = "0.5.1"
4
- end
5
- end
1
+ module Soap
2
+ module Object
3
+ VERSION = "0.6"
4
+ end
5
+ end
@@ -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 TestWorld
18
- include SoapObject::Factory
19
- end
20
-
21
-
22
- describe SoapObject do
23
- let(:client) { double('client') }
24
- let(:subject) { TestServiceWithWsdl.new }
25
-
26
-
27
- context "when creating new instances" do
28
- before do
29
- Savon.should_receive(:client).and_return(client)
30
- end
31
-
32
- it "should initialize the client using the wsdl" do
33
- subject.send(:client_properties)[:wsdl].should == 'http://blah.com'
34
- end
35
-
36
- it "should know when it is connected to service" do
37
- subject.should be_connected
38
- end
39
-
40
- it "should allow one to setup a proxy" do
41
- subject.send(:client_properties)[:proxy].should == 'http://proxy.com:8080'
42
- end
43
-
44
- it "should allow one to set an open timeout" do
45
- subject.send(:client_properties)[:open_timeout].should == 10
46
- end
47
-
48
- it "should allow one to set a read timeout" do
49
- subject.send(:client_properties)[:read_timeout].should == 20
50
- end
51
-
52
- it "should allow one to set a soap header" do
53
- subject.send(:client_properties)[:soap_header].should == {'Token' => 'secret'}
54
- end
55
-
56
- it "should allow one to set the encoding" do
57
- subject.send(:client_properties)[:encoding].should == 'UTF-16'
58
- end
59
-
60
- it "should allow one to use basic authentication" do
61
- subject.send(:client_properties)[:basic_auth].should == ['steve', 'secret']
62
- end
63
-
64
- it "should allow one to use digest authentication" do
65
- subject.send(:client_properties)[:digest_auth].should == ['digest', 'auth']
66
- end
67
-
68
- it "should allow one to set the log level" do
69
- subject.send(:client_properties)[:log_level].should == :error
70
- end
71
- end
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
-
95
- context "when calling methods on the service" do
96
- before do
97
- Savon.should_receive(:client).and_return(client)
98
- end
99
-
100
- it "should make a valid request" do
101
- response = double('response')
102
- response.should_receive(:to_xml)
103
- client.should_receive(:call).with(:fake_call, message: {data_key: 'some_value'}).and_return(response)
104
- @so = TestServiceWithWsdl.new
105
- @so.fake_call data_key: 'some_value'
106
- end
107
- end
108
- end
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
@@ -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.5.1
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: 2013-06-01 00:00:00.000000000 Z
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.3
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