reps_client 0.0.1 → 0.1.0

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.
@@ -0,0 +1,49 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
3
+ <soap:Header>
4
+ <wsa:Action>http://www.mdiachieve.com/SaveLeadResponse</wsa:Action>
5
+ <wsa:MessageID>urn:uuid:03f5a9a6-7329-4971-b8dd-b51d34d01a29</wsa:MessageID>
6
+ <wsa:RelatesTo>urn:uuid:748aba76-8c71-4e58-b322-a8981ed17d37</wsa:RelatesTo>
7
+ <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
8
+ <wsse:Security>
9
+ <wsu:Timestamp wsu:Id="Timestamp-7722e938-dc03-42b8-960a-600bd988a153">
10
+ <wsu:Created>2011-12-29T15:42:38Z</wsu:Created>
11
+ <wsu:Expires>2011-12-29T15:47:38Z</wsu:Expires>
12
+ </wsu:Timestamp>
13
+ </wsse:Security>
14
+ </soap:Header>
15
+ <soap:Body>
16
+ <SaveLeadResponse xmlns="http://www.mdiachieve.com/">
17
+ <SaveLeadResult>
18
+ <xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
19
+ <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="BrokenRules" msdata:UseCurrentLocale="true">
20
+ <xs:complexType>
21
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
22
+ <xs:element name="BrokenRules">
23
+ <xs:complexType>
24
+ <xs:sequence>
25
+ <xs:element name="Id" type="xs:int" minOccurs="0"/>
26
+ <xs:element name="RuleBroken" type="xs:string" minOccurs="0"/>
27
+ </xs:sequence>
28
+ </xs:complexType>
29
+ </xs:element>
30
+ </xs:choice>
31
+ </xs:complexType>
32
+ <xs:unique name="Constraint1">
33
+ <xs:selector xpath=".//BrokenRules"/>
34
+ <xs:field xpath="Id"/>
35
+ </xs:unique>
36
+ </xs:element>
37
+ </xs:schema>
38
+ <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
39
+ <DocumentElement xmlns="">
40
+ <BrokenRules>
41
+ <Id>1</Id>
42
+ <RuleBroken>Some rule</RuleBroken>
43
+ </BrokenRules>
44
+ </DocumentElement>
45
+ </diffgr:diffgram>
46
+ </SaveLeadResult>
47
+ </SaveLeadResponse>
48
+ </soap:Body>
49
+ </soap:Envelope>
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
3
+ <soap:Header>
4
+ <wsa:Action>http://www.mdiachieve.com/SaveLeadResponse</wsa:Action>
5
+ <wsa:MessageID>urn:uuid:03f5a9a6-7329-4971-b8dd-b51d34d01a29</wsa:MessageID>
6
+ <wsa:RelatesTo>urn:uuid:748aba76-8c71-4e58-b322-a8981ed17d37</wsa:RelatesTo>
7
+ <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
8
+ <wsse:Security>
9
+ <wsu:Timestamp wsu:Id="Timestamp-7722e938-dc03-42b8-960a-600bd988a153">
10
+ <wsu:Created>2011-12-29T15:42:38Z</wsu:Created>
11
+ <wsu:Expires>2011-12-29T15:47:38Z</wsu:Expires>
12
+ </wsu:Timestamp>
13
+ </wsse:Security>
14
+ </soap:Header>
15
+ <soap:Body>
16
+ <SaveLeadResponse xmlns="http://www.mdiachieve.com/">
17
+ <SaveLeadResult>
18
+ <xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
19
+ <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="BrokenRules" msdata:UseCurrentLocale="true">
20
+ <xs:complexType>
21
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
22
+ <xs:element name="BrokenRules">
23
+ <xs:complexType>
24
+ <xs:sequence>
25
+ <xs:element name="Id" type="xs:int" minOccurs="0"/>
26
+ <xs:element name="RuleBroken" type="xs:string" minOccurs="0"/>
27
+ </xs:sequence>
28
+ </xs:complexType>
29
+ </xs:element>
30
+ </xs:choice>
31
+ </xs:complexType>
32
+ <xs:unique name="Constraint1">
33
+ <xs:selector xpath=".//BrokenRules"/>
34
+ <xs:field xpath="Id"/>
35
+ </xs:unique>
36
+ </xs:element>
37
+ </xs:schema>
38
+ <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"/>
39
+ </SaveLeadResult>
40
+ </SaveLeadResponse>
41
+ </soap:Body>
42
+ </soap:Envelope>
@@ -4,6 +4,10 @@ describe RepsClient::Client do
4
4
  subject { client }
5
5
 
6
6
  after { RepsClient.reset }
7
+ after do
8
+ Savon.log = nil
9
+ Savon.logger = nil
10
+ end
7
11
 
8
12
  let(:client) { RepsClient::Client.new(options) }
9
13
 
@@ -12,12 +16,17 @@ describe RepsClient::Client do
12
16
  let(:password) { 'secret' }
13
17
  let(:namespace) { 'http://foo.com/namespace' }
14
18
  let(:enterprise_key) { 'enterprise_key' }
19
+ let(:debug) { true }
20
+ let(:logger) { mock() }
21
+
15
22
  let(:options) do
16
23
  {:endpoint => endpoint,
17
24
  :username => username,
18
25
  :password => password,
19
26
  :namespace => namespace,
20
- :enterprise_key => enterprise_key}
27
+ :enterprise_key => enterprise_key,
28
+ :debug => debug,
29
+ :logger => logger}
21
30
  end
22
31
 
23
32
  context 'with default configuration' do
@@ -28,6 +37,17 @@ describe RepsClient::Client do
28
37
  its(:username) { should be_nil }
29
38
  its(:password) { should be_nil }
30
39
  its(:enterprise_key) { should be_nil }
40
+ it { should_not be_debug }
41
+ its(:logger) { should be_an_instance_of(Logger) }
42
+
43
+ it 'should disable debug logging in savon' do
44
+ expect { subject }.to change { Savon.log? }.from(true).to(false)
45
+ end
46
+
47
+ it 'should set the default logger on savon' do
48
+ subject
49
+ Savon.logger.should == client.logger
50
+ end
31
51
  end
32
52
 
33
53
  context 'with non-default configuration' do
@@ -36,6 +56,17 @@ describe RepsClient::Client do
36
56
  its(:username) { should == username }
37
57
  its(:password) { should == password }
38
58
  its(:enterprise_key) { should == enterprise_key }
59
+ it { should be_debug }
60
+ its(:logger) { should == logger }
61
+
62
+ it 'should enable debug logging in savon' do
63
+ Savon.log = false
64
+ expect { subject }.to change { Savon.log? }.from(false).to(true)
65
+ end
66
+
67
+ it 'should set the logger on savon' do
68
+ expect { subject }.to change { Savon.logger }.to(logger)
69
+ end
39
70
 
40
71
  describe '#endpoint=' do
41
72
  subject { client.endpoint = new_endpoint }
@@ -192,6 +223,94 @@ describe RepsClient::Client do
192
223
  end
193
224
  end
194
225
 
226
+ describe '#debug=' do
227
+ subject { client.debug = new_debug }
228
+
229
+ context 'with nil' do
230
+ let(:new_debug) { nil }
231
+
232
+ context 'when there is a debug setting configured at the top level' do
233
+ let(:debug) { false }
234
+ before { RepsClient.configure { |config| config.debug = true } }
235
+
236
+ it 'should set the debug flag according to the configuration' do
237
+ expect { subject }.to change { client.debug? }.from(false).to(true)
238
+ end
239
+
240
+ it 'should enable debug logging in savon' do
241
+ expect { subject }.to change { Savon.log? }.from(client.debug).to(true)
242
+ end
243
+ end
244
+
245
+ context 'when there is no debug setting configured at the top level' do
246
+ it 'should set the debug flag to the default' do
247
+ expect { subject }.to change { client.debug? }.from(true).to(false)
248
+ end
249
+
250
+ it 'should disable debug logging in savon' do
251
+ expect { subject }.to change { Savon.log? }.from(client.debug).to(false)
252
+ end
253
+ end
254
+ end
255
+
256
+ context 'with new setting' do
257
+ let(:debug) { false }
258
+ let(:new_debug) { true }
259
+
260
+ it 'should set the debug flag' do
261
+ expect { subject }.to change { client.debug? }.from(false).to(true)
262
+ end
263
+
264
+ it 'should enable debug logging in savon' do
265
+ expect { subject }.to change { Savon.log? }.from(client.debug).to(true)
266
+ end
267
+ end
268
+ end
269
+
270
+ describe "#logger=" do
271
+ subject { client.logger = new_logger }
272
+
273
+ context 'with nil' do
274
+ let(:new_logger) { nil }
275
+ let(:top_logger) { mock }
276
+ context 'when there is a logger configured at the top level' do
277
+ before { RepsClient.configure { |config| config.logger = top_logger } }
278
+
279
+ it 'should set the logger based on the configuration' do
280
+ expect { subject }.to change { client.logger }.from(logger).to(top_logger)
281
+ end
282
+
283
+ it 'should set the savon logger based on the configuration' do
284
+ expect { subject }.to change { Savon.logger }.from(client.logger).to(top_logger)
285
+ end
286
+ end
287
+
288
+ context 'when there is no logger configured at the top level' do
289
+ it 'should set the logger to the default' do
290
+ subject
291
+ client.logger.should be_an_instance_of(Logger)
292
+ end
293
+
294
+ it 'should set the savon logger to the default' do
295
+ subject
296
+ Savon.logger.should == client.logger
297
+ end
298
+ end
299
+ end
300
+
301
+ context 'with custom logger' do
302
+ let(:new_logger) { mock() }
303
+
304
+ it 'should set the logger' do
305
+ expect { subject }.to change { client.logger }.from(logger).to(new_logger)
306
+ end
307
+
308
+ it 'should set the savon logger' do
309
+ expect { subject }.to change { Savon.logger }.to(new_logger)
310
+ end
311
+ end
312
+ end
313
+
195
314
  describe '#soap_client' do
196
315
  subject { client.soap_client }
197
316
 
@@ -211,6 +330,8 @@ describe RepsClient::Client do
211
330
 
212
331
  its(:username) { should == username }
213
332
  its(:password) { should == password }
333
+ it { should be_timestamp }
334
+ its(:created_at) { should be_utc }
214
335
  end
215
336
  end
216
337
  end
@@ -74,14 +74,20 @@ describe 'community methods mixin' do
74
74
  subject { communities }
75
75
  let(:communities) { test_object.get_communities }
76
76
 
77
+ before { savon.stubs(soap_action).returns(fixture_name) }
78
+ let(:soap_action) { 'GetCommunities' }
79
+ let(:fixture_name) { nil }
80
+
77
81
  context 'when there is one community' do
78
- before { savon.stubs('GetCommunities').returns(:single_community) }
82
+ let(:fixture_name) { :single_community }
79
83
 
80
84
  it 'should call the remote service with the correct enterprise key' do
81
- savon.expects('GetCommunities').with(:enterprise_key => enterprise_key).returns(:single_community)
85
+ savon.expects(soap_action).with(:enterprise_key => enterprise_key).returns(fixture_name)
82
86
  subject
83
87
  end
84
88
 
89
+ it_should_behave_like 'a ws-addressing header generator'
90
+
85
91
  it { should be }
86
92
  it { should have(1).community }
87
93
 
@@ -99,13 +105,15 @@ describe 'community methods mixin' do
99
105
  end
100
106
 
101
107
  context 'when there are multiple communities' do
102
- before { savon.stubs('GetCommunities').returns(:multiple_communities) }
108
+ let(:fixture_name) { :multiple_communities }
103
109
 
104
110
  it 'should call the remote service with the correct enterprise key' do
105
- savon.expects('GetCommunities').with(:enterprise_key => enterprise_key).returns(:multiple_communities)
111
+ savon.expects(soap_action).with(:enterprise_key => enterprise_key).returns(:multiple_communities)
106
112
  subject
107
113
  end
108
114
 
115
+ it_should_behave_like 'a ws-addressing header generator'
116
+
109
117
  it { should be }
110
118
  it { should have(2).communities }
111
119
 
@@ -14,6 +14,8 @@ describe RepsClient::Configuration do
14
14
  let(:password) { 'configured password' }
15
15
  let(:namespace) { 'http://configured.namespace.com' }
16
16
  let(:enterprise_key) { 'my_enterprise_key' }
17
+ let(:debug) { true }
18
+ let(:logger) { mock() }
17
19
 
18
20
  after { test_module.reset }
19
21
 
@@ -25,6 +27,9 @@ describe RepsClient::Configuration do
25
27
  its(:username) { should_not be }
26
28
  its(:password) { should_not be }
27
29
  its(:enterprise_key) { should_not be }
30
+ its(:debug) { should == 'false' }
31
+ it { should_not be_debug }
32
+ its(:logger) { should be_an_instance_of Logger }
28
33
  end
29
34
 
30
35
  describe '.configure' do
@@ -38,6 +43,8 @@ describe RepsClient::Configuration do
38
43
  config.password = password
39
44
  config.namespace = namespace
40
45
  config.enterprise_key = enterprise_key
46
+ config.debug = debug
47
+ config.logger = logger
41
48
  end
42
49
  end
43
50
 
@@ -48,6 +55,9 @@ describe RepsClient::Configuration do
48
55
  its(:password) { should == password }
49
56
  its(:namespace) { should == namespace }
50
57
  its(:enterprise_key) { should == enterprise_key }
58
+ its(:debug) { should == 'true' }
59
+ it { should be_debug }
60
+ its(:logger) { should == logger }
51
61
  end
52
62
 
53
63
  context 'with partial configuration' do
@@ -56,6 +66,7 @@ describe RepsClient::Configuration do
56
66
  config.username = username
57
67
  config.password = password
58
68
  config.enterprise_key = enterprise_key
69
+ config.debug = true
59
70
  end
60
71
  end
61
72
 
@@ -66,6 +77,9 @@ describe RepsClient::Configuration do
66
77
  its(:username) { should == username }
67
78
  its(:password) { should == password }
68
79
  its(:enterprise_key) { should == enterprise_key }
80
+ its(:debug) { should == 'true' }
81
+ it { should be_debug }
82
+ its(:logger) { should be_an_instance_of Logger }
69
83
  end
70
84
  end
71
85
 
@@ -79,6 +93,8 @@ describe RepsClient::Configuration do
79
93
  config.password = password
80
94
  config.namespace = namespace
81
95
  config.enterprise_key = enterprise_key
96
+ config.debug = debug
97
+ config.logger = logger
82
98
  end
83
99
  end
84
100
 
@@ -103,6 +119,15 @@ describe RepsClient::Configuration do
103
119
  it 'should clear the enterprise key' do
104
120
  expect { subject }.to change { test_module.enterprise_key }.from(enterprise_key).to(nil)
105
121
  end
122
+
123
+ it 'should reset the debug flag' do
124
+ expect { subject }.to change { test_module.debug? }.from(true).to(false)
125
+ end
126
+
127
+ it 'should reset the logger' do
128
+ subject
129
+ test_module.logger.should be_an_instance_of(Logger)
130
+ end
106
131
  end
107
132
 
108
133
  describe '.options' do
@@ -113,6 +138,8 @@ describe RepsClient::Configuration do
113
138
  config.password = password
114
139
  config.namespace = namespace
115
140
  config.enterprise_key = enterprise_key
141
+ config.debug = debug
142
+ config.logger = logger
116
143
  end
117
144
  end
118
145
 
@@ -128,5 +155,9 @@ describe RepsClient::Configuration do
128
155
  its([:password]) { should == password }
129
156
  it { should have_key(:enterprise_key) }
130
157
  its([:enterprise_key]) { should == enterprise_key }
158
+ it { should have_key(:debug) }
159
+ its([:debug]) { should be_true }
160
+ it { should have_key(:logger) }
161
+ its([:logger]) { should == logger }
131
162
  end
132
163
  end
@@ -775,13 +775,16 @@ describe 'lead methods mixin' do
775
775
 
776
776
  let(:prospect) { nil }
777
777
 
778
- before { savon.stubs('SaveLead').returns(nil) }
778
+ let(:soap_action) { 'SaveLead' }
779
+ let(:fixture_name) { :success }
780
+
781
+ before { savon.stubs(soap_action).returns(fixture_name) }
779
782
 
780
783
  context 'without a community id' do
781
784
  let(:community_id) { nil }
782
785
 
783
786
  it 'should raise an ArgumentError without calling the remote service' do
784
- savon.expects('SaveLead').never
787
+ savon.expects(soap_action).never
785
788
  expect { subject }.to raise_error(ArgumentError)
786
789
  end
787
790
  end
@@ -790,7 +793,7 @@ describe 'lead methods mixin' do
790
793
  let(:community_id) { 'foo' }
791
794
 
792
795
  it 'should raise an ArgumentError without calling the remote service' do
793
- savon.expects('SaveLead').never
796
+ savon.expects(soap_action).never
794
797
  expect { subject }.to raise_error(ArgumentError)
795
798
  end
796
799
  end
@@ -799,7 +802,7 @@ describe 'lead methods mixin' do
799
802
  let(:contact) { nil }
800
803
 
801
804
  it 'should raise an ArgumentError without calling the remote service' do
802
- savon.expects('SaveLead').never
805
+ savon.expects(soap_action).never
803
806
  expect { subject }.to raise_error(ArgumentError)
804
807
  end
805
808
  end
@@ -808,7 +811,7 @@ describe 'lead methods mixin' do
808
811
  let(:contact_attributes) { Hash.new }
809
812
 
810
813
  it 'should raise an ArgumentError without calling the remote service' do
811
- savon.expects('SaveLead').never
814
+ savon.expects(soap_action).never
812
815
  expect { subject }.to raise_error(ArgumentError)
813
816
  end
814
817
  end
@@ -822,28 +825,38 @@ describe 'lead methods mixin' do
822
825
  end
823
826
 
824
827
  it 'should call the remote service with the correct enterprise key' do
825
- savon.expects('SaveLead').with(has_entry(:enterprise_key => enterprise_key)).returns(nil)
828
+ savon.expects(soap_action).with(has_entry(:enterprise_key => enterprise_key)).returns(fixture_name)
826
829
  subject
827
830
  end
828
831
 
829
832
  it 'should call the remote service with the correct community id' do
830
- savon.expects('SaveLead').with(has_entry(:community_id => community_id)).returns(nil)
833
+ savon.expects(soap_action).with(has_entry(:community_id => community_id)).returns(fixture_name)
831
834
  subject
832
835
  end
833
836
 
834
837
  it 'should call the remote service with the correct contact parameters' do
835
- savon.expects('SaveLead').with(has_entry(:new_contact => contact.to_soap_hash)).returns(nil)
838
+ savon.expects(soap_action).with(has_entry(:new_contact => contact.to_soap_hash)).returns(fixture_name)
836
839
  subject
837
840
  end
838
841
 
839
842
  it 'should call the remote service with the correct parameter order' do
840
- savon.expects('SaveLead').with(has_entry(:order! => [:enterprise_key,:community_id,:new_contact])).returns(nil)
843
+ savon.expects(soap_action).with(has_entry(:order! => [:enterprise_key,:community_id,:new_contact])).returns(fixture_name)
841
844
  subject
842
845
  end
843
846
 
847
+ it_should_behave_like 'a ws-addressing header generator'
848
+
844
849
  it_should_behave_like 'a fault handler', 'SaveLead'
845
850
 
846
- # TODO: assert result
851
+ context 'when result is successful' do
852
+ it { should be_true }
853
+ end
854
+
855
+ context 'when result is not successful' do
856
+ let(:fixture_name) { :broken_rule }
857
+
858
+ it { should be_false }
859
+ end
847
860
  end
848
861
 
849
862
  context 'with a prospect' do
@@ -853,7 +866,7 @@ describe 'lead methods mixin' do
853
866
  let(:prospect_attributes) { {:first_name => 'a' * 200} }
854
867
 
855
868
  it 'should raise an ArgumentError without calling the remote service' do
856
- savon.expects('SaveLead').never
869
+ savon.expects(soap_action).never
857
870
  expect { subject }.to raise_error(ArgumentError)
858
871
  end
859
872
  end
@@ -872,33 +885,43 @@ describe 'lead methods mixin' do
872
885
  end
873
886
 
874
887
  it 'should call the remote service with the correct enterprise key' do
875
- savon.expects('SaveLead').with(has_entry(:enterprise_key => enterprise_key)).returns(nil)
888
+ savon.expects(soap_action).with(has_entry(:enterprise_key => enterprise_key)).returns(fixture_name)
876
889
  subject
877
890
  end
878
891
 
879
892
  it 'should call the remote service with the correct community id' do
880
- savon.expects('SaveLead').with(has_entry(:community_id => community_id)).returns(nil)
893
+ savon.expects(soap_action).with(has_entry(:community_id => community_id)).returns(fixture_name)
881
894
  subject
882
895
  end
883
896
 
884
897
  it 'should call the remote service with the correct contact parameters' do
885
- savon.expects('SaveLead').with(has_entry(:new_contact => contact.to_soap_hash)).returns(nil)
898
+ savon.expects(soap_action).with(has_entry(:new_contact => contact.to_soap_hash)).returns(fixture_name)
886
899
  subject
887
900
  end
888
901
 
889
902
  it 'should call the remote service with the correct prospect parameters' do
890
- savon.expects('SaveLead').with(has_entry(:new_prospect => prospect.to_soap_hash)).returns(nil)
903
+ savon.expects(soap_action).with(has_entry(:new_prospect => prospect.to_soap_hash)).returns(fixture_name)
891
904
  subject
892
905
  end
893
906
 
894
907
  it 'should call the remote service with the correct parameter order' do
895
- savon.expects('SaveLead').with(has_entry(:order! => [:enterprise_key,:community_id,:new_contact,:new_prospect])).returns(nil)
908
+ savon.expects(soap_action).with(has_entry(:order! => [:enterprise_key,:community_id,:new_contact,:new_prospect])).returns(fixture_name)
896
909
  subject
897
910
  end
898
911
 
912
+ it_should_behave_like 'a ws-addressing header generator'
913
+
899
914
  it_should_behave_like 'a fault handler', 'SaveLead'
900
915
 
901
- # TODO: assert result
916
+ context 'when result is successful' do
917
+ it { should be_true }
918
+ end
919
+
920
+ context 'when result is not successful' do
921
+ let(:fixture_name) { :broken_rule }
922
+
923
+ it { should be_false }
924
+ end
902
925
  end
903
926
  end
904
927
  end
@@ -150,7 +150,8 @@ describe 'pick list methods mixin' do
150
150
  subject { pick_lists }
151
151
  let(:pick_lists) { test_object.get_pick_lists(community_id) }
152
152
 
153
- before { savon.stubs('GetPickLists').returns(fixture_name) }
153
+ before { savon.stubs(soap_action).returns(fixture_name) }
154
+ let(:soap_action) { 'GetPickLists' }
154
155
  let(:fixture_name) { nil }
155
156
 
156
157
  context 'with a community id' do
data/spec/spec_helper.rb CHANGED
@@ -7,9 +7,6 @@ require 'savon_spec'
7
7
  Dir[File.join(File.dirname(__FILE__), 'support', '*.rb')].each { |f| require f }
8
8
 
9
9
  Savon::Spec::Fixture.path = File.expand_path("../fixtures", __FILE__)
10
- Savon.configure do |config|
11
- config.log = false
12
- end
13
10
 
14
11
  RSpec.configure do |config|
15
12
  config.include FakeFS::SpecHelpers
@@ -1,16 +1,18 @@
1
1
  shared_examples_for 'a pick list requester' do
2
2
  it 'should include the enterprise key when requesting pick lists from the remote service' do
3
- savon.expects('GetPickLists').with(has_entry(:enterprise_key => enterprise_key)).returns(fixture_name)
3
+ savon.expects(soap_action).with(has_entry(:enterprise_key => enterprise_key)).returns(fixture_name)
4
4
  subject
5
5
  end
6
6
 
7
7
  it 'should include the community id when requesting pick lists from the remote service' do
8
- savon.expects('GetPickLists').with(has_entry(:community_id => community_id)).returns(fixture_name)
8
+ savon.expects(soap_action).with(has_entry(:community_id => community_id)).returns(fixture_name)
9
9
  subject
10
10
  end
11
11
 
12
12
  it 'should order the parameters correctly when requesting pick lists from the remote service' do
13
- savon.expects('GetPickLists').with(has_entry(:order! => [:enterprise_key,:community_id])).returns(fixture_name)
13
+ savon.expects(soap_action).with(has_entry(:order! => [:enterprise_key,:community_id])).returns(fixture_name)
14
14
  subject
15
15
  end
16
+
17
+ it_should_behave_like 'a ws-addressing header generator'
16
18
  end
@@ -0,0 +1,33 @@
1
+ # TODO: refactor these examples when savon/savon_spec v1.0 is released
2
+ shared_examples_for 'a ws-addressing header generator' do
3
+ let(:soap_namespaces) { Hash.new }
4
+ before { Savon::SOAP::XML.any_instance.stubs(:namespaces).returns(soap_namespaces) }
5
+
6
+ it 'should define the wsa namespace on the soap envelope' do
7
+ expect { subject }.to change { soap_namespaces['xmlns:wsa'] }.to('http://schemas.xmlsoap.org/ws/2004/08/addressing')
8
+ end
9
+
10
+ it 'should set the wsa:Action header' do
11
+ qualified_soap_action = URI.join(test_object.namespace, soap_action).to_s
12
+ Savon::SOAP::XML.any_instance.expects(:header=).with(has_entry('wsa:Action' => qualified_soap_action))
13
+ subject
14
+ end
15
+
16
+ it 'should set the wsa:MessageID header to a generated UUID' do
17
+ message_id = 'e4e5a596-6514-4c25-829c-98e136e0794e'
18
+ UUIDTools::UUID.expects(:random_create).returns(UUIDTools::UUID.parse(message_id))
19
+ Savon::SOAP::XML.any_instance.expects(:header=).with(has_entry('wsa:MessageID' => "urn:uuid:#{message_id}"))
20
+ subject
21
+ end
22
+
23
+ it 'should set the wsa:ReplyTo address' do
24
+ reply_to_address = {'wsa:Address' => 'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous'}
25
+ Savon::SOAP::XML.any_instance.expects(:header=).with(has_entry('wsa:ReplyTo' => reply_to_address))
26
+ subject
27
+ end
28
+
29
+ it 'should set the wsa:To header' do
30
+ Savon::SOAP::XML.any_instance.expects(:header=).with(has_entry('wsa:To' => test_object.endpoint))
31
+ subject
32
+ end
33
+ end