spark_api 1.4.28 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +5 -13
  2. data/README.md +1 -1
  3. data/VERSION +1 -1
  4. data/lib/spark_api/authentication/api_auth.rb +1 -1
  5. data/lib/spark_api/authentication/oauth2.rb +1 -1
  6. data/lib/spark_api/authentication/oauth2_impl/grant_type_base.rb +1 -1
  7. data/lib/spark_api/client.rb +2 -2
  8. data/lib/spark_api/models.rb +1 -0
  9. data/lib/spark_api/models/account.rb +7 -1
  10. data/lib/spark_api/models/account_report.rb +0 -5
  11. data/lib/spark_api/models/floplan.rb +24 -0
  12. data/lib/spark_api/models/listing.rb +11 -1
  13. data/lib/spark_api/models/subresource.rb +2 -2
  14. data/lib/spark_api/request.rb +2 -2
  15. data/script/reso_middleware_example.rb +70 -0
  16. data/spec/fixtures/listings/floplans_index.json +15 -0
  17. data/spec/spec_helper.rb +9 -4
  18. data/spec/unit/spark_api/authentication/api_auth_spec.rb +21 -22
  19. data/spec/unit/spark_api/authentication/base_auth_spec.rb +3 -3
  20. data/spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb +1 -1
  21. data/spec/unit/spark_api/authentication/oauth2_impl/grant_type_base_spec.rb +1 -1
  22. data/spec/unit/spark_api/authentication/oauth2_impl/single_session_provider_spec.rb +2 -2
  23. data/spec/unit/spark_api/authentication/oauth2_spec.rb +40 -40
  24. data/spec/unit/spark_api/authentication_spec.rb +2 -2
  25. data/spec/unit/spark_api/configuration/yaml_spec.rb +44 -44
  26. data/spec/unit/spark_api/configuration_spec.rb +56 -57
  27. data/spec/unit/spark_api/faraday_middleware_spec.rb +12 -12
  28. data/spec/unit/spark_api/models/account_report_spec.rb +2 -22
  29. data/spec/unit/spark_api/models/account_spec.rb +24 -21
  30. data/spec/unit/spark_api/models/activity_spec.rb +5 -5
  31. data/spec/unit/spark_api/models/base_spec.rb +32 -32
  32. data/spec/unit/spark_api/models/concerns/destroyable_spec.rb +2 -2
  33. data/spec/unit/spark_api/models/concerns/savable_spec.rb +19 -19
  34. data/spec/unit/spark_api/models/connect_prefs_spec.rb +1 -1
  35. data/spec/unit/spark_api/models/constraint_spec.rb +1 -1
  36. data/spec/unit/spark_api/models/contact_spec.rb +50 -50
  37. data/spec/unit/spark_api/models/dirty_spec.rb +12 -12
  38. data/spec/unit/spark_api/models/document_spec.rb +3 -3
  39. data/spec/unit/spark_api/models/fields_spec.rb +17 -17
  40. data/spec/unit/spark_api/models/finders_spec.rb +7 -7
  41. data/spec/unit/spark_api/models/floplan_spec.rb +24 -0
  42. data/spec/unit/spark_api/models/listing_cart_spec.rb +46 -46
  43. data/spec/unit/spark_api/models/listing_meta_translations_spec.rb +6 -6
  44. data/spec/unit/spark_api/models/listing_spec.rb +91 -91
  45. data/spec/unit/spark_api/models/message_spec.rb +10 -10
  46. data/spec/unit/spark_api/models/note_spec.rb +10 -10
  47. data/spec/unit/spark_api/models/notification_spec.rb +6 -6
  48. data/spec/unit/spark_api/models/open_house_spec.rb +4 -4
  49. data/spec/unit/spark_api/models/photo_spec.rb +8 -8
  50. data/spec/unit/spark_api/models/portal_spec.rb +4 -4
  51. data/spec/unit/spark_api/models/property_types_spec.rb +5 -5
  52. data/spec/unit/spark_api/models/rental_calendar_spec.rb +13 -11
  53. data/spec/unit/spark_api/models/rule_spec.rb +2 -2
  54. data/spec/unit/spark_api/models/saved_search_spec.rb +33 -33
  55. data/spec/unit/spark_api/models/search_template/quick_search_spec.rb +5 -5
  56. data/spec/unit/spark_api/models/shared_listing_spec.rb +12 -12
  57. data/spec/unit/spark_api/models/sort_spec.rb +3 -3
  58. data/spec/unit/spark_api/models/standard_fields_spec.rb +12 -12
  59. data/spec/unit/spark_api/models/subresource_spec.rb +33 -15
  60. data/spec/unit/spark_api/models/system_info_spec.rb +7 -7
  61. data/spec/unit/spark_api/models/tour_of_home_spec.rb +3 -3
  62. data/spec/unit/spark_api/models/video_spec.rb +9 -9
  63. data/spec/unit/spark_api/models/virtual_tour_spec.rb +7 -7
  64. data/spec/unit/spark_api/models/vow_account_spec.rb +8 -8
  65. data/spec/unit/spark_api/multi_client_spec.rb +14 -14
  66. data/spec/unit/spark_api/options_hash_spec.rb +4 -4
  67. data/spec/unit/spark_api/paginate_spec.rb +71 -71
  68. data/spec/unit/spark_api/primary_array_spec.rb +5 -5
  69. data/spec/unit/spark_api/request_spec.rb +65 -59
  70. data/spec/unit/spark_api_spec.rb +6 -6
  71. metadata +215 -280
@@ -0,0 +1,24 @@
1
+ require './spec/spec_helper'
2
+
3
+ describe FloPlan do
4
+
5
+ it "responds to" do
6
+ expect(FloPlan).to respond_to(:find_by_listing_key)
7
+ end
8
+
9
+ describe "/listings/<listing_id>/videos", :support do
10
+ before do
11
+ stub_auth_request
12
+ stub_api_get('/listings/1234/floplans','listings/floplans_index.json')
13
+ end
14
+
15
+ on_get_it "should correctly split images and thumbnails" do
16
+ p = FloPlan.find_by_listing_key('1234').first
17
+ expect(p.attributes['Images'].length).to eq(2)
18
+ expect(p.images.length).to eq(1)
19
+ expect(p.thumbnails.length).to eq(1)
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -9,9 +9,9 @@ describe ListingCart do
9
9
  on_get_it "should get all listing carts" do
10
10
  stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
11
11
  resources = subject.class.get
12
- resources.should be_an(Array)
13
- resources.length.should eq(2)
14
- resources.first.Id.should eq("20100912153422758914000000")
12
+ expect(resources).to be_an(Array)
13
+ expect(resources.length).to eq(2)
14
+ expect(resources.first.Id).to eq("20100912153422758914000000")
15
15
  end
16
16
 
17
17
  on_post_it "should save a new listing cart" do
@@ -20,8 +20,8 @@ describe ListingCart do
20
20
  '20110302120238448431000000',
21
21
  '20110510011212354751000000']
22
22
  subject.Name = "My Cart's Name"
23
- subject.save.should be(true)
24
- subject.ResourceUri.should eq("/v1/listingcarts/20100912153422758914000000")
23
+ expect(subject.save).to be(true)
24
+ expect(subject.ResourceUri).to eq("/v1/listingcarts/20100912153422758914000000")
25
25
  end
26
26
 
27
27
  on_post_it "should fail saving" do
@@ -29,8 +29,8 @@ describe ListingCart do
29
29
  request.to_return(:status => 400, :body => fixture('errors/failure.json'))
30
30
  end
31
31
  subject
32
- subject.save.should be(false)
33
- expect{ subject.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.should == 400 }
32
+ expect(subject.save).to be(false)
33
+ expect{ subject.save! }.to raise_error(SparkApi::ClientError){ |e| expect(e.status).to eq(400) }
34
34
  end
35
35
  end
36
36
 
@@ -38,9 +38,9 @@ describe ListingCart do
38
38
  on_get_it "should get a listing cart" do
39
39
  stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
40
40
  resource = subject.class.get.first
41
- resource.Id.should eq("20100912153422758914000000")
42
- resource.Name.should eq("My Listing Cart")
43
- resource.ListingCount.should eq(10)
41
+ expect(resource.Id).to eq("20100912153422758914000000")
42
+ expect(resource.Name).to eq("My Listing Cart")
43
+ expect(resource.ListingCount).to eq(10)
44
44
  end
45
45
 
46
46
  on_put_it "should save a listing cart Name" do
@@ -48,9 +48,9 @@ describe ListingCart do
48
48
  resource = subject.class.get.first
49
49
  stub_api_put("/#{subject.class.element_name}/#{resource.Id}", 'listing_carts/put_name.json', 'success.json')
50
50
  resource.Name = "My Cart's Name"
51
- resource.changed?.should be(true)
52
- resource.save.should be(true)
53
- resource.ResourceUri.should eq("/v1/listingcarts/20100912153422758914000000")
51
+ expect(resource.changed?).to be(true)
52
+ expect(resource.save).to be(true)
53
+ expect(resource.ResourceUri).to eq("/v1/listingcarts/20100912153422758914000000")
54
54
  end
55
55
 
56
56
  on_put_it "should save a listing cart ListingIds" do
@@ -60,41 +60,41 @@ describe ListingCart do
60
60
  resource.ListingIds = ['20110112234857732941000000',
61
61
  '20110302120238448431000000',
62
62
  '20110510011212354751000000']
63
- resource.changed?.should be(true)
64
- resource.save.should be(true)
65
- resource.ResourceUri.should eq("/v1/listingcarts/20100912153422758914000000")
63
+ expect(resource.changed?).to be(true)
64
+ expect(resource.save).to be(true)
65
+ expect(resource.ResourceUri).to eq("/v1/listingcarts/20100912153422758914000000")
66
66
  end
67
67
 
68
68
  on_post_it "should add a listing to a cart" do
69
69
  list_id = "20110621133454434543000000"
70
70
  stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
71
71
  resource = subject.class.get.first
72
- resource.Id.should eq("20100912153422758914000000")
72
+ expect(resource.Id).to eq("20100912153422758914000000")
73
73
  stub_api_post("/#{subject.class.element_name}/#{resource.Id}",'listing_carts/add_listing_post.json', 'listing_carts/add_listing.json')
74
- resource.ListingCount.should eq(10)
74
+ expect(resource.ListingCount).to eq(10)
75
75
  resource.add_listing(list_id)
76
- resource.ListingCount.should eq(11)
76
+ expect(resource.ListingCount).to eq(11)
77
77
  end
78
78
 
79
79
  on_post_it "should add multiple listings to a cart" do
80
80
  listing_ids = ["20110621133454434543000000", "20110621133454434543000001"]
81
81
  stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
82
82
  resource = subject.class.get.first
83
- resource.Id.should eq("20100912153422758914000000")
83
+ expect(resource.Id).to eq("20100912153422758914000000")
84
84
  stub_api_post("/#{subject.class.element_name}/#{resource.Id}",'listing_carts/add_listings_post.json', 'listing_carts/add_listings.json')
85
- resource.ListingCount.should eq(10)
85
+ expect(resource.ListingCount).to eq(10)
86
86
  resource.add_listings(listing_ids)
87
- resource.ListingCount.should eq(12)
87
+ expect(resource.ListingCount).to eq(12)
88
88
  end
89
89
 
90
90
  on_delete_it "should delete a listing cart" do
91
91
  stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
92
92
  resource = subject.class.get.first
93
- resource.Id.should eq("20100912153422758914000000")
94
- resource.Name.should eq("My Listing Cart")
95
- resource.ListingCount.should eq(10)
93
+ expect(resource.Id).to eq("20100912153422758914000000")
94
+ expect(resource.Name).to eq("My Listing Cart")
95
+ expect(resource.ListingCount).to eq(10)
96
96
  stub_api_delete("/#{subject.class.element_name}/#{resource.Id}", 'success.json')
97
- resource.delete.should be(true)
97
+ expect(resource.delete).to be(true)
98
98
  end
99
99
  end
100
100
 
@@ -103,11 +103,11 @@ describe ListingCart do
103
103
  list_id = "20110621133454434543000000"
104
104
  stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
105
105
  resource = subject.class.get.first
106
- resource.Id.should eq("20100912153422758914000000")
106
+ expect(resource.Id).to eq("20100912153422758914000000")
107
107
  stub_api_delete("/#{subject.class.element_name}/#{resource.Id}/listings/#{list_id}", 'listing_carts/remove_listing.json')
108
- resource.ListingCount.should eq(10)
108
+ expect(resource.ListingCount).to eq(10)
109
109
  resource.remove_listing(list_id)
110
- resource.ListingCount.should eq(9)
110
+ expect(resource.ListingCount).to eq(9)
111
111
  end
112
112
  end
113
113
 
@@ -117,9 +117,9 @@ describe ListingCart do
117
117
  stub_api_get("/#{subject.class.element_name}/for/#{listing.Id}", 'listing_carts/listing_cart.json')
118
118
  [listing, listing.Id ].each do |l|
119
119
  resources = subject.class.for(l)
120
- resources.should be_an(Array)
121
- resources.length.should eq(2)
122
- resources.first.Id.should eq("20100912153422758914000000")
120
+ expect(resources).to be_an(Array)
121
+ expect(resources.length).to eq(2)
122
+ expect(resources.first.Id).to eq("20100912153422758914000000")
123
123
  end
124
124
  end
125
125
  end
@@ -128,9 +128,9 @@ describe ListingCart do
128
128
  on_get_it "should get the carts for a user" do
129
129
  stub_api_get("/my/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
130
130
  resources = subject.class.my
131
- resources.should be_an(Array)
132
- resources.length.should eq(2)
133
- resources.first.Id.should eq("20100912153422758914000000")
131
+ expect(resources).to be_an(Array)
132
+ expect(resources.length).to eq(2)
133
+ expect(resources.first.Id).to eq("20100912153422758914000000")
134
134
  end
135
135
  end
136
136
 
@@ -138,9 +138,9 @@ describe ListingCart do
138
138
  on_get_it "should get the carts specific to a portal user" do
139
139
  stub_api_get("/#{subject.class.element_name}/portal", 'listing_carts/listing_cart.json')
140
140
  resources = subject.class.portal
141
- resources.should be_an(Array)
142
- resources.length.should eq(2)
143
- resources.first.Id.should eq("20100912153422758914000000")
141
+ expect(resources).to be_an(Array)
142
+ expect(resources.length).to eq(2)
143
+ expect(resources.first.Id).to eq("20100912153422758914000000")
144
144
  end
145
145
  end
146
146
 
@@ -148,38 +148,38 @@ describe ListingCart do
148
148
  it "should return the listings in the cart" do
149
149
  resource = subject.class.new Id: 5, ListingIds: ["1234"]
150
150
  stub_api_get("/#{subject.class.element_name}/#{resource.Id}/listings", 'listings/multiple.json')
151
- resource.listings.should be_a(Array)
152
- resource.listings.first.should be_a(Listing)
151
+ expect(resource.listings).to be_a(Array)
152
+ expect(resource.listings.first).to be_a(Listing)
153
153
  end
154
154
 
155
155
  it "should return an empty array if there aren't any listings" do
156
156
  resource = subject.class.new Id: 5
157
- resource.listings.should be_a(Array)
158
- resource.listings.count.should === 0
157
+ expect(resource.listings).to be_a(Array)
158
+ expect(resource.listings.count).to be === 0
159
159
  end
160
160
  end
161
161
 
162
162
  describe "filter" do
163
163
  it "should return a filter string for the cart" do
164
164
  resource = subject.class.new Id: 5
165
- resource.filter.should eq("ListingCart Eq '5'")
165
+ expect(resource.filter).to eq("ListingCart Eq '5'")
166
166
  end
167
167
  end
168
168
 
169
169
  describe "#deletable?" do
170
170
  it "should return true for private custom carts" do
171
171
  resource = subject.class.new
172
- expect(resource.deletable?).to be_true
172
+ expect(resource.deletable?).to be true
173
173
  end
174
174
 
175
175
  it "should return true for custom vow carts" do
176
176
  resource = subject.class.new PortalCartType: "Custom"
177
- expect(resource.deletable?).to be_true
177
+ expect(resource.deletable?).to be true
178
178
  end
179
179
 
180
180
  it "should return false for vow carts" do
181
181
  resource = subject.class.new PortalCartType: "Favorites"
182
- expect(resource.deletable?).to be_false
182
+ expect(resource.deletable?).to be false
183
183
  end
184
184
  end
185
185
 
@@ -12,18 +12,18 @@ describe ListingMetaTranslations do
12
12
  stub_api_get("/flexmls/propertytypes/A/translations", 'listing_meta_translations/get.json')
13
13
 
14
14
  translations = ListingMetaTranslations.for_property_type('A')
15
- translations.should be_an(ListingMetaTranslations)
16
- translations.StandardFields.should be_an(Hash)
17
- translations.CustomFields.should be_an(Hash)
15
+ expect(translations).to be_an(ListingMetaTranslations)
16
+ expect(translations.StandardFields).to be_an(Hash)
17
+ expect(translations.CustomFields).to be_an(Hash)
18
18
  end
19
19
 
20
20
  on_get_it "doesn't explode if there are no results" do
21
21
  stub_api_get("/flexmls/propertytypes/A/translations", 'no_results.json')
22
22
 
23
23
  translations = ListingMetaTranslations.for_property_type('A')
24
- translations.should be_an(ListingMetaTranslations)
25
- translations.StandardFields.should be_an(Hash)
26
- translations.CustomFields.should be_an(Hash)
24
+ expect(translations).to be_an(ListingMetaTranslations)
25
+ expect(translations.StandardFields).to be_an(Hash)
26
+ expect(translations.CustomFields).to be_an(Hash)
27
27
  end
28
28
  end
29
29
 
@@ -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.should be_a(Hash)
78
- @listing.StandardFields['ListingId'].should be_a(String)
79
- @listing.StandardFields['ListPrice'].should match(@listing.ListPrice)
80
- @listing.photos.should be_a(Array)
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.should_not respond_to(:Photos)
85
- @listing.should_not respond_to(:Documents)
86
- @listing.should_not respond_to(:VirtualTours)
87
- @listing.should_not respond_to(:Videos)
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.should eq("100 Someone's St")
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.should eq("")
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.should eq('')
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.should eq("Fargo, ND 55320")
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.should eq("100 Someone's St, Fargo, ND 55320")
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.should eq("Someone's")
118
- @listing.YearBuilt.should eq(nil)
119
- @listing.BuildingAreaTotal.should eq("1321.0")
120
- @listing.PublicRemarks.should eq(nil)
121
- @listing.PostalCode.should eq("55320")
122
- @listing.ListPrice.should eq("100000.0")
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.should respond_to(:StreetName)
127
- @listing.should respond_to(:YearBuilt)
128
- @listing.should respond_to(:BuildingAreaTotal)
129
- @listing.should respond_to(:PublicRemarks)
130
- @listing.should respond_to(:PostalCode)
131
- @listing.should respond_to(:ListPrice)
132
-
133
- @listing.should_not respond_to(:BogusField)
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.should respond_to(:BogusField)
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.should respond_to(:find)
141
+ expect(Listing).to respond_to(:find)
142
142
  end
143
143
 
144
144
  it "should respond to first" do
145
- Listing.should respond_to(:first)
145
+ expect(Listing).to respond_to(:first)
146
146
  end
147
147
 
148
148
  it "should respond to last" do
149
- Listing.should respond_to(:last)
149
+ expect(Listing).to respond_to(:last)
150
150
  end
151
151
 
152
152
  it "should respond to my" do
153
- Listing.should respond_to(:my)
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.should respond_to(:find_by_cart_id)
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.should respond_to(:count)
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.should be_an(Array)
176
- listings.count.should eq(2)
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.should == 2001
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.should == 0
192
- l.photos.length.should == 0
193
- l.documents.length.should == 0
194
- l.Id.should eq('20060725224713296297000000')
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.should be(true)
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.should be(true)
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.should be(false)
225
- expect{ l.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.should == 400 }
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.should be(true)
235
- l.constraints.size.should eq(1)
236
- l.constraints.first.RuleName.should eq("MaxValue")
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.should be_false
249
- l.constraints.size.should eq(1)
250
- l.constraints.first.RuleName.should eq("MaxIncreasePercent")
251
- l.errors.size.should eq(1)
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.should eq(5)
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').should be(true)
281
- l.constraints.size.should eq(1)
282
- l.constraints.first.RuleName.should eq("MaxValue")
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.should == 5
292
- l.documents.length.should == 0
293
- l.videos.length.should == 0
294
- l.virtual_tours.length.should == 0
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.should == 0
302
- l.documents.length.should == 2
303
- l.videos.length.should == 0
304
- l.virtual_tours.length.should == 0
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.should == 1
312
- l.photos.length.should == 0
313
- l.documents.length.should == 0
314
- l.videos.length.should == 0
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.should == 2
322
- l.virtual_tours.length.should == 0
323
- l.photos.length.should == 0
324
- l.documents.length.should == 0
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.should == 2
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.should == 2
341
- #l.videos.length.should == 0
342
- #l.photos.length.should == 0
343
- #l.documents.length.should == 0
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"].should eq(true)
350
- l.editable?().should eq(true)
351
- l.editable?(:PriceChange).should eq(true)
352
- l.editable?(:Photos).should eq(false)
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).should_not be_empty
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.should be_an(Array)
373
- listings.count.should eq(2)
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.should be_an(Array)
383
- listings.count.should eq(2)
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.should be_an(Array)
393
- listings.count.should eq(2)
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.should == 1
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.should be_an(Array)
413
- listings.count.should eq(2)
412
+ expect(listings).to be_an(Array)
413
+ expect(listings.count).to eq(2)
414
414
 
415
415
  end
416
416
  end