Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix specs #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/google-contacts/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def initialize(data=nil)
if data["link"]
data["link"].each do |link|
if link["@rel"] == "next"
@next_uri = URI(link["@href"])
@next_uri = parse_link(link["@href"])
elsif link["@rel"] == "previous"
@previous_uri = URI(link["@href"])
@previous_uri = parse_link(link["@href"])
end
end
end
Expand All @@ -56,6 +56,10 @@ def [](index); @entries[index] end
def empty?; @entries.empty? end
def length; @entries.length end

def parse_link(href)
URI(href.gsub(/(&)|(&)/, '&'))
end

alias size length
end
end
16 changes: 8 additions & 8 deletions spec/lib/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
contacts = client.all(:params => {"updated-min" => "1234"})

contacts.id.should == "[email protected]"
contacts.updated.to_s.should == "2012-04-05T21:46:31.537Z"
contacts.updated.to_s.should == "2012-04-05T21:46:31+00:00"
contacts.title.should == "Johnny's Contacts"
contacts.author.should == {"name" => "Johnny", "email" => "[email protected]"}
contacts.next_uri.should be_nil
Expand All @@ -68,7 +68,7 @@
contact = contacts.first
contact.id.should == "http://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/base/fd8fb1a55f2916e"
contact.title.should == "Steve Stephson"
contact.updated.to_s.should == "2012-02-06T01:14:56.240Z"
contact.updated.to_s.should == "2012-02-06T01:14:56+00:00"
contact.edit_uri.should == URI("https://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/full/fd8fb1a55f2916e")
contact.etag.should == '"OWUxNWM4MTEzZjEyZTVjZTQ1Mjgy."'
contact.data.should == {"gd:name"=>[{"gd:fullName"=>"Steve Stephson", "gd:givenName"=>"Steve", "gd:familyName"=>"Stephson"}], "gd:email"=>[{"@rel"=>"http://schemas.google.com/g/2005#other", "@address"=>"[email protected]", "@primary"=>"true"}, {"@rel"=>"http://schemas.google.com/g/2005#other", "@address"=>"[email protected]"}], "gd:phoneNumber"=>[{"text"=>"3005004000", "@rel"=>"http://schemas.google.com/g/2005#mobile"}, {"text"=>"+130020003000", "@rel"=>"http://schemas.google.com/g/2005#work"}], "gContact:groupMembershipInfo"=>[{"@deleted"=>"false", "@href"=>"http://www.google.com/m8/feeds/groups/john.doe%40gmail.com/base/6"}]}
Expand All @@ -78,15 +78,15 @@
contact = contacts[1]
contact.id.should == "http://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/base/894bc75ebb5187d"
contact.title.should == "Jill Doe"
contact.updated.to_s.should == "2011-07-01T18:08:32.555Z"
contact.updated.to_s.should == "2011-07-01T18:08:32+00:00"
contact.edit_uri.should == URI("https://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/full/894bc75ebb5187d")
contact.etag.should == '"ZGRhYjVhMTNkMmFhNzJjMzEyY2Ux."'
contact.data.should == {"gd:name" => [{"gd:fullName" => "Jill Doe", "gd:givenName" => "Jill", "gd:familyName" => "Doe"}]}

contact = contacts[2]
contact.id.should == "http://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/base/cd046ed518f0fb0"
contact.title.should == 'Dave "Terry" Pratchett'
contact.updated.to_s.should == "2011-06-29T23:11:57.345Z"
contact.updated.to_s.should == "2011-06-29T23:11:57+00:00"
contact.edit_uri.should == URI("https://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/full/cd046ed518f0fb0")
contact.etag.should == '"ZWVhMDQ0MWI0MWM0YTJkM2MzY2Zh."'
contact.data.should == {"gd:name"=>[{"gd:fullName"=>"Dave \"Terry\" Pratchett", "gd:givenName"=>"Dave", "gd:additionalName"=>"\"Terry\"", "gd:familyName"=>"Pratchett"}], "gd:organization"=>[{"gd:orgName"=>"Foo Bar Inc", "@rel"=>"http://schemas.google.com/g/2005#work"}], "gd:email"=>[{"@rel"=>"http://schemas.google.com/g/2005#home", "@address"=>"[email protected]", "@primary"=>"true"}], "gd:phoneNumber"=>[{"text"=>"7003002000", "@rel"=>"http://schemas.google.com/g/2005#mobile"}], "gContact:groupMembershipInfo"=>[{"@deleted"=>"false", "@href"=>"http://www.google.com/m8/feeds/groups/john.doe%40gmail.com/base/6"}]}
Expand All @@ -96,7 +96,7 @@
contact = contacts[3]
contact.id.should == "http://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/base/a1941d3d13cdc66"
contact.title.should == "Jane Doe"
contact.updated.to_s.should == "2012-04-04T02:08:37.804Z"
contact.updated.to_s.should == "2012-04-04T02:08:37+00:00"
contact.edit_uri.should == URI("https://www.google.com/m8/feeds/contacts/john.doe%40gmail.com/full/a1941d3d13cdc66")
contact.etag.should == '"Yzg3MTNiODJlMTRlZjZjN2EyOGRm."'
contact.data.should == {"gd:name"=>[{"gd:fullName"=>"Jane Doe", "gd:givenName"=>"Jane", "gd:familyName"=>"Doe"}], "gd:email"=>[{"@rel"=>"http://schemas.google.com/g/2005#home", "@address"=>"[email protected]", "@primary"=>"true"}], "gd:phoneNumber"=>[{"text"=>"16004003000", "@rel"=>"http://schemas.google.com/g/2005#mobile"}], "gd:structuredPostalAddress"=>[{"gd:formattedAddress"=>"5 Market St\n San Francisco\n CA", "gd:street"=>"5 Market St", "gd:city"=>"San Francisco", "gd:region"=>"CA", "@rel"=>"http://schemas.google.com/g/2005#home"}], "gContact:groupMembershipInfo"=>[{"@deleted"=>"false", "@href"=>"http://www.google.com/m8/feeds/groups/john.doe%40gmail.com/base/6"}]}
Expand Down Expand Up @@ -286,7 +286,7 @@
groups = client.all(:params => {"updated-min" => "1234"})

groups.id.should == "[email protected]"
groups.updated.to_s.should == "2012-04-05T22:32:03.192Z"
groups.updated.to_s.should == "2012-04-05T22:32:03+00:00"
groups.title.should == "Johnny's Contact Groups"
groups.author.should == {"name" => "Johnny", "email" => "[email protected]"}
groups.next_uri.should be_nil
Expand All @@ -298,15 +298,15 @@
group = groups.first
group.id.should == "http://www.google.com/m8/feeds/groups/john.doe%40gmail.com/base/6"
group.title.should == "System Group: My Contacts"
group.updated.to_s.should == "1970-01-01T00:00:00.000Z"
group.updated.to_s.should == "1970-01-01T00:00:00+00:00"
group.edit_uri.should be_nil
group.etag.should == '"YWJmYzA."'
group.data.should have(1).items

group = groups[1]
group.id.should == "http://www.google.com/m8/feeds/groups/john.doe%40gmail.com/base/ada43d293fdb9b1"
group.title.should == "Misc"
group.updated.to_s.should == "2009-08-17T20:33:20.978Z"
group.updated.to_s.should == "2009-08-17T20:33:20+00:00"
group.edit_uri.should == URI("https://www.google.com/m8/feeds/groups/john.doe%40gmail.com/full/ada43d293fdb9b1")
group.etag.should == '"QXc8cDVSLyt7I2A9WxNTFUkLRQQ."'
group.data.should have(0).items
Expand Down