soapforce 0.3.0 → 0.5.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.
@@ -1,3 +1,3 @@
1
1
  module Soapforce
2
- VERSION = "0.3.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency "savon", ">= 2.3.0", '< 3.0.0'
22
22
 
23
- spec.add_development_dependency 'rspec', '~> 2.14.0', '>= 2.14.0'
24
- spec.add_development_dependency 'webmock', '~> 1.17.0', '>= 1.17.0'
25
- spec.add_development_dependency 'simplecov', '~> 0.9.0', '>= 0.9.0'
23
+ spec.add_development_dependency 'rspec', '>= 2.14.0', '< 4.0.0'
24
+ spec.add_development_dependency 'webmock', '>= 1.17.0', '< 2.0.0'
25
+ spec.add_development_dependency 'simplecov', '>= 0.9.0', '< 1.0.0'
26
26
  end
@@ -2,11 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe Soapforce::Client do
4
4
  let(:endpoint) { 'https://na15.salesforce.com' }
5
+ let(:subject) { Soapforce::Client.new(tag_style: :snakecase) }
5
6
 
6
7
  describe "#operations" do
7
8
  it "should return list of operations from the wsdl" do
8
- subject.operations.should be_a(Array)
9
- subject.operations.should include(:login, :logout, :query, :create)
9
+ expect(subject.operations).to be_an(Array)
10
+ expect(subject.operations).to include(:login, :logout, :query, :create)
10
11
  end
11
12
  end
12
13
 
@@ -32,8 +33,8 @@ describe Soapforce::Client do
32
33
 
33
34
  user_info = subject.login(session_id: 'abcde12345', server_url: 'https://na15.salesforce.com')
34
35
 
35
- user_info[:user_email].should == "johndoe@email.com"
36
- user_info[:user_full_name].should == "John Doe"
36
+ expect(user_info[:user_email]).to eq "johndoe@email.com"
37
+ expect(user_info[:user_full_name]).to eq "John Doe"
37
38
  end
38
39
 
39
40
  it "should raise arugment error when no parameters are passed" do
@@ -45,19 +46,19 @@ describe Soapforce::Client do
45
46
  it "should return array of object names" do
46
47
 
47
48
  body = "<tns:describeGlobal></tns:describeGlobal>"
48
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'describe_global_response'})
49
+ stub_api_request(endpoint, {with_body: body, fixture: 'describe_global_response'})
49
50
 
50
- subject.list_sobjects.should == ['Account', 'AccountContactRole']
51
+ expect(subject.list_sobjects).to eq ['Account', 'AccountContactRole']
51
52
  end
52
53
  end
53
54
 
54
55
  describe "org_id" do
55
56
  it "should return organization id" do
56
57
 
57
- body = "<tns:query><tns:queryString>select id from Organization</tns:queryString></tns:query>"
58
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'org_id_response'})
58
+ body = "<tns:query><tns:queryString>SELECT Id FROM Organization</tns:queryString></tns:query>"
59
+ stub_api_request(endpoint, {with_body: body, fixture: 'org_id_response'})
59
60
 
60
- subject.org_id.should == "00DA0000000YpZ4MAK"
61
+ expect(subject.org_id).to eq "00DA0000000YpZ4MAK"
61
62
  end
62
63
  end
63
64
 
@@ -66,7 +67,7 @@ describe Soapforce::Client do
66
67
  it "supports single sobject name" do
67
68
 
68
69
  body = "<tns:describeSObject><tns:sObjectType>Opportunity</tns:sObjectType></tns:describeSObject>"
69
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'describe_s_object_response'})
70
+ stub_api_request(endpoint, {with_body: body, fixture: 'describe_s_object_response'})
70
71
 
71
72
  subject.describe("Opportunity")
72
73
 
@@ -77,7 +78,7 @@ describe Soapforce::Client do
77
78
  it "supports array of sobject names" do
78
79
 
79
80
  body = "<tns:describeSObjects><tns:sObjectType>Account</tns:sObjectType><tns:sObjectType>Opportunity</tns:sObjectType></tns:describeSObjects>"
80
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'describe_s_objects_response'})
81
+ stub_api_request(endpoint, {with_body: body, fixture: 'describe_s_objects_response'})
81
82
 
82
83
  subject.describe(["Account", "Opportunity"])
83
84
  end
@@ -88,7 +89,7 @@ describe Soapforce::Client do
88
89
  it "gets layouts for an sobject type" do
89
90
 
90
91
  body = %Q{<tns:describeLayout><tns:sObjectType>Account</tns:sObjectType><tns:recordTypeIds xsi:nil="true"/></tns:describeLayout>}
91
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'describe_layout_response'})
92
+ stub_api_request(endpoint, {with_body: body, fixture: 'describe_layout_response'})
92
93
 
93
94
  subject.describe_layout("Account")
94
95
 
@@ -99,7 +100,7 @@ describe Soapforce::Client do
99
100
  it "get the details for a specific layout" do
100
101
 
101
102
  body = %Q{<tns:describeLayout><tns:sObjectType>Account</tns:sObjectType><tns:recordTypeIds>012000000000000AAA</tns:recordTypeIds></tns:describeLayout>}
102
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'describe_layout_response'})
103
+ stub_api_request(endpoint, {with_body: body, fixture: 'describe_layout_response'})
103
104
 
104
105
  subject.describe_layout('Account', '012000000000000AAA')
105
106
  end
@@ -108,42 +109,43 @@ describe Soapforce::Client do
108
109
  describe "#retrieve" do
109
110
 
110
111
  it "should retrieve object by id" do
111
- fields = {:fields => [{:name => "Id"},{:name => "Name"},{:name => "Description"},{:name => "StageName"}]}
112
+ fields = fields_hash
113
+
112
114
  # retrieve calls describe to get the list of available fields.
113
- subject.should_receive(:describe).with("Opportunity").and_return(fields)
115
+ expect(subject).to receive(:describe).with("Opportunity").and_return(fields)
114
116
 
115
117
  body = "<tns:retrieve><tns:fieldList>Id,Name,Description,StageName</tns:fieldList><tns:sObjectType>Opportunity</tns:sObjectType><tns:ids>006A000000LbkT5IAJ</tns:ids></tns:retrieve>"
116
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'retrieve_response'})
118
+ stub_api_request(endpoint, {with_body: body, fixture: 'retrieve_response'})
117
119
 
118
120
  sobject = subject.retrieve("Opportunity", "006A000000LbkT5IAJ")
119
121
 
120
- sobject.should be_a(Soapforce::SObject)
121
- sobject.type.should == "Opportunity"
122
- sobject.Id.should == "006A000000LbkT5IAJ"
123
- sobject.Name.should == "SOAPForce Opportunity"
124
- sobject.Description.should be_nil
125
- sobject.StageName.should == "Prospecting"
122
+ expect(sobject).to be_instance_of(Soapforce::SObject)
123
+ expect(sobject.type).to eq "Opportunity"
124
+ expect(sobject.Id).to eq "006A000000LbkT5IAJ"
125
+ expect(sobject.Name).to eq "SOAPForce Opportunity"
126
+ expect(sobject.Description).to be_nil
127
+ expect(sobject.StageName).to eq "Prospecting"
126
128
  end
127
129
  end
128
130
 
129
131
  describe "#find" do
130
132
  it "should retrieve object by id" do
133
+ fields = fields_hash
131
134
 
132
- fields = {:fields => [{:name => "Id"},{:name => "Name"},{:name => "Description"},{:name => "StageName"}]}
133
135
  # retrieve calls describe to get the list of available fields.
134
- subject.should_receive(:describe).with("Opportunity").and_return(fields)
136
+ expect(subject).to receive(:describe).with("Opportunity").and_return(fields)
135
137
 
136
138
  body = "<tns:retrieve><tns:fieldList>Id,Name,Description,StageName</tns:fieldList><tns:sObjectType>Opportunity</tns:sObjectType><tns:ids>006A000000LbkT5IAJ</tns:ids></tns:retrieve>"
137
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'retrieve_response'})
139
+ stub_api_request(endpoint, {with_body: body, fixture: 'retrieve_response'})
138
140
 
139
141
  sobject = subject.find("Opportunity", "006A000000LbkT5IAJ")
140
142
 
141
- sobject.should be_a(Soapforce::SObject)
142
- sobject.type.should == "Opportunity"
143
- sobject.Id.should == "006A000000LbkT5IAJ"
144
- sobject.Name.should == "SOAPForce Opportunity"
145
- sobject.Description.should be_nil
146
- sobject.StageName.should == "Prospecting"
143
+ expect(sobject).to be_instance_of(Soapforce::SObject)
144
+ expect(sobject.type).to eq "Opportunity"
145
+ expect(sobject.Id).to eq "006A000000LbkT5IAJ"
146
+ expect(sobject.Name).to eq "SOAPForce Opportunity"
147
+ expect(sobject.Description).to be_nil
148
+ expect(sobject.StageName).to eq "Prospecting"
147
149
  end
148
150
 
149
151
  end
@@ -151,23 +153,29 @@ describe Soapforce::Client do
151
153
  describe "#find_by_field" do
152
154
 
153
155
  it "should retrieve object by string field" do
154
- fields = {:fields => [{:name => "Id"},{:name => "Name"},{:name => "Description"},{:name => "StageName"}]}
156
+ fields = fields_hash
157
+
155
158
  # retrieve calls describe to get the list of available fields.
156
- subject.should_receive(:describe).exactly(2).with("Opportunity").and_return(fields)
159
+ expect(subject).to receive(:describe).exactly(2).with("Opportunity").and_return(fields)
157
160
 
158
- body = "<tns:query><tns:queryString>Select Id, Name, Description, StageName From Opportunity Where StageName = 'Prospecting'</tns:queryString></tns:query>"
159
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
161
+ body = "<tns:query><tns:queryString>SELECT Id, Name, Description, StageName FROM Opportunity WHERE StageName = &#39;Prospecting&#39;</tns:queryString></tns:query>"
162
+ stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
160
163
 
161
164
  subject.find_by_field("Opportunity", "Prospecting", "StageName")
162
165
  end
163
166
 
164
167
  it "should retrieve object by number field" do
165
- fields = {:fields => [{:name => "Id"},{:name => "Name"},{:name => "Description"},{:name => "Amount", :type => "double"}]}
168
+ if subject.tag_style == :raw
169
+ fields = {"fields" => [{"name" => "Id"},{"name" => "Name"},{"name" => "Description"},{"name" => "Amount", "type" => "double"}]}
170
+ else
171
+ fields = {:fields => [{:name => "Id"},{:name => "Name"},{:name => "Description"},{:name => "Amount", :type => "double"}]}
172
+ end
173
+
166
174
  # retrieve calls describe to get the list of available fields.
167
- subject.should_receive(:describe).exactly(2).with("Opportunity").and_return(fields)
175
+ expect(subject).to receive(:describe).exactly(2).with("Opportunity").and_return(fields)
168
176
 
169
- body = "<tns:query><tns:queryString>Select Id, Name, Description, Amount From Opportunity Where Amount = 0.0</tns:queryString></tns:query>"
170
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
177
+ body = "<tns:query><tns:queryString>SELECT Id, Name, Description, Amount FROM Opportunity WHERE Amount = 0.0</tns:queryString></tns:query>"
178
+ stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
171
179
 
172
180
  subject.find_by_field("Opportunity", 0.0, "Amount")
173
181
  end
@@ -176,45 +184,45 @@ describe Soapforce::Client do
176
184
 
177
185
  describe "#find_where" do
178
186
 
179
- let(:fields) { {:fields => [{:name => "Id"},{:name => "Name"},{:name => "Description"},{:name => "StageName"}]} }
180
- let(:body) { "<tns:query><tns:queryString>Select Id, Name, Description, StageName From Opportunity Where Id = '006A000000LbkT5IAJ' AND Amount = 0.0</tns:queryString></tns:query>" }
187
+ let(:fields) { fields_hash }
188
+ let(:body) { "<tns:query><tns:queryString>SELECT Id, Name, Description, StageName FROM Opportunity WHERE Id = &#39;006A000000LbkT5IAJ&#39; AND Amount = 0.0</tns:queryString></tns:query>" }
181
189
 
182
190
  after(:each) do
183
- @result.should be_a(Soapforce::QueryResult)
184
- @result.size.should == 2
185
- @result.first.Name == "Opportunity 1"
186
- @result.last.Name == "Opportunity 2"
191
+ expect(@result).to be_instance_of(Soapforce::QueryResult)
192
+ expect(@result.size).to eq 2
193
+ expect(@result.first.Name).to eq "Opportunity 1"
194
+ expect(@result.last.Name).to eq "Opportunity 2"
187
195
  end
188
196
 
189
197
  it "should retrieve records from hash conditions" do
190
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
198
+ stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
191
199
  # retrieve calls describe to get the list of available fields.
192
- subject.should_receive(:describe).with("Opportunity").and_return(fields)
200
+ expect(subject).to receive(:describe).with("Opportunity").and_return(fields)
193
201
 
194
202
  @result = subject.find_where("Opportunity", {Id: "006A000000LbkT5IAJ", Amount: 0.0})
195
203
  end
196
204
 
197
205
  it "should retrieve records from hash condition using IN clause" do
198
- body = "<tns:query><tns:queryString>Select Id, Name, Description, StageName From Opportunity Where Id IN ('006A000000LbkT5IAJ', '006A000000AbkTcIAQ')</tns:queryString></tns:query>"
199
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
206
+ body = "<tns:query><tns:queryString>SELECT Id, Name, Description, StageName FROM Opportunity WHERE Id IN (&#39;006A000000LbkT5IAJ&#39;, &#39;006A000000AbkTcIAQ&#39;)</tns:queryString></tns:query>"
207
+ stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
200
208
 
201
209
  # retrieve calls describe to get the list of available fields.
202
- subject.should_receive(:describe).with("Opportunity").and_return(fields)
210
+ expect(subject).to receive(:describe).with("Opportunity").and_return(fields)
203
211
 
204
212
  @result = subject.find_where("Opportunity", {Id: ["006A000000LbkT5IAJ", "006A000000AbkTcIAQ"]})
205
213
  end
206
214
 
207
215
  it "should retrieve records from string condition" do
208
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
216
+ stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
209
217
  # retrieve calls describe to get the list of available fields.
210
- subject.should_receive(:describe).with("Opportunity").and_return(fields)
218
+ expect(subject).to receive(:describe).with("Opportunity").and_return(fields)
211
219
 
212
220
  @result = subject.find_where("Opportunity", "Id = '006A000000LbkT5IAJ' AND Amount = 0.0")
213
221
  end
214
222
 
215
223
  it "should retrieve records from string condition and specify fields" do
216
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
217
- subject.should_not_receive(:describe)
224
+ stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
225
+ expect(subject).to_not receive(:describe)
218
226
 
219
227
  @result = subject.find_where("Opportunity", "Id = '006A000000LbkT5IAJ' AND Amount = 0.0", ["Id", "Name", "Description", "StageName"])
220
228
  end
@@ -224,29 +232,31 @@ describe Soapforce::Client do
224
232
  describe "query methods" do
225
233
 
226
234
  after(:each) do
227
- @result.should be_a(Soapforce::QueryResult)
228
- @result.size.should == 2
229
- @result.first.Name == "Opportunity 1"
230
- @result.last.Name == "Opportunity 2"
235
+ expect(@result).to be_instance_of(Soapforce::QueryResult)
236
+ expect(@result.size).to eq 2
237
+ expect(@result.first.Name).to eq "Opportunity 1"
238
+ expect(@result.last.Name).to eq "Opportunity 2"
231
239
  end
232
240
 
233
241
  it "#query" do
234
- body = "<tns:query><tns:queryString>Select Id, Name, StageName from Opportunity</tns:queryString></tns:query>"
235
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
242
+ soql = "SELECT Id, Name, StageName FROM Opportunity"
243
+ body = "<tns:query><tns:queryString>#{soql}</tns:queryString></tns:query>"
244
+ stub_api_request(endpoint, {with_body: body, fixture: 'query_response'})
236
245
 
237
- @result = subject.query("Select Id, Name, StageName from Opportunity")
246
+ @result = subject.query(soql)
238
247
  end
239
248
 
240
249
  it "#query_all" do
241
- body = "<tns:queryAll><tns:queryString>Select Id, Name, StageName from Opportunity</tns:queryString></tns:queryAll>"
242
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'query_all_response'})
250
+ soql = "SELECT Id, Name, StageName FROM Opportunity"
251
+ body = "<tns:queryAll><tns:queryString>#{soql}</tns:queryString></tns:queryAll>"
252
+ stub_api_request(endpoint, {with_body: body, fixture: 'query_all_response'})
243
253
 
244
- @result = subject.query_all("Select Id, Name, StageName from Opportunity")
254
+ @result = subject.query_all(soql)
245
255
  end
246
256
 
247
257
  it "#query_more" do
248
258
  body = "<tns:queryMore><tns:queryLocator>some_locator_string</tns:queryLocator></tns:queryMore>"
249
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'query_more_response'})
259
+ stub_api_request(endpoint, {with_body: body, fixture: 'query_more_response'})
250
260
 
251
261
  @result = subject.query_more("some_locator_string")
252
262
  end
@@ -258,9 +268,9 @@ describe Soapforce::Client do
258
268
  it "should return search results" do
259
269
 
260
270
  sosl = "FIND 'Name*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead"
261
-
262
- body = "<tns:search><tns:searchString>#{sosl}</tns:searchString></tns:search>"
263
- stub = stub_api_request(endpoint, {with_body: body, fixture: 'search_response'})
271
+ # single quote encoding changed in ruby 2
272
+ body = "<tns:search><tns:searchString>FIND &#39;Name*&#39; IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead</tns:searchString></tns:search>"
273
+ stub_api_request(endpoint, {with_body: body, fixture: 'search_response'})
264
274
 
265
275
  subject.search(sosl)
266
276
  end
@@ -275,33 +285,33 @@ describe Soapforce::Client do
275
285
 
276
286
  it "should create new object" do
277
287
 
278
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'create_response'})
288
+ stub_api_request(endpoint, {with_body: @body, fixture: 'create_response'})
279
289
  response = subject.create("Opportunity", @params)
280
290
 
281
- response[:success].should be_true
282
- response[:id].should == "006A000000LbiizIAB"
291
+ expect(response[:success]).to eq true
292
+ expect(response[:id]).to eq "006A000000LbiizIAB"
283
293
  end
284
294
 
285
295
  it "should return false if object not created" do
286
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'create_response_failure'})
296
+ stub_api_request(endpoint, {with_body: @body, fixture: 'create_response_failure'})
287
297
  response = subject.create("Opportunity", @params)
288
- response.should be_false
298
+ expect(response).to eq false
289
299
  end
290
300
 
291
301
  it "creates! new object" do
292
302
 
293
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'create_response'})
303
+ stub_api_request(endpoint, {with_body: @body, fixture: 'create_response'})
294
304
  response = subject.create!("Opportunity", @params)
295
305
 
296
- response[:success].should be_true
297
- response[:id].should == "006A000000LbiizIAB"
306
+ expect(response[:success]).to eq true
307
+ expect(response[:id]).to eq "006A000000LbiizIAB"
298
308
  end
299
309
 
300
310
  it "raises exception when create! fails" do
301
311
 
302
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'create_response_failure'})
312
+ stub_api_request(endpoint, {with_body: @body, fixture: 'create_response_failure'})
303
313
  expect {
304
- response = subject.create!("Opportunity", @params)
314
+ subject.create!("Opportunity", @params)
305
315
  }.to raise_error(Savon::Error)
306
316
 
307
317
  end
@@ -314,33 +324,31 @@ describe Soapforce::Client do
314
324
  end
315
325
 
316
326
  it "updates existing object" do
317
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'update_response'})
327
+ stub_api_request(endpoint, {with_body: @body, fixture: 'update_response'})
318
328
  response = subject.update("Opportunity", @params)
319
329
 
320
- response[:success].should be_true
321
- response[:id].should == "006A000000LbiizIAB"
330
+ expect(response[:success]).to eq true
331
+ expect(response[:id]).to eq "006A000000LbiizIAB"
322
332
  end
323
333
 
324
334
  it "updates! existing object" do
325
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'update_response'})
335
+ stub_api_request(endpoint, {with_body: @body, fixture: 'update_response'})
326
336
  response = subject.update!("Opportunity", @params)
327
337
 
328
- response[:success].should be_true
329
- response[:id].should == "006A000000LbiizIAB"
338
+ expect(response[:success]).to eq true
339
+ expect(response[:id]).to eq "006A000000LbiizIAB"
330
340
  end
331
341
 
332
342
  it "returns false when update fails" do
333
-
334
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'update_response_failure'})
343
+ stub_api_request(endpoint, {with_body: @body, fixture: 'update_response_failure'})
335
344
  response = subject.update("Opportunity", @params)
336
- response.should be_false
345
+ expect(response).to eq false
337
346
  end
338
347
 
339
348
  it "raises exception when update fails" do
340
-
341
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'update_response_failure'})
349
+ stub_api_request(endpoint, {with_body: @body, fixture: 'update_response_failure'})
342
350
  expect {
343
- response = subject.update!("Opportunity", @params)
351
+ subject.update!("Opportunity", @params)
344
352
  }.to raise_error(Savon::Error)
345
353
 
346
354
  end
@@ -356,7 +364,7 @@ describe Soapforce::Client do
356
364
  end
357
365
 
358
366
  it "inserts new and updates existing objects" do
359
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'upsert_response'})
367
+ stub_api_request(endpoint, {with_body: @body, fixture: 'upsert_response'})
360
368
  subject.upsert("Opportunity", "External_Id__c", @objects)
361
369
  end
362
370
 
@@ -369,30 +377,31 @@ describe Soapforce::Client do
369
377
  end
370
378
 
371
379
  it "deletes existing object" do
372
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'delete_response'})
380
+ stub_api_request(endpoint, {with_body: @body, fixture: 'delete_response'})
373
381
  response = subject.delete(@id)
374
382
 
375
- response[:success].should be_true
376
- response[:id].should == @id
383
+ expect(response[:success]).to eq true
384
+ expect(response[:id]).to eq @id
377
385
  end
378
386
 
379
387
  it "returns false if delete fails" do
380
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'delete_response_failure'})
388
+ stub_api_request(endpoint, {with_body: @body, fixture: 'delete_response_failure'})
381
389
  response = subject.delete(@id)
382
390
 
383
- response.should be_false
391
+ expect(response).to eq false
384
392
  end
385
393
 
386
394
  it "deletes existing object with a bang" do
387
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'delete_response'})
395
+ stub_api_request(endpoint, {with_body: @body, fixture: 'delete_response'})
388
396
  response = subject.delete!(@id)
389
397
 
390
- response[:success].should be_true
391
- response[:id].should == @id
398
+ expect(response).to be_an_instance_of Soapforce::Result
399
+ expect(response[:success]).to eq true
400
+ expect(response[:id]).to eq @id
392
401
  end
393
402
 
394
403
  it "raises an exception if delete fails" do
395
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'delete_response_failure'})
404
+ stub_api_request(endpoint, {with_body: @body, fixture: 'delete_response_failure'})
396
405
  expect {
397
406
  subject.delete!(@id)
398
407
  }.to raise_error(Savon::Error)
@@ -408,32 +417,34 @@ describe Soapforce::Client do
408
417
  end
409
418
 
410
419
  it "merges objects together" do
411
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response'})
420
+ stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response'})
412
421
  response = subject.merge("Account", @object, @to_merge)
413
422
 
414
- response[:success].should be_true
415
- response[:id].should == @object[:id]
416
- response[:merged_record_ids].sort.should == @to_merge
423
+ expect(response).to be_an_instance_of Soapforce::Result
424
+ expect(response[:success]).to eq true
425
+ expect(response[:id]).to eq @object[:id]
426
+ expect(response[:merged_record_ids]).to be_an(Array)
427
+ expect(response[:merged_record_ids].sort).to eq @to_merge
417
428
  end
418
429
 
419
430
  it "returns false if merge fails" do
420
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response_failure'})
431
+ stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response_failure'})
421
432
  response = subject.merge("Account", @object, @to_merge)
422
433
 
423
- response.should be_false
434
+ expect(response).to eq false
424
435
  end
425
436
 
426
437
  it "merges objects with a bang" do
427
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response'})
438
+ stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response'})
428
439
  response = subject.merge!("Account", @object, @to_merge)
429
440
 
430
- response[:success].should be_true
431
- response[:id].should == @object[:id]
432
- response[:merged_record_ids].sort.should == @to_merge
441
+ expect(response[:success]).to eq true
442
+ expect(response[:id]).to eq @object[:id]
443
+ expect(response[:merged_record_ids].sort).to eq @to_merge
433
444
  end
434
445
 
435
446
  it "raises an exception if merge fails" do
436
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response_failure'})
447
+ stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response_failure'})
437
448
  expect {
438
449
  subject.merge!('Account', @object, @to_merge)
439
450
  }.to raise_error(Savon::Error)
@@ -446,32 +457,42 @@ describe Soapforce::Client do
446
457
 
447
458
  @body = '<tns:process><tns:actions xsi:type="tns:ProcessSubmitRequest"><tns:objectId>a00i0000007JBLJAA4</tns:objectId><tns:comments>Submitting for Approval</tns:comments></tns:actions></tns:process>'
448
459
 
449
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'process_submit_request_response'})
460
+ stub_api_request(endpoint, {with_body: @body, fixture: 'process_submit_request_response'})
450
461
  response = subject.process({objectId: "a00i0000007JBLJAA4", comments: "Submitting for Approval"})
451
462
 
452
- response[:success].should be_true
453
- response[:new_workitem_ids].should == "04ii000000098uLAAQ"
463
+ expect(response).to be_an_instance_of(Soapforce::Result)
464
+ expect(response[:success]).to eq true
465
+ expect(response[:new_workitem_ids]).to eq "04ii000000098uLAAQ"
466
+ expect(response["newWorkitemIds"]).to eq "04ii000000098uLAAQ"
454
467
  end
455
468
 
456
469
  it "process submit request with approvers" do
457
470
 
458
471
  @body = '<tns:process><tns:actions xsi:type="tns:ProcessSubmitRequest"><tns:objectId>a00i0000007JBLJAA4</tns:objectId><tns:comments>Submitting for Approval</tns:comments><tns:nextApproverIds>abcde12345</tns:nextApproverIds></tns:actions></tns:process>'
459
472
 
460
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'process_submit_request_response'})
473
+ stub_api_request(endpoint, {with_body: @body, fixture: 'process_submit_request_response'})
461
474
  response = subject.process({objectId: "a00i0000007JBLJAA4", comments: "Submitting for Approval", approverIds: "abcde12345"})
462
475
 
463
- response[:success].should be_true
464
- response[:new_workitem_ids].should == "04ii000000098uLAAQ"
476
+ expect(response[:success]).to eq true
477
+ expect(response[:new_workitem_ids]).to eq "04ii000000098uLAAQ"
465
478
  end
466
479
 
467
480
  it "process workitem request" do
468
481
  @body = '<tns:process><tns:actions xsi:type="tns:ProcessWorkitemRequest"><tns:action>Removed</tns:action><tns:workitemId>a00i0000007JBLJAA4</tns:workitemId><tns:comments>Recalling Request</tns:comments></tns:actions></tns:process>'
469
482
 
470
- stub = stub_api_request(endpoint, {with_body: @body, fixture: 'process_workitem_request_response'})
483
+ stub_api_request(endpoint, {with_body: @body, fixture: 'process_workitem_request_response'})
471
484
  response = subject.process({action: "Removed", workitemId: "a00i0000007JBLJAA4", comments: "Recalling Request"})
472
485
 
473
- response[:success].should be_true
474
- response[:instance_status].should == "Removed"
486
+ expect(response[:success]).to eq true
487
+ expect(response[:instance_status]).to eq "Removed"
488
+ end
489
+ end
490
+
491
+ def fields_hash
492
+ if subject.tag_style == :raw
493
+ {"fields" => [{"name" => "Id"},{"name" => "Name"},{"name" => "Description"},{"name" => "StageName"}]}
494
+ else
495
+ {:fields => [{:name => "Id"},{:name => "Name"},{:name => "Description"},{:name => "StageName"}]}
475
496
  end
476
497
  end
477
498