spark_api 1.4.34 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/spark_api/authentication/api_auth.rb +1 -1
- data/lib/spark_api/authentication/oauth2.rb +1 -1
- data/lib/spark_api/authentication/oauth2_impl/grant_type_base.rb +1 -1
- data/lib/spark_api/client.rb +2 -2
- data/lib/spark_api/request.rb +1 -1
- data/spec/spec_helper.rb +9 -4
- data/spec/unit/spark_api/authentication/api_auth_spec.rb +21 -22
- data/spec/unit/spark_api/authentication/base_auth_spec.rb +3 -3
- data/spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb +1 -1
- data/spec/unit/spark_api/authentication/oauth2_impl/grant_type_base_spec.rb +1 -1
- data/spec/unit/spark_api/authentication/oauth2_impl/single_session_provider_spec.rb +2 -2
- data/spec/unit/spark_api/authentication/oauth2_spec.rb +40 -40
- data/spec/unit/spark_api/authentication_spec.rb +2 -2
- data/spec/unit/spark_api/configuration/yaml_spec.rb +44 -44
- data/spec/unit/spark_api/configuration_spec.rb +56 -57
- data/spec/unit/spark_api/faraday_middleware_spec.rb +12 -12
- data/spec/unit/spark_api/models/account_spec.rb +20 -20
- data/spec/unit/spark_api/models/activity_spec.rb +5 -5
- data/spec/unit/spark_api/models/base_spec.rb +32 -32
- data/spec/unit/spark_api/models/concerns/destroyable_spec.rb +2 -2
- data/spec/unit/spark_api/models/concerns/savable_spec.rb +19 -19
- data/spec/unit/spark_api/models/connect_prefs_spec.rb +1 -1
- data/spec/unit/spark_api/models/constraint_spec.rb +1 -1
- data/spec/unit/spark_api/models/contact_spec.rb +50 -50
- data/spec/unit/spark_api/models/dirty_spec.rb +12 -12
- data/spec/unit/spark_api/models/document_spec.rb +3 -3
- data/spec/unit/spark_api/models/fields_spec.rb +17 -17
- data/spec/unit/spark_api/models/finders_spec.rb +7 -7
- data/spec/unit/spark_api/models/floplan_spec.rb +4 -4
- data/spec/unit/spark_api/models/listing_cart_spec.rb +46 -46
- data/spec/unit/spark_api/models/listing_meta_translations_spec.rb +6 -6
- data/spec/unit/spark_api/models/listing_spec.rb +91 -91
- data/spec/unit/spark_api/models/message_spec.rb +10 -10
- data/spec/unit/spark_api/models/note_spec.rb +10 -10
- data/spec/unit/spark_api/models/notification_spec.rb +6 -6
- data/spec/unit/spark_api/models/open_house_spec.rb +4 -4
- data/spec/unit/spark_api/models/photo_spec.rb +8 -8
- data/spec/unit/spark_api/models/portal_spec.rb +4 -4
- data/spec/unit/spark_api/models/property_types_spec.rb +5 -5
- data/spec/unit/spark_api/models/rental_calendar_spec.rb +13 -11
- data/spec/unit/spark_api/models/rule_spec.rb +2 -2
- data/spec/unit/spark_api/models/saved_search_spec.rb +33 -33
- data/spec/unit/spark_api/models/search_template/quick_search_spec.rb +5 -5
- data/spec/unit/spark_api/models/shared_listing_spec.rb +12 -12
- data/spec/unit/spark_api/models/sort_spec.rb +3 -3
- data/spec/unit/spark_api/models/standard_fields_spec.rb +12 -12
- data/spec/unit/spark_api/models/subresource_spec.rb +18 -18
- data/spec/unit/spark_api/models/system_info_spec.rb +7 -7
- data/spec/unit/spark_api/models/tour_of_home_spec.rb +3 -3
- data/spec/unit/spark_api/models/video_spec.rb +9 -9
- data/spec/unit/spark_api/models/virtual_tour_spec.rb +7 -7
- data/spec/unit/spark_api/models/vow_account_spec.rb +8 -8
- data/spec/unit/spark_api/multi_client_spec.rb +14 -14
- data/spec/unit/spark_api/options_hash_spec.rb +4 -4
- data/spec/unit/spark_api/paginate_spec.rb +71 -71
- data/spec/unit/spark_api/primary_array_spec.rb +5 -5
- data/spec/unit/spark_api/request_spec.rb +60 -60
- data/spec/unit/spark_api_spec.rb +6 -6
- metadata +162 -233
@@ -74,91 +74,91 @@ describe Listing do
|
|
74
74
|
|
75
75
|
describe "attributes" do
|
76
76
|
it "should allow access to fields" do
|
77
|
-
@listing.StandardFields.
|
78
|
-
@listing.StandardFields['ListingId'].
|
79
|
-
@listing.StandardFields['ListPrice'].
|
80
|
-
@listing.photos.
|
77
|
+
expect(@listing.StandardFields).to be_a(Hash)
|
78
|
+
expect(@listing.StandardFields['ListingId']).to be_a(String)
|
79
|
+
expect(@listing.StandardFields['ListPrice']).to match(@listing.ListPrice)
|
80
|
+
expect(@listing.photos).to be_a(Array)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should not respond to removed attributes" do
|
84
|
-
@listing.
|
85
|
-
@listing.
|
86
|
-
@listing.
|
87
|
-
@listing.
|
84
|
+
expect(@listing).not_to respond_to(:Photos)
|
85
|
+
expect(@listing).not_to respond_to(:Documents)
|
86
|
+
expect(@listing).not_to respond_to(:VirtualTours)
|
87
|
+
expect(@listing).not_to respond_to(:Videos)
|
88
88
|
end
|
89
89
|
|
90
90
|
describe '.street_address' do
|
91
91
|
it 'should return the street address' do
|
92
|
-
@listing.street_address.
|
92
|
+
expect(@listing.street_address).to eq("100 Someone's St")
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'should remove data masks' do
|
96
96
|
@listing.StandardFields["UnparsedFirstLineAddress"] = "********"
|
97
|
-
@listing.street_address.
|
97
|
+
expect(@listing.street_address).to eq("")
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'should handle a missing unparsed first line address' do
|
101
101
|
[nil, '', ' '].each do |current|
|
102
102
|
@listing.StandardFields['UnparsedFirstLineAddress'] = current
|
103
|
-
@listing.street_address.
|
103
|
+
expect(@listing.street_address).to eq('')
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should return the regional address" do
|
109
|
-
@listing.region_address.
|
109
|
+
expect(@listing.region_address).to eq("Fargo, ND 55320")
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should return full address" do
|
113
|
-
@listing.full_address.
|
113
|
+
expect(@listing.full_address).to eq("100 Someone's St, Fargo, ND 55320")
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should provide shortcut methods to standard fields" do
|
117
|
-
@listing.StreetName.
|
118
|
-
@listing.YearBuilt.
|
119
|
-
@listing.BuildingAreaTotal.
|
120
|
-
@listing.PublicRemarks.
|
121
|
-
@listing.PostalCode.
|
122
|
-
@listing.ListPrice.
|
117
|
+
expect(@listing.StreetName).to eq("Someone's")
|
118
|
+
expect(@listing.YearBuilt).to eq(nil)
|
119
|
+
expect(@listing.BuildingAreaTotal).to eq("1321.0")
|
120
|
+
expect(@listing.PublicRemarks).to eq(nil)
|
121
|
+
expect(@listing.PostalCode).to eq("55320")
|
122
|
+
expect(@listing.ListPrice).to eq("100000.0")
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should report that it responds to shortcut methods to standard fields" do
|
126
|
-
@listing.
|
127
|
-
@listing.
|
128
|
-
@listing.
|
129
|
-
@listing.
|
130
|
-
@listing.
|
131
|
-
@listing.
|
132
|
-
|
133
|
-
@listing.
|
126
|
+
expect(@listing).to respond_to(:StreetName)
|
127
|
+
expect(@listing).to respond_to(:YearBuilt)
|
128
|
+
expect(@listing).to respond_to(:BuildingAreaTotal)
|
129
|
+
expect(@listing).to respond_to(:PublicRemarks)
|
130
|
+
expect(@listing).to respond_to(:PostalCode)
|
131
|
+
expect(@listing).to respond_to(:ListPrice)
|
132
|
+
|
133
|
+
expect(@listing).not_to respond_to(:BogusField)
|
134
134
|
@listing.StandardFields['BogusField'] = 'bogus'
|
135
|
-
@listing.
|
135
|
+
expect(@listing).to respond_to(:BogusField)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
139
|
describe "class methods" do
|
140
140
|
it "should respond to find" do
|
141
|
-
Listing.
|
141
|
+
expect(Listing).to respond_to(:find)
|
142
142
|
end
|
143
143
|
|
144
144
|
it "should respond to first" do
|
145
|
-
Listing.
|
145
|
+
expect(Listing).to respond_to(:first)
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should respond to last" do
|
149
|
-
Listing.
|
149
|
+
expect(Listing).to respond_to(:last)
|
150
150
|
end
|
151
151
|
|
152
152
|
it "should respond to my" do
|
153
|
-
Listing.
|
153
|
+
expect(Listing).to respond_to(:my)
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should respond to find_by_cart_id" do
|
157
|
-
Listing.
|
157
|
+
expect(Listing).to respond_to(:find_by_cart_id)
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should respond to count" do
|
161
|
-
Listing.
|
161
|
+
expect(Listing).to respond_to(:count)
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -172,14 +172,14 @@ describe Listing do
|
|
172
172
|
stub_api_get('/listings', 'listings/multiple.json', {:_filter => "PostalCode Eq '83805'"})
|
173
173
|
|
174
174
|
listings = Listing.find(:all, :_filter => "PostalCode Eq '83805'")
|
175
|
-
listings.
|
176
|
-
listings.count.
|
175
|
+
expect(listings).to be_an(Array)
|
176
|
+
expect(listings.count).to eq(2)
|
177
177
|
end
|
178
178
|
|
179
179
|
on_get_it "should return the count" do
|
180
180
|
stub_api_get("/listings", 'count.json', { :_pagination => "count"})
|
181
181
|
count = Listing.count()
|
182
|
-
count.
|
182
|
+
expect(count).to eq(2001)
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
@@ -188,10 +188,10 @@ describe Listing do
|
|
188
188
|
stub_api_get("/listings/20060725224713296297000000", 'listings/no_subresources.json')
|
189
189
|
|
190
190
|
l = Listing.find('20060725224713296297000000')
|
191
|
-
l.videos.length.
|
192
|
-
l.photos.length.
|
193
|
-
l.documents.length.
|
194
|
-
l.Id.
|
191
|
+
expect(l.videos.length).to eq(0)
|
192
|
+
expect(l.photos.length).to eq(0)
|
193
|
+
expect(l.documents.length).to eq(0)
|
194
|
+
expect(l.Id).to eq('20060725224713296297000000')
|
195
195
|
end
|
196
196
|
|
197
197
|
on_put_it "should save a listing that has modified ListPrice" do
|
@@ -200,7 +200,7 @@ describe Listing do
|
|
200
200
|
stub_api_put("/flexmls/listings/#{list_id}", 'listings/put.json', 'success.json')
|
201
201
|
l = Listing.find(list_id)
|
202
202
|
l.ListPrice = 10000.0
|
203
|
-
l.save.
|
203
|
+
expect(l.save).to be(true)
|
204
204
|
end
|
205
205
|
|
206
206
|
on_put_it "should save a listing that has modified ExpirationDate" do
|
@@ -209,7 +209,7 @@ describe Listing do
|
|
209
209
|
stub_api_put("/flexmls/listings/#{list_id}", 'listings/put_expiration_date.json', 'success.json')
|
210
210
|
l = Listing.find(list_id)
|
211
211
|
l.ExpirationDate = "2011-10-04"
|
212
|
-
l.save.
|
212
|
+
expect(l.save).to be(true)
|
213
213
|
end
|
214
214
|
|
215
215
|
it "should not save a listing that does not exist", :method => 'PUT' do
|
@@ -221,8 +221,8 @@ describe Listing do
|
|
221
221
|
l = Listing.find(list_id)
|
222
222
|
l.Id = "lolwut"
|
223
223
|
l.ListPrice = 10000.0
|
224
|
-
l.save.
|
225
|
-
expect{ l.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.
|
224
|
+
expect(l.save).to be(false)
|
225
|
+
expect{ l.save! }.to raise_error(SparkApi::ClientError){ |e| expect(e.status).to eq(400) }
|
226
226
|
end
|
227
227
|
|
228
228
|
on_put_it "should save a listing with constraints" do
|
@@ -231,9 +231,9 @@ describe Listing do
|
|
231
231
|
stub_api_put("/flexmls/listings/#{list_id}", 'listings/put.json', 'listings/constraints.json')
|
232
232
|
l = Listing.find(list_id)
|
233
233
|
l.ListPrice = 10000.0
|
234
|
-
l.save.
|
235
|
-
l.constraints.size.
|
236
|
-
l.constraints.first.RuleName.
|
234
|
+
expect(l.save).to be(true)
|
235
|
+
expect(l.constraints.size).to eq(1)
|
236
|
+
expect(l.constraints.first.RuleName).to eq("MaxValue")
|
237
237
|
end
|
238
238
|
|
239
239
|
on_put_it "should fail saving a listing with constraints and provide the constraints" do
|
@@ -245,10 +245,10 @@ describe Listing do
|
|
245
245
|
|
246
246
|
l = Listing.find(list_id)
|
247
247
|
l.ListPrice = 10000.0
|
248
|
-
l.save.
|
249
|
-
l.constraints.size.
|
250
|
-
l.constraints.first.RuleName.
|
251
|
-
l.errors.size.
|
248
|
+
expect(l.save).to be false
|
249
|
+
expect(l.constraints.size).to eq(1)
|
250
|
+
expect(l.constraints.first.RuleName).to eq("MaxIncreasePercent")
|
251
|
+
expect(l.errors.size).to eq(1)
|
252
252
|
end
|
253
253
|
|
254
254
|
on_put_it "should reorder a photo" do
|
@@ -257,7 +257,7 @@ describe Listing do
|
|
257
257
|
stub_api_put("/listings/#{list_id}/photos/20110826220032167405000000", 'listings/put_reorder_photo.json', 'listings/reorder_photo.json')
|
258
258
|
l = Listing.find(list_id)
|
259
259
|
l.reorder_photo("20110826220032167405000000", "2")
|
260
|
-
l.photos.size.
|
260
|
+
expect(l.photos.size).to eq(5)
|
261
261
|
end
|
262
262
|
|
263
263
|
on_put_it "should raise an exception when an index is not an Integer" do
|
@@ -277,9 +277,9 @@ describe Listing do
|
|
277
277
|
stub_api_put("/flexmls/listings/#{list_id}", 'listings/put.json', 'listings/constraints_with_pagination.json', :_pagination => '1')
|
278
278
|
l = Listing.find(list_id)
|
279
279
|
l.ListPrice = 10000.0
|
280
|
-
l.save(:_pagination => '1').
|
281
|
-
l.constraints.size.
|
282
|
-
l.constraints.first.RuleName.
|
280
|
+
expect(l.save(:_pagination => '1')).to be(true)
|
281
|
+
expect(l.constraints.size).to eq(1)
|
282
|
+
expect(l.constraints.first.RuleName).to eq("MaxValue")
|
283
283
|
end
|
284
284
|
end
|
285
285
|
|
@@ -288,47 +288,47 @@ describe Listing do
|
|
288
288
|
stub_api_get("/listings/1234", 'listings/with_photos.json', { :_expand => "Photos" })
|
289
289
|
|
290
290
|
l = Listing.find('1234', :_expand => "Photos")
|
291
|
-
l.photos.length.
|
292
|
-
l.documents.length.
|
293
|
-
l.videos.length.
|
294
|
-
l.virtual_tours.length.
|
291
|
+
expect(l.photos.length).to eq(5)
|
292
|
+
expect(l.documents.length).to eq(0)
|
293
|
+
expect(l.videos.length).to eq(0)
|
294
|
+
expect(l.virtual_tours.length).to eq(0)
|
295
295
|
end
|
296
296
|
|
297
297
|
on_get_it "should return an array of documents" do
|
298
298
|
stub_api_get("/listings/1234", 'listings/with_documents.json', { :_expand => "Documents" })
|
299
299
|
|
300
300
|
l = Listing.find('1234', :_expand => "Documents")
|
301
|
-
l.photos.length.
|
302
|
-
l.documents.length.
|
303
|
-
l.videos.length.
|
304
|
-
l.virtual_tours.length.
|
301
|
+
expect(l.photos.length).to eq(0)
|
302
|
+
expect(l.documents.length).to eq(2)
|
303
|
+
expect(l.videos.length).to eq(0)
|
304
|
+
expect(l.virtual_tours.length).to eq(0)
|
305
305
|
end
|
306
306
|
|
307
307
|
on_get_it "should return an array of virtual tours" do
|
308
308
|
stub_api_get("/listings/1234", 'listings/with_vtour.json', { :_expand => "VirtualTours" })
|
309
309
|
|
310
310
|
l = Listing.find('1234', :_expand => "VirtualTours")
|
311
|
-
l.virtual_tours.length.
|
312
|
-
l.photos.length.
|
313
|
-
l.documents.length.
|
314
|
-
l.videos.length.
|
311
|
+
expect(l.virtual_tours.length).to eq(1)
|
312
|
+
expect(l.photos.length).to eq(0)
|
313
|
+
expect(l.documents.length).to eq(0)
|
314
|
+
expect(l.videos.length).to eq(0)
|
315
315
|
end
|
316
316
|
|
317
317
|
on_get_it "should return an array of videos" do
|
318
318
|
stub_api_get("/listings/1234", 'listings/with_videos.json', { :_expand => "Videos" })
|
319
319
|
|
320
320
|
l = Listing.find('1234', :_expand => "Videos")
|
321
|
-
l.videos.length.
|
322
|
-
l.virtual_tours.length.
|
323
|
-
l.photos.length.
|
324
|
-
l.documents.length.
|
321
|
+
expect(l.videos.length).to eq(2)
|
322
|
+
expect(l.virtual_tours.length).to eq(0)
|
323
|
+
expect(l.photos.length).to eq(0)
|
324
|
+
expect(l.documents.length).to eq(0)
|
325
325
|
end
|
326
326
|
|
327
327
|
on_get_it "should return an array of rental calendars" do
|
328
328
|
stub_api_get("/listings/1234", 'listings/with_rental_calendar.json', { :_expand => "RentalCalendar" })
|
329
329
|
|
330
330
|
l = Listing.find('1234', :_expand => "RentalCalendar")
|
331
|
-
l.rental_calendars.length.
|
331
|
+
expect(l.rental_calendars.length).to eq(2)
|
332
332
|
end
|
333
333
|
|
334
334
|
## TourOfHomes: Not implemented yet ##
|
@@ -337,19 +337,19 @@ describe Listing do
|
|
337
337
|
#stub_api_get("/listings/20060725224713296297000000/tourofhomes", 'listings/tour_of_homes.json')
|
338
338
|
|
339
339
|
#l = Listing.find('20060725224713296297000000')
|
340
|
-
#l.tour_of_homes().length.
|
341
|
-
#l.videos.length.
|
342
|
-
#l.photos.length.
|
343
|
-
#l.documents.length.
|
340
|
+
#expect(l.tour_of_homes().length).to eq 2
|
341
|
+
#expect(l.videos.length).to eq 0
|
342
|
+
#expect(l.photos.length).to eq 0
|
343
|
+
#expect(l.documents.length).to eq 0
|
344
344
|
#end
|
345
345
|
|
346
346
|
on_get_it "should return permissions" do
|
347
347
|
stub_api_get("/listings/20060725224713296297000000", 'listings/with_permissions.json', { :_expand => "Permissions" })
|
348
348
|
l = Listing.find('20060725224713296297000000', :_expand => "Permissions")
|
349
|
-
l.Permissions["Editable"].
|
350
|
-
l.editable?().
|
351
|
-
l.editable?(:PriceChange).
|
352
|
-
l.editable?(:Photos).
|
349
|
+
expect(l.Permissions["Editable"]).to eq(true)
|
350
|
+
expect(l.editable?()).to eq(true)
|
351
|
+
expect(l.editable?(:PriceChange)).to eq(true)
|
352
|
+
expect(l.editable?(:Photos)).to eq(false)
|
353
353
|
end
|
354
354
|
|
355
355
|
on_delete_it "should bulk delete listing photos" do
|
@@ -359,7 +359,7 @@ describe Listing do
|
|
359
359
|
photo_id1 = l.photos[0].Id
|
360
360
|
photo_id2 = l.photos[1].Id
|
361
361
|
stub_api_delete("/listings/#{list_id}/photos/#{photo_id1},#{photo_id2}", 'listings/photos/index.json')
|
362
|
-
l.delete_photos(photo_id1 + "," + photo_id2).
|
362
|
+
expect(l.delete_photos(photo_id1 + "," + photo_id2)).not_to be_empty
|
363
363
|
end
|
364
364
|
end
|
365
365
|
end
|
@@ -369,8 +369,8 @@ describe Listing do
|
|
369
369
|
stub_api_get('/my/listings', 'listings/multiple.json')
|
370
370
|
|
371
371
|
listings = Listing.my
|
372
|
-
listings.
|
373
|
-
listings.count.
|
372
|
+
expect(listings).to be_an(Array)
|
373
|
+
expect(listings.count).to eq(2)
|
374
374
|
end
|
375
375
|
end
|
376
376
|
|
@@ -379,8 +379,8 @@ describe Listing do
|
|
379
379
|
stub_api_get('/office/listings', 'listings/multiple.json')
|
380
380
|
|
381
381
|
listings = Listing.office
|
382
|
-
listings.
|
383
|
-
listings.count.
|
382
|
+
expect(listings).to be_an(Array)
|
383
|
+
expect(listings.count).to eq(2)
|
384
384
|
end
|
385
385
|
end
|
386
386
|
|
@@ -389,8 +389,8 @@ describe Listing do
|
|
389
389
|
stub_api_get('/company/listings', 'listings/multiple.json')
|
390
390
|
|
391
391
|
listings = Listing.company
|
392
|
-
listings.
|
393
|
-
listings.count.
|
392
|
+
expect(listings).to be_an(Array)
|
393
|
+
expect(listings.count).to eq(2)
|
394
394
|
end
|
395
395
|
end
|
396
396
|
|
@@ -399,7 +399,7 @@ describe Listing do
|
|
399
399
|
stub_api_get("/listings/nearby",
|
400
400
|
'listings/no_subresources.json', {:_lat => "45.45", :_lon => "-93.98"})
|
401
401
|
l = Listing.nearby(45.45, -93.98)
|
402
|
-
l.length.
|
402
|
+
expect(l.length).to eq(1)
|
403
403
|
end
|
404
404
|
end
|
405
405
|
|
@@ -409,8 +409,8 @@ describe Listing do
|
|
409
409
|
|
410
410
|
listings = Listing.tour_of_homes
|
411
411
|
|
412
|
-
listings.
|
413
|
-
listings.count.
|
412
|
+
expect(listings).to be_an(Array)
|
413
|
+
expect(listings.count).to eq(2)
|
414
414
|
|
415
415
|
end
|
416
416
|
end
|
@@ -21,18 +21,18 @@ describe Message do
|
|
21
21
|
on_get_it "should get all my messages" do
|
22
22
|
stub_api_get("/messages", 'messages/get.json')
|
23
23
|
messages = Message.find(:all)
|
24
|
-
messages.size.
|
24
|
+
expect(messages.size).to eq(2)
|
25
25
|
end
|
26
26
|
|
27
27
|
on_post_it "should save a new message" do
|
28
28
|
stub_api_post("/messages", 'messages/new.json', 'messages/post.json')
|
29
|
-
subject.save.
|
29
|
+
expect(subject.save).to be(true)
|
30
30
|
end
|
31
31
|
|
32
32
|
on_post_it "should save a new message with recipients" do
|
33
33
|
stub_api_post("/messages", 'messages/new_with_recipients.json', 'messages/post.json')
|
34
34
|
subject.attributes["Recipients"] = ["20110112234857732941000000","20110092234857738467000000"]
|
35
|
-
subject.save.
|
35
|
+
expect(subject.save).to be(true)
|
36
36
|
end
|
37
37
|
|
38
38
|
on_post_it "should fail saving" do
|
@@ -40,8 +40,8 @@ describe Message do
|
|
40
40
|
request.to_return(:status => 400, :body => fixture('errors/failure.json'))
|
41
41
|
end
|
42
42
|
m=subject.class.new
|
43
|
-
m.save.
|
44
|
-
expect{ m.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.
|
43
|
+
expect(m.save).to be(false)
|
44
|
+
expect{ m.save! }.to raise_error(SparkApi::ClientError){ |e| expect(e.status).to eq(400) }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -49,7 +49,7 @@ describe Message do
|
|
49
49
|
on_get_it "should get a single message" do
|
50
50
|
subject.attributes["Id"] = "20110353423434130982000000"
|
51
51
|
stub_api_get("/messages/#{subject.Id}", "messages/get.json")
|
52
|
-
subject.
|
52
|
+
expect(subject).to be_a(Message)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -57,7 +57,7 @@ describe Message do
|
|
57
57
|
on_get_it "should get all the replies" do
|
58
58
|
subject.attributes["Id"] = "20110353423434130982000000"
|
59
59
|
stub_api_get("/messages/#{subject.Id}/replies", "messages/get.json", :_expand => 'Body, Sender')
|
60
|
-
subject.replies.size.
|
60
|
+
expect(subject.replies.size).to eq(2)
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
@@ -67,13 +67,13 @@ describe Message do
|
|
67
67
|
on_get_it "gets unread messages" do
|
68
68
|
stub_api_get("/messages/unread", 'messages/get.json', {})
|
69
69
|
messages = Message.unread
|
70
|
-
messages.size.
|
71
|
-
messages.first.
|
70
|
+
expect(messages.size).to eq(2)
|
71
|
+
expect(messages.first).to be_a Message
|
72
72
|
end
|
73
73
|
|
74
74
|
on_get_it "gets unread messages count" do
|
75
75
|
stub_api_get("/messages/unread", 'messages/count.json', _pagination: 'count')
|
76
|
-
Message.unread_count.
|
76
|
+
expect(Message.unread_count).to eq(78)
|
77
77
|
end
|
78
78
|
|
79
79
|
end
|
@@ -3,10 +3,10 @@ require './spec/spec_helper'
|
|
3
3
|
describe Note do
|
4
4
|
|
5
5
|
it "responds to instance and class methods" do
|
6
|
-
Note.
|
7
|
-
Note.new.
|
8
|
-
Note.new.
|
9
|
-
Note.new.
|
6
|
+
expect(Note).to respond_to(:get)
|
7
|
+
expect(Note.new).to respond_to(:save)
|
8
|
+
expect(Note.new).to respond_to(:save!)
|
9
|
+
expect(Note.new).to respond_to(:delete)
|
10
10
|
end
|
11
11
|
|
12
12
|
context "when shared with a contact" do
|
@@ -16,19 +16,19 @@ describe Note do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should have the correct path" do
|
19
|
-
@note.path.
|
19
|
+
expect(@note.path).to eq("/listings/1234/shared/notes/contacts/5678")
|
20
20
|
end
|
21
21
|
|
22
22
|
context "/listings/<listing_id>/shared/notes/contacts/<contact_id>", :support do
|
23
23
|
on_get_it "GET should get my notes" do
|
24
24
|
stub_api_get("#{@note.path}", 'notes/agent_shared.json')
|
25
25
|
ret = @note.get
|
26
|
-
ret.Note.
|
26
|
+
expect(ret.Note).to eq("lorem ipsum dolor sit amet")
|
27
27
|
end
|
28
28
|
|
29
29
|
on_get_it "should return a nil when no shared notes exist" do
|
30
30
|
stub_api_get("#{@note.path}", 'notes/agent_shared_empty.json')
|
31
|
-
@note.get.
|
31
|
+
expect(@note.get).to be_nil
|
32
32
|
end
|
33
33
|
|
34
34
|
on_delete_it "should allow you to delete an existing note" do
|
@@ -43,15 +43,15 @@ describe Note do
|
|
43
43
|
request.to_return(:status => 500, :body => fixture('generic_failure.json'))
|
44
44
|
end
|
45
45
|
|
46
|
-
expect { n.save! }.to raise_error(SparkApi::ClientError) { |e| e.status.
|
47
|
-
expect { n.save }.to raise_error(SparkApi::ClientError) { |e| e.status.
|
46
|
+
expect { n.save! }.to raise_error(SparkApi::ClientError) { |e| expect(e.status).to eq(500) }
|
47
|
+
expect { n.save }.to raise_error(SparkApi::ClientError) { |e| expect(e.status).to eq(500) }
|
48
48
|
end
|
49
49
|
|
50
50
|
on_put_it "should allow adding of a note" do
|
51
51
|
n = @note.new(:Note => "lorem ipsum dolor")
|
52
52
|
stub_api_put("#{@note.path}", 'notes/new.json', 'notes/add.json')
|
53
53
|
n.save
|
54
|
-
n.ResourceUri.
|
54
|
+
expect(n.ResourceUri).to eq('/v1/listings/20100909200152674436000000/shared/notes/contacts/20110407212043616271000000/')
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|