forked from josephholsten/rets4r
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5781ef9
commit 94d4ed4
Showing
3 changed files
with
82 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'uri' | ||
|
||
module RETS4R #:nodoc: | ||
class Client #:nodoc: | ||
class Links < Hash | ||
attr_accessor :logger | ||
def self.from_login_url(login_url) | ||
links = self.new | ||
links['Login'] = URI.parse(login_url) | ||
links | ||
end | ||
def login | ||
self['Login'] | ||
end | ||
def logout | ||
self['Logout'] | ||
end | ||
def metadata | ||
self['GetMetadata'] | ||
end | ||
def objects | ||
self['GetObject'] | ||
end | ||
def search | ||
self['Search'] | ||
end | ||
def action | ||
self['Action'] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")) | ||
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "test")) | ||
require 'test_helper' | ||
require 'rets4r/client/links' | ||
|
||
class TestClientLinks < Test::Unit::TestCase | ||
def setup | ||
@links = RETS4R::Client::Links.from_login_url('http://example.com/login') | ||
@links['Logout'] = URI.parse('http://example.com/logout') | ||
@links['GetMetadata'] = URI.parse('http://example.com/metadata') | ||
@links['GetObject'] = URI.parse('http://example.com/objects') | ||
@links['Search'] = URI.parse('http://example.com/search') | ||
@links['Action'] = URI.parse('http://example.com/action') | ||
end | ||
def test_should_build_from_login_url | ||
assert_equal normalize_url('http://example.com/login'), @links['Login'].to_s | ||
end | ||
def test_should_access_login | ||
assert_equal normalize_url('http://example.com/login'), @links.login.to_s | ||
end | ||
def test_should_access_logout | ||
assert_equal normalize_url('http://example.com/logout'), @links.logout.to_s | ||
end | ||
def test_should_access_metadata | ||
assert_equal normalize_url('http://example.com/metadata'), @links.metadata.to_s | ||
end | ||
def test_should_access_object | ||
assert_equal normalize_url('http://example.com/objects'), @links.objects.to_s | ||
end | ||
def test_should_access_search | ||
assert_equal normalize_url('http://example.com/search'), @links.search.to_s | ||
end | ||
def test_should_access_action | ||
assert_equal normalize_url('http://example.com/action'), @links.action.to_s | ||
end | ||
def normalize_url(url) | ||
URI.parse(url).to_s | ||
end | ||
end |