you_got_listed 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/you_got_listed/accounts.rb +2 -2
- data/lib/you_got_listed/agent.rb +6 -6
- data/lib/you_got_listed/client.rb +5 -5
- data/lib/you_got_listed/complex.rb +6 -6
- data/lib/you_got_listed/complexes.rb +8 -8
- data/lib/you_got_listed/error.rb +4 -4
- data/lib/you_got_listed/lead.rb +3 -3
- data/lib/you_got_listed/listing.rb +15 -14
- data/lib/you_got_listed/listings.rb +13 -13
- data/lib/you_got_listed/resource.rb +5 -5
- data/lib/you_got_listed/response.rb +19 -8
- data/lib/you_got_listed/version.rb +1 -1
- data/lib/you_got_listed.rb +0 -1
- data/spec/fixtures/responses/blank.xml +0 -0
- data/spec/fixtures/responses/empty.xml +2 -0
- data/spec/you_got_listed/accounts_spec.rb +5 -5
- data/spec/you_got_listed/agent_spec.rb +14 -14
- data/spec/you_got_listed/client_spec.rb +4 -4
- data/spec/you_got_listed/complex_spec.rb +5 -5
- data/spec/you_got_listed/complexes_spec.rb +13 -13
- data/spec/you_got_listed/error_spec.rb +2 -2
- data/spec/you_got_listed/lead_spec.rb +6 -6
- data/spec/you_got_listed/listing_spec.rb +82 -20
- data/spec/you_got_listed/listings_spec.rb +69 -33
- data/spec/you_got_listed/resource_spec.rb +3 -3
- data/spec/you_got_listed/response_spec.rb +52 -24
- data/you_got_listed.gemspec +1 -2
- metadata +20 -32
@@ -1,40 +1,40 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe YouGotListed::Complexes do
|
4
|
-
|
4
|
+
|
5
5
|
before do
|
6
6
|
@ygl = new_ygl
|
7
7
|
@complexes = YouGotListed::Complexes.new(@ygl)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
context "search" do
|
11
11
|
before do
|
12
12
|
VCR.use_cassette('complexes.search') do
|
13
13
|
@response = @complexes.search
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it { @response.should be_kind_of(YouGotListed::Complexes::SearchResponse) }
|
18
18
|
it { @response.success?.should be_true }
|
19
|
-
|
19
|
+
|
20
20
|
context "search response" do
|
21
21
|
it { @response.should be_kind_of(YouGotListed::Response) }
|
22
22
|
it { @response.should respond_to(:property_complexes, :paginator) }
|
23
|
-
|
23
|
+
|
24
24
|
it "should return an array of property_complexes" do
|
25
25
|
@response.property_complexes.should be_kind_of(Array)
|
26
26
|
@response.property_complexes.each do |property|
|
27
27
|
property.should be_kind_of(YouGotListed::Complex)
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it "should return a will_paginate collection" do
|
32
32
|
@response.paginator.should be_kind_of(WillPaginate::Collection)
|
33
33
|
@response.paginator.collect{|p| p.id}.should == @response.property_complexes.collect{|p| p.id}
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
context "find_by_id" do
|
39
39
|
context "valid id" do
|
40
40
|
before do
|
@@ -45,20 +45,20 @@ describe YouGotListed::Complexes do
|
|
45
45
|
@complex = @complexes.find_by_id(@valid_complex_id)
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
it { @complex.should be_kind_of(YouGotListed::Complex) }
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
context "missing id" do
|
53
53
|
before do
|
54
54
|
VCR.use_cassette('complexes.find_by_id_missing') do
|
55
55
|
@complex = @complexes.find_by_id('CSM-111-382')
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
it { @complex.should be_nil }
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
context "invalid id" do
|
63
63
|
it "should not raise an exception" do
|
64
64
|
lambda {
|
@@ -67,7 +67,7 @@ describe YouGotListed::Complexes do
|
|
67
67
|
end
|
68
68
|
}.should_not raise_exception
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
it "should be nil" do
|
72
72
|
VCR.use_cassette('complexes.find_by_id_invalid') do
|
73
73
|
@complex = @complexes.find_by_id('CAM')
|
@@ -76,5 +76,5 @@ describe YouGotListed::Complexes do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe YouGotListed::Error do
|
4
|
-
|
4
|
+
|
5
5
|
it "should set a message" do
|
6
6
|
@error = YouGotListed::Error.new(300, 'Account retrieving failed.')
|
7
7
|
@error.message.should == "YouGotListed Error: Account retrieving failed. (code: 300)"
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe YouGotListed::Lead do
|
4
|
-
|
4
|
+
|
5
5
|
before do
|
6
6
|
@ygl = new_ygl
|
7
7
|
@lead = YouGotListed::Lead.new(@ygl)
|
8
8
|
@success_params = {:first_name => "You", :last_name => "GotListed", :email => "ygl@gmail.com"}
|
9
9
|
@failed_params = {}
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
context "create" do
|
13
13
|
context "a successful creation" do
|
14
14
|
it "should not raise an exception" do
|
@@ -19,7 +19,7 @@ describe YouGotListed::Lead do
|
|
19
19
|
}.should_not raise_exception
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
context "a failed creation" do
|
24
24
|
it "should raise an exception" do
|
25
25
|
lambda {
|
@@ -30,7 +30,7 @@ describe YouGotListed::Lead do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
context "create!" do
|
35
35
|
context "a successful creation" do
|
36
36
|
it "should not raise an exception" do
|
@@ -41,7 +41,7 @@ describe YouGotListed::Lead do
|
|
41
41
|
}.should_not raise_exception
|
42
42
|
end
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
context "a failed creation" do
|
46
46
|
it "should raise an exception" do
|
47
47
|
lambda {
|
@@ -52,5 +52,5 @@ describe YouGotListed::Lead do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe YouGotListed::Listing do
|
4
|
-
|
4
|
+
|
5
5
|
before do
|
6
6
|
@ygl = new_ygl
|
7
7
|
@listing = YouGotListed::Listing.new(valid_listing_rash, @ygl)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should create methods from all hash keys" do
|
11
11
|
@listing.should respond_to(
|
12
12
|
"unit_level", "pet", "include_hot_water", "square_footage", "external_id", "zip", "student_policy",
|
@@ -16,72 +16,134 @@ describe YouGotListed::Listing do
|
|
16
16
|
"include_gas", "state", "baths", "photos"
|
17
17
|
)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should return ygl id for id" do
|
21
21
|
@listing.id.should == "BOS-182-933"
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should return the city - neighborhood for town_neighborhood" do
|
25
25
|
@listing.town_neighborhood.should == 'Boston - Fenway'
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should return the city_neighborhood search param for city_neighborhood" do
|
29
29
|
@listing.city_neighborhood.should == 'Boston:Fenway'
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "should return photos for pictures" do
|
33
33
|
@listing.pictures.should == @listing.photos.photo
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
context "default similar listings" do
|
37
37
|
before do
|
38
38
|
VCR.use_cassette('listing.similar_listings') do
|
39
39
|
@similar_props = @listing.similar_listings
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
it "should return an array of listings" do
|
44
44
|
@similar_props.should be_kind_of(Array)
|
45
45
|
@similar_props.should have_at_most(6).listings
|
46
46
|
@similar_props.collect{|x| x.id}.should_not include(@listing.id)
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
context "similar listings with custom limit" do
|
51
51
|
before do
|
52
52
|
VCR.use_cassette('listing.similar_listings') do
|
53
53
|
@similar_props = @listing.similar_listings(4)
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
it "should return an array of listings" do
|
58
58
|
@similar_props.should be_kind_of(Array)
|
59
59
|
@similar_props.should have_at_most(4).listings
|
60
60
|
@similar_props.collect{|x| x.id}.should_not include(@listing.id)
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
|
+
context "empty response" do
|
65
|
+
before do
|
66
|
+
min_baths = ((@listing.baths.to_i - 1) <= 0 ? 0 : (@listing.baths.to_i - 1))
|
67
|
+
max_baths = @listing.baths.to_i + 1
|
68
|
+
min_rent = (@listing.price.to_i * 0.9).to_i
|
69
|
+
max_rent = (@listing.price.to_i * 1.1).to_i
|
70
|
+
min_beds = ((@listing.beds.to_i - 1) <= 0 ? 0 : (@listing.beds.to_i - 1))
|
71
|
+
max_beds = @listing.beds.to_i + 1
|
72
|
+
httparty_get(@ygl.class.base_uri, '/rentals/search.php', 'empty.xml', @ygl.class.default_params.merge({
|
73
|
+
:limit => 7.to_s,
|
74
|
+
:min_rent => min_rent.to_s,
|
75
|
+
:max_rent => max_rent.to_s,
|
76
|
+
:min_bed => min_beds.to_s,
|
77
|
+
:max_bed => max_beds.to_s,
|
78
|
+
:baths => [min_baths, @listing.baths, max_baths].join(','),
|
79
|
+
:city_neighborhood => @listing.city_neighborhood,
|
80
|
+
:page_count => 20.to_s,
|
81
|
+
:page_index => 1.to_s,
|
82
|
+
:sort_name => "rent",
|
83
|
+
:sort_dir => "asc",
|
84
|
+
:detail_level => 2.to_s
|
85
|
+
})
|
86
|
+
)
|
87
|
+
@similar_props = @listing.similar_listings
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should return an empty array of listings" do
|
91
|
+
@similar_props.should be_empty
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "blank response" do
|
96
|
+
before do
|
97
|
+
min_baths = ((@listing.baths.to_i - 1) <= 0 ? 0 : (@listing.baths.to_i - 1))
|
98
|
+
max_baths = @listing.baths.to_i + 1
|
99
|
+
min_rent = (@listing.price.to_i * 0.9).to_i
|
100
|
+
max_rent = (@listing.price.to_i * 1.1).to_i
|
101
|
+
min_beds = ((@listing.beds.to_i - 1) <= 0 ? 0 : (@listing.beds.to_i - 1))
|
102
|
+
max_beds = @listing.beds.to_i + 1
|
103
|
+
httparty_get(@ygl.class.base_uri, '/rentals/search.php', 'blank.xml', @ygl.class.default_params.merge({
|
104
|
+
:limit => 7.to_s,
|
105
|
+
:min_rent => min_rent.to_s,
|
106
|
+
:max_rent => max_rent.to_s,
|
107
|
+
:min_bed => min_beds.to_s,
|
108
|
+
:max_bed => max_beds.to_s,
|
109
|
+
:baths => [min_baths, @listing.baths, max_baths].join(','),
|
110
|
+
:city_neighborhood => @listing.city_neighborhood,
|
111
|
+
:page_count => 20.to_s,
|
112
|
+
:page_index => 1.to_s,
|
113
|
+
:sort_name => "rent",
|
114
|
+
:sort_dir => "asc",
|
115
|
+
:detail_level => 2.to_s
|
116
|
+
})
|
117
|
+
)
|
118
|
+
@similar_props = @listing.similar_listings
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should return an empty array of listings" do
|
122
|
+
@similar_props.should be_empty
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
64
126
|
context "mls_listing" do
|
65
127
|
before do
|
66
128
|
@listing = YouGotListed::Listing.new(valid_listing_rash.merge(:source => 'MLS'), @ygl)
|
67
129
|
end
|
68
|
-
|
130
|
+
|
69
131
|
it "should be a mls_listing" do
|
70
132
|
@listing.mls_listing?.should be_true
|
71
133
|
end
|
72
134
|
end
|
73
|
-
|
135
|
+
|
74
136
|
context "main_picture" do
|
75
137
|
it "should return the first photo" do
|
76
138
|
@listing.main_picture.should == @listing.pictures.first
|
77
139
|
@listing.main_picture.should == "http://yougotlistings.com/photos/AC-000-103/500141.jpg"
|
78
140
|
end
|
79
|
-
|
141
|
+
|
80
142
|
it "should return nil if no pictures" do
|
81
143
|
@listing.stub!(:pictures).and_return(nil)
|
82
144
|
@listing.main_picture.should be_nil
|
83
145
|
end
|
84
|
-
|
146
|
+
|
85
147
|
it "should return an array if the property has only one photo" do
|
86
148
|
rash = valid_listing_rash
|
87
149
|
rash[:photos].merge!(:photo => 'http://ygl-photos.s3.amazonaws.com/1236380.jpg')
|
@@ -90,29 +152,29 @@ describe YouGotListed::Listing do
|
|
90
152
|
@listing.main_picture.should == 'http://ygl-photos.s3.amazonaws.com/1236380.jpg'
|
91
153
|
end
|
92
154
|
end
|
93
|
-
|
155
|
+
|
94
156
|
context "latitude" do
|
95
157
|
it "should return a float" do
|
96
158
|
@listing.latitude.should be_kind_of(Float)
|
97
159
|
@listing.latitude.should == 42.346182
|
98
160
|
end
|
99
|
-
|
161
|
+
|
100
162
|
it "should return nil if blank" do
|
101
163
|
@listing = YouGotListed::Listing.new(valid_listing_rash.merge(:latitude => ''), @ygl)
|
102
164
|
@listing.latitude.should be_nil
|
103
165
|
end
|
104
166
|
end
|
105
|
-
|
167
|
+
|
106
168
|
context "longitude" do
|
107
169
|
it "should return a float" do
|
108
170
|
@listing.longitude.should be_kind_of(Float)
|
109
171
|
@listing.longitude.should == -71.104427
|
110
172
|
end
|
111
|
-
|
173
|
+
|
112
174
|
it "should return nil if blank" do
|
113
175
|
@listing = YouGotListed::Listing.new(valid_listing_rash.merge(:longitude => ''), @ygl)
|
114
176
|
@listing.longitude.should be_nil
|
115
177
|
end
|
116
178
|
end
|
117
|
-
|
179
|
+
|
118
180
|
end
|
@@ -1,40 +1,76 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe YouGotListed::Listings do
|
4
|
-
|
4
|
+
|
5
5
|
before do
|
6
6
|
@ygl = new_ygl
|
7
7
|
@listings = YouGotListed::Listings.new(@ygl)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
context "search" do
|
11
11
|
before do
|
12
12
|
VCR.use_cassette('listings.search') do
|
13
13
|
@response = @listings.search
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it { @response.should be_kind_of(YouGotListed::Listings::SearchResponse) }
|
18
18
|
it { @response.success?.should be_true }
|
19
|
-
|
19
|
+
|
20
20
|
context "search response" do
|
21
21
|
it { @response.should be_kind_of(YouGotListed::Response) }
|
22
22
|
it { @response.should respond_to(:properties, :paginator) }
|
23
|
-
|
23
|
+
|
24
24
|
it "should return an array of properties" do
|
25
25
|
@response.properties.should be_kind_of(Array)
|
26
26
|
@response.properties.each do |property|
|
27
27
|
property.should be_kind_of(YouGotListed::Listing)
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it "should return a will_paginate collection" do
|
32
32
|
@response.paginator.should be_kind_of(WillPaginate::Collection)
|
33
33
|
@response.paginator.collect{|p| p.id}.should == @response.properties.collect{|p| p.id}
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
|
+
context "empty response" do
|
39
|
+
before do
|
40
|
+
httparty_get(@ygl.class.base_uri, '/rentals/search.php', 'empty.xml', @ygl.class.default_params.merge({
|
41
|
+
:page_count => 20.to_s,
|
42
|
+
:page_index => 1.to_s,
|
43
|
+
:sort_name => "rent",
|
44
|
+
:sort_dir => "asc",
|
45
|
+
:detail_level => 2.to_s
|
46
|
+
})
|
47
|
+
)
|
48
|
+
@response = @listings.search
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return an empty array of listings" do
|
52
|
+
@response.properties.should be_empty
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "blank response" do
|
57
|
+
before do
|
58
|
+
httparty_get(@ygl.class.base_uri, '/rentals/search.php', 'blank.xml', @ygl.class.default_params.merge({
|
59
|
+
:page_count => 20.to_s,
|
60
|
+
:page_index => 1.to_s,
|
61
|
+
:sort_name => "rent",
|
62
|
+
:sort_dir => "asc",
|
63
|
+
:detail_level => 2.to_s
|
64
|
+
})
|
65
|
+
)
|
66
|
+
@response = @listings.search
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should return an empty array of listings" do
|
70
|
+
@response.properties.should be_empty
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
38
74
|
context "mls_search" do
|
39
75
|
before do
|
40
76
|
VCR.use_cassette('listings.mls_search') do
|
@@ -42,24 +78,24 @@ describe YouGotListed::Listings do
|
|
42
78
|
@response.properties.first.stub!(:source).and_return('MLS')
|
43
79
|
end
|
44
80
|
end
|
45
|
-
|
81
|
+
|
46
82
|
context "search response" do
|
47
83
|
it { @response.mls_results?.should be_true }
|
48
84
|
end
|
49
85
|
end
|
50
|
-
|
86
|
+
|
51
87
|
context "featured" do
|
52
88
|
before do
|
53
89
|
VCR.use_cassette('listings.featured') do
|
54
90
|
@response = @listings.featured
|
55
91
|
end
|
56
92
|
end
|
57
|
-
|
93
|
+
|
58
94
|
it "should only return featured properties" do
|
59
95
|
@response.properties.find_all{|p| p.tags && p.tags.tag.include?('Featured Rentals')}.size.should == @response.properties.size
|
60
96
|
end
|
61
97
|
end
|
62
|
-
|
98
|
+
|
63
99
|
context "find_by_id" do
|
64
100
|
context "valid id" do
|
65
101
|
before do
|
@@ -70,20 +106,20 @@ describe YouGotListed::Listings do
|
|
70
106
|
@listing = @listings.find_by_id(@valid_listing_id)
|
71
107
|
end
|
72
108
|
end
|
73
|
-
|
109
|
+
|
74
110
|
it { @listing.should be_kind_of(YouGotListed::Listing) }
|
75
111
|
end
|
76
|
-
|
112
|
+
|
77
113
|
context "missing id" do
|
78
114
|
before do
|
79
115
|
VCR.use_cassette('listings.find_by_id_missing') do
|
80
116
|
@listing = @listings.find_by_id('CAM-111-3823475')
|
81
117
|
end
|
82
118
|
end
|
83
|
-
|
119
|
+
|
84
120
|
it { @listing.should be_nil }
|
85
121
|
end
|
86
|
-
|
122
|
+
|
87
123
|
context "invalid id" do
|
88
124
|
it "should not raise an exception" do
|
89
125
|
lambda {
|
@@ -92,7 +128,7 @@ describe YouGotListed::Listings do
|
|
92
128
|
end
|
93
129
|
}.should_not raise_exception
|
94
130
|
end
|
95
|
-
|
131
|
+
|
96
132
|
it "should be nil" do
|
97
133
|
VCR.use_cassette('listings.find_by_id_invalid') do
|
98
134
|
@listing = @listings.find_by_id('CAM')
|
@@ -101,7 +137,7 @@ describe YouGotListed::Listings do
|
|
101
137
|
end
|
102
138
|
end
|
103
139
|
end
|
104
|
-
|
140
|
+
|
105
141
|
context "find_all" do
|
106
142
|
before do
|
107
143
|
search_params = {:max_rent => "2000"}
|
@@ -109,16 +145,16 @@ describe YouGotListed::Listings do
|
|
109
145
|
@properties = @listings.find_all(search_params)
|
110
146
|
end
|
111
147
|
end
|
112
|
-
|
148
|
+
|
113
149
|
it { @properties.should be_kind_of(Array)}
|
114
|
-
|
150
|
+
|
115
151
|
it "should only return properties" do
|
116
152
|
@properties.each do |p|
|
117
153
|
p.should be_kind_of(YouGotListed::Listing)
|
118
154
|
end
|
119
155
|
end
|
120
156
|
end
|
121
|
-
|
157
|
+
|
122
158
|
context "find_all_by_ids" do
|
123
159
|
before do
|
124
160
|
VCR.use_cassette('listings.search') do
|
@@ -137,44 +173,44 @@ describe YouGotListed::Listings do
|
|
137
173
|
@find_ids_with_off_market = @find_ids.clone
|
138
174
|
@find_ids_with_off_market << @off_market_id if @off_market_id
|
139
175
|
end
|
140
|
-
|
176
|
+
|
141
177
|
context "passing an array of ids" do
|
142
178
|
before do
|
143
179
|
VCR.use_cassette('listings.find_all_by_ids.array') do
|
144
180
|
@properties = @listings.find_all_by_ids(@find_ids)
|
145
181
|
end
|
146
182
|
end
|
147
|
-
|
183
|
+
|
148
184
|
it { @properties.should be_kind_of(Array) }
|
149
|
-
|
185
|
+
|
150
186
|
it "should only return properties for requested ids" do
|
151
187
|
@properties.each do |p|
|
152
188
|
@find_ids.should include(p.id)
|
153
189
|
end
|
154
190
|
end
|
155
191
|
end
|
156
|
-
|
192
|
+
|
157
193
|
context "passing an string of ids" do
|
158
194
|
before do
|
159
195
|
VCR.use_cassette('listings.find_all_by_ids.string') do
|
160
196
|
@properties = @listings.find_all_by_ids(@find_ids.join(','))
|
161
197
|
end
|
162
198
|
end
|
163
|
-
|
199
|
+
|
164
200
|
it { @properties.should be_kind_of(Array) }
|
165
201
|
end
|
166
|
-
|
202
|
+
|
167
203
|
context "should not return off market properties if directed not to" do
|
168
204
|
before do
|
169
205
|
VCR.use_cassette('listings.find_all_by_ids.no_off_market') do
|
170
206
|
@properties = @listings.find_all_by_ids(@find_ids_with_off_market, false)
|
171
207
|
end
|
172
208
|
end
|
173
|
-
|
209
|
+
|
174
210
|
it { @properties.size.should_not == @find_ids_with_off_market.size }
|
175
211
|
it { @properties.collect{|p| p.id}.should_not include(@off_market_id) }
|
176
212
|
end
|
177
|
-
|
213
|
+
|
178
214
|
context "should find all properties including the mls properties" do
|
179
215
|
before do
|
180
216
|
VCR.use_cassette("listings.search_with_mls") do
|
@@ -193,9 +229,9 @@ describe YouGotListed::Listings do
|
|
193
229
|
@properties = @listings.find_all_by_ids(@find_ids_with_mls)
|
194
230
|
end
|
195
231
|
end
|
196
|
-
|
232
|
+
|
197
233
|
it { @properties.size.should == @find_ids_with_mls.size }
|
198
|
-
|
234
|
+
|
199
235
|
it "should only return properties for requested ids" do
|
200
236
|
@properties.each do |p|
|
201
237
|
@find_ids_with_mls.should include(p.id)
|
@@ -203,7 +239,7 @@ describe YouGotListed::Listings do
|
|
203
239
|
end
|
204
240
|
end
|
205
241
|
end
|
206
|
-
|
242
|
+
|
207
243
|
def find_off_market_property(listings, page_id = 1)
|
208
244
|
VCR.use_cassette("listings.search_with_off_market.#{page_id}") do
|
209
245
|
response = listings.search(:include_off_market => "1", :page_index => page_id)
|
@@ -214,7 +250,7 @@ describe YouGotListed::Listings do
|
|
214
250
|
end
|
215
251
|
end
|
216
252
|
end
|
217
|
-
|
253
|
+
|
218
254
|
def find_mls_property(listings, page_id = 1)
|
219
255
|
VCR.use_cassette("listings.search_with_mls.#{page_id}") do
|
220
256
|
response = listings.search(:include_mls => "1", :page_index => page_id)
|
@@ -225,5 +261,5 @@ describe YouGotListed::Listings do
|
|
225
261
|
end
|
226
262
|
end
|
227
263
|
end
|
228
|
-
|
264
|
+
|
229
265
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe YouGotListed::Resource do
|
4
|
-
|
4
|
+
|
5
5
|
before do
|
6
6
|
@ygl = new_ygl
|
7
7
|
@resource = YouGotListed::Resource.new(@ygl)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
context "initialize" do
|
11
11
|
it "should instantiate with a client" do
|
12
12
|
@resource.client.should_not be_nil
|
13
13
|
@resource.client.should be_kind_of(YouGotListed::Client)
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
end
|