flexmls_api 0.3.6 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/Gemfile +6 -6
  2. data/Gemfile.lock +6 -6
  3. data/README.md +5 -3
  4. data/Rakefile +2 -1
  5. data/VERSION +1 -1
  6. data/lib/flexmls_api/authentication.rb +25 -54
  7. data/lib/flexmls_api/authentication/api_auth.rb +100 -0
  8. data/lib/flexmls_api/authentication/base_auth.rb +47 -0
  9. data/lib/flexmls_api/authentication/oauth2.rb +219 -0
  10. data/lib/flexmls_api/client.rb +7 -1
  11. data/lib/flexmls_api/configuration.rb +5 -2
  12. data/lib/flexmls_api/faraday.rb +6 -2
  13. data/lib/flexmls_api/models.rb +2 -0
  14. data/lib/flexmls_api/models/base.rb +5 -1
  15. data/lib/flexmls_api/models/contact.rb +1 -0
  16. data/lib/flexmls_api/models/custom_fields.rb +2 -2
  17. data/lib/flexmls_api/models/finders.rb +2 -2
  18. data/lib/flexmls_api/models/idx_link.rb +1 -1
  19. data/lib/flexmls_api/models/listing.rb +31 -5
  20. data/lib/flexmls_api/models/market_statistics.rb +1 -1
  21. data/lib/flexmls_api/models/note.rb +43 -0
  22. data/lib/flexmls_api/models/standard_fields.rb +43 -0
  23. data/lib/flexmls_api/models/subresource.rb +5 -2
  24. data/lib/flexmls_api/models/system_info.rb +7 -0
  25. data/lib/flexmls_api/models/tour_of_home.rb +24 -0
  26. data/lib/flexmls_api/request.rb +13 -28
  27. data/spec/fixtures/add_note.json +11 -0
  28. data/spec/fixtures/agent_shared_note.json +11 -0
  29. data/spec/fixtures/agent_shared_note_empty.json +7 -0
  30. data/spec/fixtures/authentication_failure.json +7 -0
  31. data/spec/fixtures/count.json +10 -0
  32. data/spec/fixtures/errors/expired.json +7 -0
  33. data/spec/fixtures/generic_delete.json +1 -0
  34. data/spec/fixtures/generic_failure.json +5 -0
  35. data/spec/fixtures/oauth2_access.json +3 -0
  36. data/spec/fixtures/oauth2_error.json +3 -0
  37. data/spec/fixtures/session.json +1 -1
  38. data/spec/fixtures/standardfields.json +188 -0
  39. data/spec/fixtures/standardfields_city.json +1031 -0
  40. data/spec/fixtures/standardfields_nearby.json +53 -0
  41. data/spec/fixtures/standardfields_stateorprovince.json +36 -0
  42. data/spec/fixtures/tour_of_homes.json +23 -0
  43. data/spec/spec_helper.rb +22 -5
  44. data/spec/unit/flexmls_api/authentication/api_auth_spec.rb +159 -0
  45. data/spec/unit/flexmls_api/authentication/oauth2_spec.rb +183 -0
  46. data/spec/unit/flexmls_api/authentication_spec.rb +10 -2
  47. data/spec/unit/flexmls_api/configuration_spec.rb +2 -2
  48. data/spec/unit/flexmls_api/faraday_spec.rb +3 -7
  49. data/spec/unit/flexmls_api/models/base_spec.rb +1 -1
  50. data/spec/unit/flexmls_api/models/contact_spec.rb +8 -4
  51. data/spec/unit/flexmls_api/models/document_spec.rb +2 -5
  52. data/spec/unit/flexmls_api/models/listing_spec.rb +46 -9
  53. data/spec/unit/flexmls_api/models/note_spec.rb +90 -0
  54. data/spec/unit/flexmls_api/models/photo_spec.rb +2 -2
  55. data/spec/unit/flexmls_api/models/system_info_spec.rb +37 -3
  56. data/spec/unit/flexmls_api/models/tour_of_home_spec.rb +43 -0
  57. data/spec/unit/flexmls_api/models/video_spec.rb +2 -4
  58. data/spec/unit/flexmls_api/models/virtual_tour_spec.rb +2 -2
  59. data/spec/unit/flexmls_api/paginate_spec.rb +11 -8
  60. data/spec/unit/flexmls_api/request_spec.rb +31 -16
  61. data/spec/unit/flexmls_api/standard_fields_spec.rb +86 -0
  62. data/spec/unit/flexmls_api_spec.rb +6 -27
  63. metadata +119 -76
@@ -1,6 +1,14 @@
1
1
  require './spec/spec_helper'
2
2
 
3
3
  describe FlexmlsApi::Authentication do
4
+ before(:all) do
5
+ FlexmlsApi.reset
6
+ end
7
+
8
+ after(:all) do
9
+ reset_config
10
+ end
11
+
4
12
  it "should give me a session object" do
5
13
  stub_auth_request
6
14
  stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/session/c401736bf3d3f754f07c04e460e09573").
@@ -12,7 +20,7 @@ describe FlexmlsApi::Authentication do
12
20
  client = FlexmlsApi.client
13
21
  stub_auth_request
14
22
  session = client.get "/session/c401736bf3d3f754f07c04e460e09573"
15
- session[0]["AuthToken"].should eq "c401736bf3d3f754f07c04e460e09573"
23
+ session[0]["AuthToken"].should eq("c401736bf3d3f754f07c04e460e09573")
16
24
  end
17
25
  it "should delete a session" do
18
26
  stub_auth_request
@@ -24,7 +32,7 @@ describe FlexmlsApi::Authentication do
24
32
  to_return(:body => fixture("success.json"))
25
33
  client = FlexmlsApi.client
26
34
  client.logout
27
- client.session.should eq nil
35
+ client.session.should eq(nil)
28
36
  end
29
37
 
30
38
  end
@@ -1,8 +1,8 @@
1
1
  require './spec/spec_helper'
2
2
 
3
3
  describe FlexmlsApi::Client, "Client config" do
4
- after(:each) do
5
- FlexmlsApi.reset
4
+ after(:all) do
5
+ reset_config
6
6
  end
7
7
 
8
8
  describe "default settings" do
@@ -27,11 +27,7 @@ describe FlexmlsApi do
27
27
  }]}
28
28
  }']
29
29
  }
30
- stub.get('/expired') { [401, {}, '{"D": {
31
- "Success": false,
32
- "Message": "Session token has expired",
33
- "Code": 1020
34
- }}']
30
+ stub.get('/expired') { [401, {}, fixture('errors/expired.json')]
35
31
  }
36
32
  stub.get('/methodnotallowed') { [405, {}, '{"D": {
37
33
  "Success": false,
@@ -65,8 +61,8 @@ describe FlexmlsApi do
65
61
 
66
62
  it "should raised exception on error" do
67
63
  expect { @connection.get('/methodnotallowed')}.to raise_error(FlexmlsApi::NotAllowed){ |e| e.message.should == "Method Not Allowed" }
68
- expect { @connection.get('/epicfail')}.to raise_error(FlexmlsApi::ClientError){ |e| e.status.should be 500 }
69
- expect { @connection.get('/unknownerror')}.to raise_error(FlexmlsApi::ClientError){ |e| e.status.should be 499 }
64
+ expect { @connection.get('/epicfail')}.to raise_error(FlexmlsApi::ClientError){ |e| e.status.should be(500) }
65
+ expect { @connection.get('/unknownerror')}.to raise_error(FlexmlsApi::ClientError){ |e| e.status.should be(499) }
70
66
  end
71
67
 
72
68
  it "should raised exception on invalid responses" do
@@ -33,7 +33,7 @@ describe Base, "Base model" do
33
33
  describe "finders" do
34
34
  before(:all) do
35
35
  stubs = Faraday::Adapter::Test::Stubs.new do |stub|
36
- stub.get('/v1/test/example?ApiSig=0637dccf93be3774c9c7c554bb0b1d9a&AuthToken=1234') { [200, {}, '{"D": {
36
+ stub.get('/v1/test/example?ApiSig=9fd7299fc210d0c3dcc24782d9cb7894&ApiUser=foobar&AuthToken=1234') { [200, {}, '{"D": {
37
37
  "Success": true,
38
38
  "Results": [{
39
39
  "Id": 1,
@@ -11,9 +11,9 @@ end
11
11
  describe Contact do
12
12
  before(:all) do
13
13
  stubs = Faraday::Adapter::Test::Stubs.new do |stub|
14
- stub.get('/v1/contacts?ApiSig=735774295be070a27f7cf859fde90740&AuthToken=1234') { [200, {}, fixture('contacts.json')]
14
+ stub.get('/v1/contacts?ApiSig=33e3b6d6436c85c3f9944d21f6f0cf9a&ApiUser=foobar&AuthToken=1234') { [200, {}, fixture('contacts.json')]
15
15
  }
16
- stub.post('/v1/contacts?ApiSig=7f0a7b0f648f87aabd4d4393913a10ba&AuthToken=1234', '{"D":{"Contacts":[{"DisplayName":"Contact Four","PrimaryEmail":"contact4@fbsdata.com"}]}}') { [201, {}, '{"D": {
16
+ stub.post('/v1/contacts?ApiSig=1c78fb9f798fbb739a0b8152528cd453&ApiUser=foobar&AuthToken=1234', '{"D":{"Contacts":[{"DisplayName":"Contact Four","PrimaryEmail":"contact4@fbsdata.com"}]}}') { [201, {}, '{"D": {
17
17
  "Success": true,
18
18
  "Results": [
19
19
  {
@@ -21,7 +21,7 @@ describe Contact do
21
21
  }]}
22
22
  }']
23
23
  }
24
- stub.post('/v1/contacts?ApiSig=76f6ee7032f7038d737f9b73457f06e2&AuthToken=1234', '{"D":{"Contacts":[{}]}}') { [400, {}, '{"D": {
24
+ stub.post('/v1/contacts?ApiSig=ea132fe27a8deb7d6c096b102972ce3e&ApiUser=foobar&AuthToken=1234', '{"D":{"Contacts":[{}]}}') { [400, {}, '{"D": {
25
25
  "Success": false}
26
26
  }']
27
27
  }
@@ -29,6 +29,10 @@ describe Contact do
29
29
  Contact.connection = mock_client(stubs)
30
30
  end
31
31
 
32
+ it "should include the finders module" do
33
+ Contact.should respond_to(:find)
34
+ end
35
+
32
36
  it "should get all my contacts" do
33
37
  contacts = Contact.get
34
38
  contacts.should be_an(Array)
@@ -53,7 +57,7 @@ describe Contact do
53
57
  context "on an epic fail" do
54
58
  before(:all) do
55
59
  stubs = Faraday::Adapter::Test::Stubs.new do |stub|
56
- stub.post('/v1/contacts?ApiSig=76f6ee7032f7038d737f9b73457f06e2&AuthToken=1234', '{"D":{"Contacts":[{}]}}') { [500, {}, '{"D": {
60
+ stub.post('/v1/contacts?ApiSig=ea132fe27a8deb7d6c096b102972ce3e&ApiUser=foobar&AuthToken=1234', '{"D":{"Contacts":[{}]}}') { [500, {}, '{"D": {
57
61
  "Success": false}
58
62
  }']
59
63
  }
@@ -14,7 +14,6 @@ describe Document do
14
14
  Document.should respond_to(:find_by_listing_key)
15
15
  end
16
16
 
17
-
18
17
  it "should get documents for a listing" do
19
18
  stub_auth_request
20
19
  stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/listings/1234/documents").
@@ -25,13 +24,11 @@ describe Document do
25
24
  }).
26
25
  to_return(:body => fixture('listing_document_index.json'))
27
26
 
28
- v = Document.find_by_listing_key('1234', "foobar")
29
- v.should be_an Array
27
+ v = Document.find_by_listing_key('1234')
28
+ v.should be_an(Array)
30
29
  v.length.should == 2
31
30
  end
32
31
 
33
-
34
-
35
32
  after(:each) do
36
33
  @document = nil
37
34
  end
@@ -2,6 +2,7 @@ require './spec/spec_helper'
2
2
 
3
3
  describe Listing do
4
4
  before(:each) do
5
+
5
6
  @listing = Listing.new({
6
7
  "ResourceUri"=>"/v1/listings/20080619000032866372000000",
7
8
  "StandardFields"=>{
@@ -51,10 +52,10 @@ describe Listing do
51
52
 
52
53
  describe "attributes" do
53
54
  it "should allow access to fields" do
54
- @listing.StandardFields.should be_a Hash
55
- @listing.StandardFields['ListingId'].should be_a String
56
- @listing.StandardFields['ListPrice'].should match @listing.ListPrice
57
- @listing.photos.should be_a Array
55
+ @listing.StandardFields.should be_a(Hash)
56
+ @listing.StandardFields['ListingId'].should be_a(String)
57
+ @listing.StandardFields['ListPrice'].should match(@listing.ListPrice)
58
+ @listing.photos.should be_a(Array)
58
59
  end
59
60
 
60
61
  it "should not respond to removed attributes" do
@@ -86,6 +87,20 @@ describe Listing do
86
87
  it "should respond to find_by_cart_id" do
87
88
  Listing.should respond_to(:find_by_cart_id)
88
89
  end
90
+
91
+ it "should return the count" do
92
+ stub_auth_request
93
+ stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/listings").
94
+ with(:query => {
95
+ :_pagination => "count",
96
+ :ApiSig => "9028191e427eee6774527e7d19f489cb",
97
+ :AuthToken => "c401736bf3d3f754f07c04e460e09573",
98
+ :ApiUser => "foobar"
99
+ }).
100
+ to_return(:body => fixture('count.json'))
101
+ count = Listing.count()
102
+ count.should == 2001
103
+ end
89
104
  end
90
105
 
91
106
  describe "subresources" do
@@ -104,7 +119,7 @@ describe Listing do
104
119
  }).
105
120
  to_return(:body => fixture('listing_with_photos.json'))
106
121
 
107
- l = Listing.find('1234', :ApiUser => "foobar", :_expand => "Photos")
122
+ l = Listing.find('1234', :_expand => "Photos")
108
123
  l.photos.length.should == 5
109
124
  l.documents.length.should == 0
110
125
  l.videos.length.should == 0
@@ -121,7 +136,7 @@ describe Listing do
121
136
  }).
122
137
  to_return(:body => fixture('listing_with_documents.json'))
123
138
 
124
- l = Listing.find('1234', :ApiUser => "foobar", :_expand => "Documents")
139
+ l = Listing.find('1234', :_expand => "Documents")
125
140
  l.photos.length.should == 0
126
141
  l.documents.length.should == 2
127
142
  l.videos.length.should == 0
@@ -138,7 +153,7 @@ describe Listing do
138
153
  }).
139
154
  to_return(:body => fixture('listing_with_vtour.json'))
140
155
 
141
- l = Listing.find('1234', :ApiUser => "foobar", :_expand => "VirtualTours")
156
+ l = Listing.find('1234', :_expand => "VirtualTours")
142
157
  l.virtual_tours.length.should == 1
143
158
  l.photos.length.should == 0
144
159
  l.documents.length.should == 0
@@ -156,14 +171,36 @@ describe Listing do
156
171
  }).
157
172
  to_return(:body => fixture('listing_with_videos.json'))
158
173
 
159
- l = Listing.find('1234', :ApiUser => "foobar", :_expand => "Videos")
174
+ l = Listing.find('1234', :_expand => "Videos")
160
175
  l.videos.length.should == 2
161
176
  l.virtual_tours.length.should == 0
162
177
  l.photos.length.should == 0
163
178
  l.documents.length.should == 0
164
179
  end
165
180
 
166
-
181
+ it "should return tour of homes" do
182
+ stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/listings/20060725224713296297000000").
183
+ with(:query => {
184
+ :ApiSig => "b3ae2bec3500ba4620bf8224dee28d20",
185
+ :AuthToken => "c401736bf3d3f754f07c04e460e09573",
186
+ :ApiUser => "foobar"
187
+ }).
188
+ to_return(:body => fixture('listing_no_subresources.json'))
189
+ stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/listings/20060725224713296297000000/tourofhomes").
190
+ with( :query => {
191
+ :ApiSig => "153446de6d1db765d541587d34ed0fcf",
192
+ :AuthToken => "c401736bf3d3f754f07c04e460e09573",
193
+ :ApiUser => "foobar"
194
+ }).
195
+ to_return(:body => fixture('tour_of_homes.json'))
196
+
197
+ l = Listing.find('20060725224713296297000000')
198
+ l.tour_of_homes().length.should == 2
199
+ l.videos.length.should == 0
200
+ l.photos.length.should == 0
201
+ l.documents.length.should == 0
202
+ end
203
+
167
204
  end
168
205
 
169
206
  after(:each) do
@@ -0,0 +1,90 @@
1
+ require './spec/spec_helper'
2
+
3
+ describe Note do
4
+
5
+
6
+ it "responds to instance and class methods" do
7
+ Note.should respond_to(:get)
8
+ Note.new.should respond_to(:save)
9
+ Note.new.should respond_to(:save!)
10
+ Note.new.should respond_to(:delete)
11
+ end
12
+
13
+ context "when shared with a contact" do
14
+ before :each do
15
+ @note = Listing.new(:ListingKey => "1234").shared_notes("5678")
16
+ stub_auth_request
17
+ end
18
+
19
+ it "should have the correct path" do
20
+ @note.path.should == "/listings/1234/shared/notes/contacts/5678"
21
+ end
22
+
23
+ it "should get my notes" do
24
+ stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}#{@note.path}").
25
+ with(:query => {
26
+ :ApiSig => '8b00f10700a479b86acd03776cfea34f',
27
+ :AuthToken => 'c401736bf3d3f754f07c04e460e09573',
28
+ :ApiUser => 'foobar'
29
+ }).
30
+ to_return(:body => fixture('agent_shared_note.json'))
31
+ ret = @note.get
32
+ ret.Note.should == "lorem ipsum dolor sit amet"
33
+ end
34
+
35
+ it "should return a nil when no shared notes exist" do
36
+ stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}#{@note.path}").
37
+ with(:query => {
38
+ :ApiSig => '8b00f10700a479b86acd03776cfea34f',
39
+ :AuthToken => 'c401736bf3d3f754f07c04e460e09573',
40
+ :ApiUser => 'foobar'
41
+ }).
42
+ to_return(:body => fixture('agent_shared_note_empty.json'))
43
+ @note.get.should be_nil
44
+ end
45
+
46
+ it "should allow you to delete an existing note" do
47
+ stub_request(:delete, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}#{@note.path}").
48
+ with(:query => {
49
+ :ApiSig => '8b00f10700a479b86acd03776cfea34f',
50
+ :ApiUser => 'foobar',
51
+ :AuthToken => 'c401736bf3d3f754f07c04e460e09573'
52
+ }).
53
+ to_return(:body => fixture('generic_delete.json'))
54
+ @note.new.delete # test that no exceptions are raised
55
+ end
56
+
57
+ it "should raise an exception when adding a note fails" do
58
+ n = @note.new(:Note => "lorem ipsum dolor")
59
+ stub_request(:put, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}#{@note.path}").
60
+ with(:query => {
61
+ :ApiSig => '1e8bcca11ab7307ca99463f199a58c7d',
62
+ :ApiUser => 'foobar',
63
+ :AuthToken => 'c401736bf3d3f754f07c04e460e09573'
64
+ }).
65
+ to_return(:status => 500, :body => fixture('generic_failure.json'))
66
+
67
+ expect { n.save! }.to raise_error(FlexmlsApi::ClientError) { |e| e.status.should == 500 }
68
+ expect { n.save }.to raise_error(FlexmlsApi::ClientError) { |e| e.status.should == 500 }
69
+ end
70
+
71
+ it "should allow adding of a note" do
72
+ n = @note.new(:Note => "lorem ipsum dolor")
73
+
74
+ stub_request(:put, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}#{@note.path}").
75
+ with(:query => {
76
+ :ApiSig => '1e8bcca11ab7307ca99463f199a58c7d',
77
+ :ApiUser => 'foobar',
78
+ :AuthToken => 'c401736bf3d3f754f07c04e460e09573'
79
+ }).
80
+ to_return(:body => fixture('add_note.json'))
81
+
82
+ n.save
83
+ n.ResourceUri.should == '/v1/listings/20100909200152674436000000/shared/notes/contacts/20110407212043616271000000/'
84
+ end
85
+
86
+ after :each do
87
+ @note = nil
88
+ end
89
+ end
90
+ end
@@ -44,8 +44,8 @@ describe Photo do
44
44
  end
45
45
 
46
46
  it "should get an array of photos" do
47
- p = Photo.find_by_listing_key('1234', 'foobar')
48
- p.should be_an Array
47
+ p = Photo.find_by_listing_key('1234')
48
+ p.should be_an(Array)
49
49
  end
50
50
 
51
51
  end
@@ -19,15 +19,49 @@ describe SystemInfo do
19
19
  SystemInfo.should respond_to(:get)
20
20
  end
21
21
 
22
+ it "should have a primary_logo instance method" do
23
+ @sysinfo.should respond_to(:primary_logo)
24
+ end
25
+
22
26
  it "should respond to attributes" do
23
27
  ['Name','OfficeId','Id','MlsId','Office','Mls'].each do |k|
24
- (@sysinfo.send k.to_sym).should be_a String
28
+ (@sysinfo.send k.to_sym).should be_a(String)
25
29
  end
26
- @sysinfo.Configuration.should be_a Array
30
+ @sysinfo.Configuration.should be_a(Array)
27
31
  end
28
32
 
29
33
  it "should have an array of config items" do
30
- @sysinfo.Configuration.should be_a Array
34
+ @sysinfo.Configuration.should be_a(Array)
35
+ end
36
+
37
+ describe "#primary_logo" do
38
+ before(:each) do
39
+ @sysinfo_with_logos = SystemInfo.new({
40
+ "Name"=>"Brandon Reg1",
41
+ "OfficeId"=>"20080904154102121828000000",
42
+ "Configuration"=>[{
43
+ "MlsLogos"=>[
44
+ {"Uri"=>"http://images.dev.fbsdata.com/eup/20110406184939446866000000.jpg", "Name:"=>"logo and stuff"},
45
+ {"Uri"=>"http://images.dev.fbsdata.com/eup/20110406191929838053000000.jpg", "Name:"=>"tried it"}
46
+ ],
47
+ "IdxDisclaimer"=>"",
48
+ "IdxLogoSmall"=>"",
49
+ "IdxLogo"=>"http://images.dev.fbsdata.com/eup/20110406184939446866000000.jpg"
50
+ }],
51
+ "Id"=>"20080904155327755059000000",
52
+ "MlsId"=>"20041217205818829687000000",
53
+ "Office"=>"Brandon Office1",
54
+ "Mls"=>"Eastern Upper Peninsula"
55
+ })
56
+ end
57
+
58
+ it "should return nil when no logo is present" do
59
+ @sysinfo.primary_logo.should == nil
60
+ end
61
+
62
+ it "should return the first logo when several are present" do
63
+ @sysinfo_with_logos.primary_logo.should be_a(Hash)
64
+ end
31
65
  end
32
66
 
33
67
  after(:each) do
@@ -0,0 +1,43 @@
1
+ require './spec/spec_helper'
2
+
3
+ require 'time'
4
+
5
+ describe TourOfHome do
6
+ subject do
7
+ TourOfHome.new(
8
+ 'ResourceUri'=>"/listings/20060725224713296297000000/tourofhomes/20101127153422574618000000",
9
+ 'Id'=>"20101127153422574618000000",
10
+ 'Date'=>"10/01/2010",
11
+ 'StartTime'=>"09:00:00-07:00",
12
+ 'EndTime'=>"23:00:00-07:00",
13
+ 'Comments'=>"Wonderful home; must see!",
14
+ 'AdditionalInfo'=> [{"Hosted By"=>"Joe Smith"}, {"Host Phone"=>"123-456-7890"}, {"Tour Area"=>"North-Central"}]
15
+ )
16
+ end
17
+
18
+ it "should respond to a few methods" do
19
+ subject.class.should respond_to(:find_by_listing_key)
20
+ end
21
+ it "should return tour date and times" do
22
+ start_time = DateTime.new(2010,10,1,9,0,0, "-0700")
23
+ end_time = DateTime.new(2010,10,1,23,0,0, "-0700")
24
+ subject.Date.should eq(Date.new(2010,10,1))
25
+ subject.StartTime.should eq(Time.parse(start_time.to_s))
26
+ subject.EndTime.should eq(Time.parse(end_time.to_s))
27
+ end
28
+
29
+ it "should get home tours for a listing" do
30
+ stub_auth_request
31
+ stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/listings/20060725224713296297000000/tourofhomes").
32
+ with( :query => {
33
+ :ApiSig => "153446de6d1db765d541587d34ed0fcf",
34
+ :AuthToken => "c401736bf3d3f754f07c04e460e09573",
35
+ :ApiUser => "foobar"
36
+ }).
37
+ to_return(:body => fixture('tour_of_homes.json'))
38
+ v = subject.class.find_by_listing_key('20060725224713296297000000')
39
+ v.should be_an(Array)
40
+ v.length.should == 2
41
+ end
42
+
43
+ end