quest_back 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +147 -0
- data/Rakefile +1 -0
- data/config.example.yml +3 -0
- data/lib/quest_back/api.rb +310 -0
- data/lib/quest_back/configuration.rb +34 -0
- data/lib/quest_back/debug_observer.rb +18 -0
- data/lib/quest_back/error.rb +7 -0
- data/lib/quest_back/response.rb +45 -0
- data/lib/quest_back/version.rb +3 -0
- data/lib/quest_back.rb +57 -0
- data/quest_back.gemspec +27 -0
- data/spec/fixtures/add_email_invitees_success.xml +7 -0
- data/spec/fixtures/add_respondents_data_success.xml +7 -0
- data/spec/fixtures/get_language_list_success.xml +588 -0
- data/spec/fixtures/get_quests_multiple_response_success.xml +50 -0
- data/spec/fixtures/get_quests_success.xml +32 -0
- data/spec/fixtures/quest_back.wsdl +165 -0
- data/spec/fixtures/test_connection_failure.xml +15 -0
- data/spec/fixtures/test_connection_success.xml +8 -0
- data/spec/quest_back/api_spec.rb +257 -0
- data/spec/quest_back/configuration_spec.rb +17 -0
- data/spec/quest_back/response_spec.rb +52 -0
- data/spec/spec_helper.rb +35 -0
- metadata +158 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
|
2
|
+
<s:Body>
|
3
|
+
<GetQuestsResponse xmlns="https://integration.questback.com/2011/03">
|
4
|
+
<GetQuestsResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
5
|
+
<Quests>
|
6
|
+
<Quest>
|
7
|
+
<QuestId>4567668</QuestId>
|
8
|
+
<SecurityLock>m0pI8orKJp</SecurityLock>
|
9
|
+
<QuestTitle>Skalars spørreundersøkelse</QuestTitle>
|
10
|
+
<Startdate>2014-02-18T00:00:00</Startdate>
|
11
|
+
<EndDate>2017-03-01T00:00:00</EndDate>
|
12
|
+
<State>Active</State>
|
13
|
+
<TotalInvitationsSent>0</TotalInvitationsSent>
|
14
|
+
<TotalResponseCount>0</TotalResponseCount>
|
15
|
+
<LastResponseDate>0001-01-01T00:00:00</LastResponseDate>
|
16
|
+
<DefaultLanguageId>2989</DefaultLanguageId>
|
17
|
+
<Languages>
|
18
|
+
<Language>
|
19
|
+
<LanguageId>2989</LanguageId>
|
20
|
+
<LanguageName>Norwegian (Bokmål)</LanguageName>
|
21
|
+
</Language>
|
22
|
+
</Languages>
|
23
|
+
</Quest>
|
24
|
+
</Quests>
|
25
|
+
<PageInfo>
|
26
|
+
<PageSize>10</PageSize>
|
27
|
+
<TotalCount>1</TotalCount>
|
28
|
+
</PageInfo>
|
29
|
+
</GetQuestsResult>
|
30
|
+
</GetQuestsResponse>
|
31
|
+
</s:Body>
|
32
|
+
</s:Envelope>
|
@@ -0,0 +1,165 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:i0="https://integration.questback.com/2011/03" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="QuestBackService" targetNamespace="http://tempuri.org/">
|
3
|
+
<wsp:Policy wsu:Id="BasicHttpBinding_QuestBackIntegrationLibrary_policy">
|
4
|
+
<wsp:ExactlyOne>
|
5
|
+
<wsp:All>
|
6
|
+
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
|
7
|
+
<wsp:Policy>
|
8
|
+
<sp:TransportToken>
|
9
|
+
<wsp:Policy>
|
10
|
+
<sp:HttpsToken RequireClientCertificate="false" />
|
11
|
+
</wsp:Policy>
|
12
|
+
</sp:TransportToken>
|
13
|
+
<sp:AlgorithmSuite>
|
14
|
+
<wsp:Policy>
|
15
|
+
<sp:Basic256 />
|
16
|
+
</wsp:Policy>
|
17
|
+
</sp:AlgorithmSuite>
|
18
|
+
<sp:Layout>
|
19
|
+
<wsp:Policy>
|
20
|
+
<sp:Strict />
|
21
|
+
</wsp:Policy>
|
22
|
+
</sp:Layout>
|
23
|
+
</wsp:Policy>
|
24
|
+
</sp:TransportBinding>
|
25
|
+
</wsp:All>
|
26
|
+
</wsp:ExactlyOne>
|
27
|
+
</wsp:Policy>
|
28
|
+
<wsdl:import namespace="https://integration.questback.com/2011/03" location="https://integration.questback.com/Integration.svc?wsdl=wsdl0" />
|
29
|
+
<wsdl:types />
|
30
|
+
<wsdl:binding name="BasicHttpBinding_QuestBackIntegrationLibrary" type="i0:QuestBackIntegrationLibrary">
|
31
|
+
<wsp:PolicyReference URI="#BasicHttpBinding_QuestBackIntegrationLibrary_policy" />
|
32
|
+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
|
33
|
+
<wsdl:operation name="GetQuests">
|
34
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/GetQuests" style="document" />
|
35
|
+
<wsdl:input>
|
36
|
+
<soap:body use="literal" />
|
37
|
+
</wsdl:input>
|
38
|
+
<wsdl:output>
|
39
|
+
<soap:body use="literal" />
|
40
|
+
</wsdl:output>
|
41
|
+
<wsdl:fault name="QuestBackServiceFaultFault">
|
42
|
+
<soap:fault name="QuestBackServiceFaultFault" use="literal" />
|
43
|
+
</wsdl:fault>
|
44
|
+
</wsdl:operation>
|
45
|
+
<wsdl:operation name="GetQuestQuestions">
|
46
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/GetQuestQuestions" style="document" />
|
47
|
+
<wsdl:input>
|
48
|
+
<soap:body use="literal" />
|
49
|
+
</wsdl:input>
|
50
|
+
<wsdl:output>
|
51
|
+
<soap:body use="literal" />
|
52
|
+
</wsdl:output>
|
53
|
+
</wsdl:operation>
|
54
|
+
<wsdl:operation name="AddEmailInvitees">
|
55
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/AddEmailInvitees" style="document" />
|
56
|
+
<wsdl:input>
|
57
|
+
<soap:body use="literal" />
|
58
|
+
</wsdl:input>
|
59
|
+
<wsdl:output>
|
60
|
+
<soap:body use="literal" />
|
61
|
+
</wsdl:output>
|
62
|
+
</wsdl:operation>
|
63
|
+
<wsdl:operation name="AddRespondentsData">
|
64
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/AddRespondentsData" style="document" />
|
65
|
+
<wsdl:input>
|
66
|
+
<soap:body use="literal" />
|
67
|
+
</wsdl:input>
|
68
|
+
<wsdl:output>
|
69
|
+
<soap:body use="literal" />
|
70
|
+
</wsdl:output>
|
71
|
+
</wsdl:operation>
|
72
|
+
<wsdl:operation name="AddRespondentsDataWithoutEmailInvitation">
|
73
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/AddRespondentsDataWithoutEmailInvitation" style="document" />
|
74
|
+
<wsdl:input>
|
75
|
+
<soap:body use="literal" />
|
76
|
+
</wsdl:input>
|
77
|
+
<wsdl:output>
|
78
|
+
<soap:body use="literal" />
|
79
|
+
</wsdl:output>
|
80
|
+
</wsdl:operation>
|
81
|
+
<wsdl:operation name="AddRespondentsDataWithSmsInvitation">
|
82
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/AddRespondentsDataWithSmsInvitation" style="document" />
|
83
|
+
<wsdl:input>
|
84
|
+
<soap:body use="literal" />
|
85
|
+
</wsdl:input>
|
86
|
+
<wsdl:output>
|
87
|
+
<soap:body use="literal" />
|
88
|
+
</wsdl:output>
|
89
|
+
</wsdl:operation>
|
90
|
+
<wsdl:operation name="GetInvitationResponseCounts">
|
91
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/GetInvitationResponseCounts" style="document" />
|
92
|
+
<wsdl:input>
|
93
|
+
<soap:body use="literal" />
|
94
|
+
</wsdl:input>
|
95
|
+
<wsdl:output>
|
96
|
+
<soap:body use="literal" />
|
97
|
+
</wsdl:output>
|
98
|
+
</wsdl:operation>
|
99
|
+
<wsdl:operation name="GetInviteesInfo">
|
100
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/GetInviteesInfo" style="document" />
|
101
|
+
<wsdl:input>
|
102
|
+
<soap:body use="literal" />
|
103
|
+
</wsdl:input>
|
104
|
+
<wsdl:output>
|
105
|
+
<soap:body use="literal" />
|
106
|
+
</wsdl:output>
|
107
|
+
</wsdl:operation>
|
108
|
+
<wsdl:operation name="GetAnswers">
|
109
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/GetAnswers" style="document" />
|
110
|
+
<wsdl:input>
|
111
|
+
<soap:body use="literal" />
|
112
|
+
</wsdl:input>
|
113
|
+
<wsdl:output>
|
114
|
+
<soap:body use="literal" />
|
115
|
+
</wsdl:output>
|
116
|
+
</wsdl:operation>
|
117
|
+
<wsdl:operation name="GetResponses">
|
118
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/GetResponses" style="document" />
|
119
|
+
<wsdl:input>
|
120
|
+
<soap:body use="literal" />
|
121
|
+
</wsdl:input>
|
122
|
+
<wsdl:output>
|
123
|
+
<soap:body use="literal" />
|
124
|
+
</wsdl:output>
|
125
|
+
</wsdl:operation>
|
126
|
+
<wsdl:operation name="GetRespondentsData">
|
127
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/GetRespondentsData" style="document" />
|
128
|
+
<wsdl:input>
|
129
|
+
<soap:body use="literal" />
|
130
|
+
</wsdl:input>
|
131
|
+
<wsdl:output>
|
132
|
+
<soap:body use="literal" />
|
133
|
+
</wsdl:output>
|
134
|
+
</wsdl:operation>
|
135
|
+
<wsdl:operation name="GetLanguageList">
|
136
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/GetLanguageList" style="document" />
|
137
|
+
<wsdl:input>
|
138
|
+
<soap:body use="literal" />
|
139
|
+
</wsdl:input>
|
140
|
+
<wsdl:output>
|
141
|
+
<soap:body use="literal" />
|
142
|
+
</wsdl:output>
|
143
|
+
<wsdl:fault name="QuestBackServiceFaultFault">
|
144
|
+
<soap:fault name="QuestBackServiceFaultFault" use="literal" />
|
145
|
+
</wsdl:fault>
|
146
|
+
</wsdl:operation>
|
147
|
+
<wsdl:operation name="TestConnection">
|
148
|
+
<soap:operation soapAction="https://integration.questback.com/2011/03/QuestBackIntegrationLibrary/TestConnection" style="document" />
|
149
|
+
<wsdl:input>
|
150
|
+
<soap:body use="literal" />
|
151
|
+
</wsdl:input>
|
152
|
+
<wsdl:output>
|
153
|
+
<soap:body use="literal" />
|
154
|
+
</wsdl:output>
|
155
|
+
<wsdl:fault name="QuestBackServiceFaultFault">
|
156
|
+
<soap:fault name="QuestBackServiceFaultFault" use="literal" />
|
157
|
+
</wsdl:fault>
|
158
|
+
</wsdl:operation>
|
159
|
+
</wsdl:binding>
|
160
|
+
<wsdl:service name="QuestBackService">
|
161
|
+
<wsdl:port name="BasicHttpBinding_QuestBackIntegrationLibrary" binding="tns:BasicHttpBinding_QuestBackIntegrationLibrary">
|
162
|
+
<soap:address location="https://integration.questback.com/Integration.svc" />
|
163
|
+
</wsdl:port>
|
164
|
+
</wsdl:service>
|
165
|
+
</wsdl:definitions>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<s:Body>
|
4
|
+
<s:Fault>
|
5
|
+
<faultcode>s:Client</faultcode>
|
6
|
+
<faultstring xml:lang="nb-NO">Invalid username or password.</faultstring>
|
7
|
+
<detail>
|
8
|
+
<QuestBackServiceFault xmlns="https://integration.questback.com/2011/03" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
9
|
+
<Operation>Authentication</Operation>
|
10
|
+
<ProblemType>Invalid username or password.</ProblemType>
|
11
|
+
</QuestBackServiceFault>
|
12
|
+
</detail>
|
13
|
+
</s:Fault>
|
14
|
+
</s:Body>
|
15
|
+
</s:Envelope>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<s:Body>
|
4
|
+
<TestConnectionResponse xmlns="https://integration.questback.com/2011/03">
|
5
|
+
<TestConnectionResult>Connection sucessful. you are connected to namespace: https://integration.questback.com/2011/03</TestConnectionResult>
|
6
|
+
</TestConnectionResponse>
|
7
|
+
</s:Body>
|
8
|
+
</s:Envelope>
|
@@ -0,0 +1,257 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QuestBack::Api, type: :request do
|
4
|
+
let(:config) do
|
5
|
+
QuestBack::Configuration.new(
|
6
|
+
wsdl: path_to_fixture('quest_back.wsdl'),
|
7
|
+
username: 'my-username',
|
8
|
+
password: 'my-password'
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:expected_default_message) do
|
13
|
+
{
|
14
|
+
user_info: {
|
15
|
+
'Username' => 'my-username',
|
16
|
+
'Password' => 'my-password'
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
subject { described_class.new config: config }
|
22
|
+
|
23
|
+
describe "#client" do
|
24
|
+
it "is a savon client" do
|
25
|
+
expect(subject.client).to be_a Savon::Client
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sets proxy building client" do
|
29
|
+
config.http_proxy = 'http://127.0.0.1/'
|
30
|
+
|
31
|
+
Savon::Client.should_receive(:new).
|
32
|
+
with(hash_including(proxy: 'http://127.0.0.1/')).
|
33
|
+
and_return :client
|
34
|
+
|
35
|
+
expect(subject.client).to eq :client
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
describe "operations" do
|
41
|
+
describe "#test_connection" do
|
42
|
+
context "success" do
|
43
|
+
it "calls with correct message and response is successful" do
|
44
|
+
savon.expects(:test_connection).with(message: expected_default_message).returns success_fixture_for 'test_connection'
|
45
|
+
response = subject.test_connection
|
46
|
+
expect(response).to be_successful
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "failure" do
|
51
|
+
it "raises error" do
|
52
|
+
savon.expects(:test_connection).with(message: :any).returns failure_fixture_for 'test_connection'
|
53
|
+
expect { subject.test_connection }.to raise_error Savon::SOAPFault
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
describe "#get_quests" do
|
61
|
+
it "makes call with expected arguments" do
|
62
|
+
expected_message = expected_default_message.merge(
|
63
|
+
paging_info: {'PageNo' => 0, 'PageSize' => 50},
|
64
|
+
quest_filter: '',
|
65
|
+
order!: QuestBack::Api::ORDER[:get_quests]
|
66
|
+
)
|
67
|
+
|
68
|
+
savon.expects(:get_quests).with(message: expected_message).returns success_fixture_for 'get_quests'
|
69
|
+
response = subject.get_quests
|
70
|
+
expect(response).to be_successful
|
71
|
+
end
|
72
|
+
|
73
|
+
it "is possible to override default paging info" do
|
74
|
+
expected_message = expected_default_message.merge(
|
75
|
+
paging_info: {'PageNo' => 0, 'PageSize' => 1},
|
76
|
+
quest_filter: '',
|
77
|
+
order!: QuestBack::Api::ORDER[:get_quests]
|
78
|
+
)
|
79
|
+
|
80
|
+
savon.expects(:get_quests).with(message: expected_message).returns success_fixture_for 'get_quests'
|
81
|
+
response = subject.get_quests paging_info: {page_size: 1}
|
82
|
+
expect(response).to be_successful
|
83
|
+
end
|
84
|
+
|
85
|
+
it "has expected results" do
|
86
|
+
savon.expects(:get_quests).with(message: :any).returns success_fixture_for 'get_quests'
|
87
|
+
response = subject.get_quests
|
88
|
+
|
89
|
+
result = response.results.first
|
90
|
+
|
91
|
+
expect(result[:quest_id]).to eq '4567668'
|
92
|
+
expect(result[:security_lock]).to eq 'm0pI8orKJp'
|
93
|
+
expect(result[:state]).to eq 'Active'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
describe "#get_language_list" do
|
100
|
+
it "makes call with expected arguments" do
|
101
|
+
savon.expects(:get_language_list).with(message: expected_default_message).returns success_fixture_for 'get_language_list'
|
102
|
+
response = subject.get_language_list
|
103
|
+
expect(response).to be_successful
|
104
|
+
end
|
105
|
+
|
106
|
+
it "has all known languages" do
|
107
|
+
savon.expects(:get_language_list).with(message: :any).returns success_fixture_for 'get_language_list'
|
108
|
+
response = subject.get_language_list
|
109
|
+
|
110
|
+
expect(response.results.length).to eq 145
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
describe "#add_email_invitees" do
|
117
|
+
it "makes call with expected arguments" do
|
118
|
+
expected_message = expected_default_message.merge(
|
119
|
+
quest_info: {'QuestId' => 4567668, 'SecurityLock' => 'm0pI8orKJp'},
|
120
|
+
emails: {'array:string' => ['inviso@skalar.no', 'th@skalar.no']},
|
121
|
+
sendduplicate: false,
|
122
|
+
order!: QuestBack::Api::ORDER[:add_email_invitees] - [:language_id]
|
123
|
+
)
|
124
|
+
|
125
|
+
|
126
|
+
savon.expects(:add_email_invitees).with(message: expected_message).returns success_fixture_for 'add_email_invitees'
|
127
|
+
response = subject.add_email_invitees(
|
128
|
+
quest_info: {
|
129
|
+
quest_id: 4567668,
|
130
|
+
security_lock: 'm0pI8orKJp'
|
131
|
+
},
|
132
|
+
emails: ['inviso@skalar.no', 'th@skalar.no']
|
133
|
+
)
|
134
|
+
expect(response).to be_successful
|
135
|
+
end
|
136
|
+
|
137
|
+
it "is possible to override defaults" do
|
138
|
+
expected_message = expected_default_message.merge(
|
139
|
+
quest_info: {'QuestId' => 4567668, 'SecurityLock' => 'm0pI8orKJp'},
|
140
|
+
emails: {'array:string' => ['inviso@skalar.no', 'th@skalar.no']},
|
141
|
+
sendduplicate: true,
|
142
|
+
order!: QuestBack::Api::ORDER[:add_email_invitees] - [:language_id]
|
143
|
+
)
|
144
|
+
|
145
|
+
savon.expects(:add_email_invitees).with(message: expected_message).returns success_fixture_for 'add_email_invitees'
|
146
|
+
response = subject.add_email_invitees(
|
147
|
+
quest_info: {
|
148
|
+
quest_id: 4567668,
|
149
|
+
security_lock: 'm0pI8orKJp'
|
150
|
+
},
|
151
|
+
emails: ['inviso@skalar.no', 'th@skalar.no'],
|
152
|
+
sendduplicate: true
|
153
|
+
)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "fails if you give it keys which are not known" do
|
157
|
+
expect { subject.add_email_invitees(foo: 'bar') }.to raise_error ArgumentError
|
158
|
+
end
|
159
|
+
|
160
|
+
it "has expected result" do
|
161
|
+
savon.expects(:add_email_invitees).with(message: :any).returns success_fixture_for 'add_email_invitees'
|
162
|
+
response = subject.add_email_invitees(
|
163
|
+
quest_info: {quest_id: 4567668, security_lock: 'm0pI8orKJp'},
|
164
|
+
emails: ['inviso@skalar.no', 'th@skalar.no'],
|
165
|
+
)
|
166
|
+
|
167
|
+
expect(response.result).to eq 'Added 2 invitations to QuestId:4567668'
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
describe "#add_respondents_data" do
|
173
|
+
it "makes call with expected arguments" do
|
174
|
+
expected_message = expected_default_message.merge(
|
175
|
+
quest_info: {'QuestId' => 4567668, 'SecurityLock' => 'm0pI8orKJp'},
|
176
|
+
respondents_data: {
|
177
|
+
'RespondentDataHeader' => {
|
178
|
+
'RespondentDataHeader' => [
|
179
|
+
{
|
180
|
+
'Title' => 'Epost',
|
181
|
+
'enum:Type' => 2,
|
182
|
+
'IsEmailField' => true,
|
183
|
+
'IsSmsField' => false
|
184
|
+
},
|
185
|
+
{
|
186
|
+
'Title' => 'Mobil',
|
187
|
+
'enum:Type' => 2,
|
188
|
+
'IsEmailField' => false,
|
189
|
+
'IsSmsField' => true
|
190
|
+
},
|
191
|
+
{
|
192
|
+
'Title' => 'Navn',
|
193
|
+
'enum:Type' => 2,
|
194
|
+
'IsEmailField' => false,
|
195
|
+
'IsSmsField' => false
|
196
|
+
},
|
197
|
+
{
|
198
|
+
'Title' => 'Alder',
|
199
|
+
'enum:Type' => 1,
|
200
|
+
'IsEmailField' => false,
|
201
|
+
'IsSmsField' => false
|
202
|
+
}
|
203
|
+
]
|
204
|
+
},
|
205
|
+
'RespondentData' => {'array:string' => ['th@skalar.no;404 40 404;Thorbjorn;32']},
|
206
|
+
'Delimiter' => ';',
|
207
|
+
'AllowDuplicate' => true,
|
208
|
+
'AddAsInvitee' => true,
|
209
|
+
order!: ["RespondentDataHeader", "RespondentData", "Delimiter", "AllowDuplicate", "AddAsInvitee"]
|
210
|
+
} ,
|
211
|
+
order!: QuestBack::Api::ORDER[:add_respondents_data] - [:language_id]
|
212
|
+
)
|
213
|
+
|
214
|
+
|
215
|
+
savon.expects(:add_respondents_data).with(message: expected_message).returns success_fixture_for 'add_respondents_data'
|
216
|
+
response = subject.add_respondents_data(
|
217
|
+
quest_info: {quest_id: 4567668, security_lock: 'm0pI8orKJp'},
|
218
|
+
respondents_data: {
|
219
|
+
respondent_data_header: {
|
220
|
+
respondent_data_header: [
|
221
|
+
{
|
222
|
+
title: 'Epost',
|
223
|
+
type: QuestBack::Api.respondent_data_header_type_for(:text),
|
224
|
+
is_email_field: true,
|
225
|
+
is_sms_field: false,
|
226
|
+
},
|
227
|
+
{
|
228
|
+
title: 'Mobil',
|
229
|
+
type: QuestBack::Api.respondent_data_header_type_for(:text),
|
230
|
+
is_email_field: false,
|
231
|
+
is_sms_field: true,
|
232
|
+
},
|
233
|
+
{
|
234
|
+
title: 'Navn',
|
235
|
+
type: QuestBack::Api.respondent_data_header_type_for(:text),
|
236
|
+
is_email_field: false,
|
237
|
+
is_sms_field: false,
|
238
|
+
},
|
239
|
+
{
|
240
|
+
title: 'Alder',
|
241
|
+
type: QuestBack::Api.respondent_data_header_type_for(:numeric),
|
242
|
+
is_email_field: false,
|
243
|
+
is_sms_field: false,
|
244
|
+
},
|
245
|
+
]
|
246
|
+
},
|
247
|
+
respondent_data: ['th@skalar.no;404 40 404;Thorbjorn;32'],
|
248
|
+
allow_duplicate: true,
|
249
|
+
add_as_invitee: true
|
250
|
+
}
|
251
|
+
)
|
252
|
+
|
253
|
+
expect(response).to be_successful
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QuestBack::Configuration do
|
4
|
+
describe "#initialize" do
|
5
|
+
it "has default wsdl URL" do
|
6
|
+
expect(described_class.new.wsdl).to eq 'https://integration.questback.com/integration.svc?wsdl'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "assigns incomming attributes" do
|
10
|
+
config = described_class.new username: 'name', password: 'password', http_proxy: 'http://127.0.0.1/'
|
11
|
+
|
12
|
+
expect(config.username).to eq 'name'
|
13
|
+
expect(config.password).to eq 'password'
|
14
|
+
expect(config.http_proxy).to eq 'http://127.0.0.1/'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QuestBack::Response, type: :request do
|
4
|
+
let(:http) do
|
5
|
+
double(
|
6
|
+
body: success_fixture_for('get_quests'),
|
7
|
+
error?: false
|
8
|
+
)
|
9
|
+
end
|
10
|
+
let(:globals) { Savon::GlobalOptions.new }
|
11
|
+
let(:locals) { {} }
|
12
|
+
let(:savon_response) { Savon::Response.new(http, globals, locals) }
|
13
|
+
|
14
|
+
subject { described_class.new savon_response, operation_name: :get_quests, result_key_nestings: [:quests, :quest] }
|
15
|
+
|
16
|
+
|
17
|
+
describe "#result" do
|
18
|
+
context "singular result" do
|
19
|
+
before { http.stub(:body).and_return success_fixture_for('get_quests') }
|
20
|
+
|
21
|
+
it "returns the result of it's body" do
|
22
|
+
expect(subject.result).to eq savon_response.body[:get_quests_response][:get_quests_result][:quests][:quest]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "multiple result" do
|
27
|
+
before { http.stub(:body).and_return success_fixture_for('get_quests_multiple_response') }
|
28
|
+
|
29
|
+
it "fails" do
|
30
|
+
expect { subject.result }.to raise_error QuestBack::Error::MultipleResultsFound
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#results" do
|
36
|
+
context "singular result" do
|
37
|
+
before { http.stub(:body).and_return success_fixture_for('get_quests') }
|
38
|
+
|
39
|
+
it "returns the result of it's body wrapped in an array" do
|
40
|
+
expect(subject.results).to eq Array.wrap(savon_response.body[:get_quests_response][:get_quests_result][:quests][:quest])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "multiple result" do
|
45
|
+
before { http.stub(:body).and_return success_fixture_for('get_quests_multiple_response') }
|
46
|
+
|
47
|
+
it "returns the result" do
|
48
|
+
expect(subject.results).to eq savon_response.body[:get_quests_response][:get_quests_result][:quests][:quest]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'quest_back'
|
3
|
+
require "savon/mock/spec_helper"
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
module RequestHelpers
|
8
|
+
def success_fixture_for(name)
|
9
|
+
read_fixture "#{name}_success.xml"
|
10
|
+
end
|
11
|
+
|
12
|
+
def failure_fixture_for(name)
|
13
|
+
read_fixture "#{name}_failure.xml"
|
14
|
+
end
|
15
|
+
|
16
|
+
def read_fixture(filename)
|
17
|
+
File.read path_to_fixture(filename)
|
18
|
+
end
|
19
|
+
|
20
|
+
def path_to_fixture(filename)
|
21
|
+
File.join(File.dirname(__FILE__), 'fixtures', filename)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
RSpec.configure do |c|
|
28
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
29
|
+
|
30
|
+
# Mock savon request tests
|
31
|
+
c.include Savon::SpecHelper, type: :request
|
32
|
+
c.include RequestHelpers, type: :request
|
33
|
+
c.before(type: :request) { savon.mock! }
|
34
|
+
c.after(type: :request) { savon.unmock! }
|
35
|
+
end
|