From a1881d1e55bea6655cff4aee5c59bc28535e80d3 Mon Sep 17 00:00:00 2001 From: Brad Cantin Date: Mon, 28 Jun 2010 08:11:22 -0400 Subject: [PATCH] LinkedIn::Connections tests pass --- lib/linked_in/connections.rb | 22 +++++++++++----------- lib/linked_in/profile.rb | 1 - test/client_test.rb | 13 ++++++------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/linked_in/connections.rb b/lib/linked_in/connections.rb index 64523054..0448075a 100644 --- a/lib/linked_in/connections.rb +++ b/lib/linked_in/connections.rb @@ -1,19 +1,15 @@ module LinkedIn class Connections - # include ROXML - # xml_convention {|val| val.gsub("_","-") } - # xml_reader :profiles, :as => [Profile], :from => 'person' - - # def self.from_xml(doc) - # new(Nokogiri::XML(doc)) - # end - + + def self.from_xml(doc) + new(Nokogiri::XML(doc)) + end + def initialize(doc) @doc = doc end - + def connections - # puts @doc.children @arry ||= begin connections = @doc.xpath('//connections') @arry = [] @@ -24,5 +20,9 @@ def connections end end + def profiles + connections + end + end -end \ No newline at end of file +end diff --git a/lib/linked_in/profile.rb b/lib/linked_in/profile.rb index 9883a68f..3787b5e9 100644 --- a/lib/linked_in/profile.rb +++ b/lib/linked_in/profile.rb @@ -3,7 +3,6 @@ class Profile # xml_reader :location, :as => Location # xml_reader :relation_to_viewer, :as => {:key => :name, :value => :content} - # xml_reader :connections, :as => [Profile], :from => "connections/person" # xml_reader :three_current_positions, :as => [Position] # xml_reader :member_url_resources, :as => [UrlResource], :from => 'member-url-resources/member-url' diff --git a/test/client_test.rb b/test/client_test.rb index f567f6f2..2b93fc9e 100644 --- a/test/client_test.rb +++ b/test/client_test.rb @@ -34,7 +34,6 @@ class ClientTest < Test::Unit::TestCase p.connections.size.should == 146 p.connections.first.first_name.should == "Ali" - # puts p.connections.first.inspect end should "retrieve a profile for a member by id" do @@ -56,12 +55,12 @@ class ClientTest < Test::Unit::TestCase p.last_name.should == 'Netherland' end - # should "retrieve connections for the authenticated user" do - # stub_get("/v1/people/~/connections", "connections.xml") - # cons = @linkedin.connections - # cons.size.should == 146 - # cons.last.last_name.should == 'Yuchnewicz' - # end + should "retrieve connections for the authenticated user" do + stub_get("/v1/people/~/connections", "connections.xml") + cons = @linkedin.connections + cons.size.should == 146 + cons.last.last_name.should == 'Yuchnewicz' + end # should "perform a search by keyword" do # stub_get("/v1/people?keywords=github", "search.xml")