Class: GmailContacts::TestStub

Inherits:
Object
  • Object
show all
Defined in:
lib/gmail_contacts/test_stub.rb

Overview

Handy data files and GData modifications that allow GmailContacts to be more easily tested

To setup:

require 'gmail_contacts'
require 'gmail_contacts/test_stub'

class TestMyClass < Test::Unit::TestCase
def test_something
  GmailContacts.stub

  # ... your code using gc

end
end

If you set the authsub token to 'recycled_authsub_token', the test stub will raise a GData::Client::AuthorizationError when you call #get_token.

If you set the authsub token to 'wrong_user_authsub_token', the test stub will raise a GData::Client::AuthorizationError when you call #fetch.

If you set the authsub token to 'authsub_token', #get_token will change it to 'authsub_token-upgraded' to indicate it was upgraded to a session token.

If you fetch a photo with 404 in the url, #fetch_photo will raise a Net::HTTPServerException with a 404 response inside.

#revoke_token will set the token to 'authsub_token-revoked' to indicate it was revoked.

Constant Summary collapse

CONTACTS =

First page of contacts

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:openSearch=\"http://a9.com/-/spec/opensearch/1.1/\" xmlns:gContact=\"http://schemas.google.com/contact/2008\" xmlns:batch=\"http://schemas.google.com/gdata/batch\" xmlns:gd=\"http://schemas.google.com/g/2005\" gd:etag=\"W/&quot;CEMBRHY6fSp7ImA9WxVUGEk.&quot;\">\n<id>[email protected]</id>\n<updated>2009-03-23T21:07:35.815Z</updated>\n<category scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/contact/2008#contact\"/>\n<title>drbrain's Contacts</title>\n<link rel=\"alternate\" type=\"text/html\" href=\"http://www.google.com/\"/>\n<link rel=\"http://schemas.google.com/g/2005#feed\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full\"/>\n<link rel=\"http://schemas.google.com/g/2005#post\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full\"/>\n<link rel=\"http://schemas.google.com/g/2005#batch\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full/batch\"/>\n<link rel=\"self\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full?max-results=2\"/>\n<link rel=\"next\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full?start-index=3&amp;max-results=2\"/>\n<author>\n  <name>drbrain</name>\n  <email>[email protected]</email>\n</author>\n<generator version=\"1.0\" uri=\"http://www.google.com/m8/feeds\">Contacts</generator>\n<openSearch:totalResults>4</openSearch:totalResults>\n<openSearch:startIndex>1</openSearch:startIndex>\n<openSearch:itemsPerPage>2</openSearch:itemsPerPage>\n<entry gd:etag=\"&quot;SHg-cTVSLip7ImA9WB5WGUUIQgc.&quot;\">\n  <id>http://www.google.com/m8/feeds/contacts/eric%40example.com/base/0</id>\n  <updated>2007-08-01T15:35:39.659Z</updated>\n  <app:edited xmlns:app=\"http://www.w3.org/2007/app\">2007-08-01T15:35:39.659Z</app:edited>\n  <category scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/contact/2008#contact\"/>\n  <title>Sean</title>\n  <link rel=\"http://schemas.google.com/contacts/2008/rel#photo\" type=\"image/*\" href=\"http://www.google.com/m8/feeds/photos/media/eric%40example.com/0\"/>\n  <link rel=\"self\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full/0\"/>\n  <link rel=\"edit\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full/0\"/>\n  <gd:email rel=\"http://schemas.google.com/g/2005#other\" address=\"[email protected]\" primary=\"true\"/>\n</entry>\n<entry gd:etag=\"&quot;QXk4fjVSLyp7ImA9WxVUGUwDRgE.&quot;\">\n  <id>http://www.google.com/m8/feeds/contacts/eric%40example.com/base/18</id>\n  <updated>2009-03-24T18:25:50.736Z</updated>\n  <app:edited xmlns:app=\"http://www.w3.org/2007/app\">2009-03-24T18:25:50.736Z</app:edited>\n  <category scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/contact/2008#contact\"/>\n  <title>Eric</title>\n  <link rel=\"http://schemas.google.com/contacts/2008/rel#photo\" type=\"image/*\" href=\"http://www.google.com/m8/feeds/photos/media/eric%40example.com/18\" gd:etag=\"&quot;UD9rbkUqSip7ImBkJkcZdVBoHxkeNFMKV1E.&quot;\"/>\n  <link rel=\"self\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full/18\"/>\n  <link rel=\"edit\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full/18\"/>\n  <gd:email rel=\"http://schemas.google.com/g/2005#other\" address=\"[email protected]\" primary=\"true\"/>\n  <gd:email rel=\"http://schemas.google.com/g/2005#other\" address=\"[email protected]\"/>\n  <gd:im address=\"example\" protocol=\"http://schemas.google.com/g/2005#AIM\" rel=\"http://schemas.google.com/g/2005#other\"/>\n  <gd:phoneNumber rel=\"http://schemas.google.com/g/2005#mobile\">999 555 1212</gd:phoneNumber>\n  <gd:postalAddress rel=\"http://schemas.google.com/g/2005#home\">123 Any Street\nAnyTown, ZZ 99999</gd:postalAddress>\n  <gContact:groupMembershipInfo deleted=\"false\" href=\"http://www.google.com/m8/feeds/groups/eric%40example.com/base/6\"/>\n</entry>\n</feed>\n"
CONTACTS2 =

Second page of contacts

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:openSearch=\"http://a9.com/-/spec/opensearch/1.1/\" xmlns:gContact=\"http://schemas.google.com/contact/2008\" xmlns:batch=\"http://schemas.google.com/gdata/batch\" xmlns:gd=\"http://schemas.google.com/g/2005\" gd:etag=\"W/&quot;CEYFQXkzfCp7ImA9WxVUGEg.&quot;\">\n<id>[email protected]</id>\n<updated>2009-03-23T23:48:30.784Z</updated>\n<category scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/contact/2008#contact\"/>\n<title>drbrain's Contacts</title>\n<link rel=\"alternate\" type=\"text/html\" href=\"http://www.google.com/\"/>\n<link rel=\"http://schemas.google.com/g/2005#feed\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full\"/>\n<link rel=\"http://schemas.google.com/g/2005#post\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full\"/>\n<link rel=\"http://schemas.google.com/g/2005#batch\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full/batch\"/>\n<link rel=\"self\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full?start-index=3&amp;max-results=2\"/>\n<link rel=\"previous\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full?start-index=1&amp;max-results=2\"/>\n<author>\n  <name>drbrain</name>\n  <email>[email protected]</email>\n</author>\n<generator version=\"1.0\" uri=\"http://www.google.com/m8/feeds\">Contacts</generator>\n<openSearch:totalResults>4</openSearch:totalResults>\n<openSearch:startIndex>3</openSearch:startIndex>\n<openSearch:itemsPerPage>2</openSearch:itemsPerPage>\n<entry gd:etag=\"&quot;QXk_fTVSLyp7ImA9WxVUFUQITgA.&quot;\">\n  <id>http://www.google.com/m8/feeds/contacts/eric%40example.com/base/5834fb5d0b47bfd7</id>\n  <updated>2009-03-20T23:49:00.745Z</updated>\n  <app:edited xmlns:app=\"http://www.w3.org/2007/app\">2009-03-20T23:49:00.745Z</app:edited>\n  <category scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/contact/2008#contact\"/>\n  <title>Coby</title>\n  <link rel=\"http://schemas.google.com/contacts/2008/rel#photo\" type=\"image/*\" href=\"http://www.google.com/m8/feeds/photos/media/eric%40example.com/5834fb5d0b47bfd7\" gd:etag=\"&quot;eRJhPnolbCp7ImBjG0U0GBtuHmVAdnsJYzM.&quot;\"/>\n  <link rel=\"self\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full/5834fb5d0b47bfd7\"/>\n  <link rel=\"edit\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full/5834fb5d0b47bfd7\"/>\n  <gd:email rel=\"http://schemas.google.com/g/2005#other\" address=\"[email protected]\" primary=\"true\"/>\n  <gContact:groupMembershipInfo deleted=\"false\" href=\"http://www.google.com/m8/feeds/groups/eric%40example.com/base/6\"/>\n</entry>\n<entry gd:etag=\"&quot;QXk_fTVSLyp7ImA9WxVUFUQITgAz&quot;\">\n  <id>http://www.google.com/m8/feeds/contacts/eric%40example.com/base/5834fb5d0b47bfdb</id>\n  <updated>2009-03-20T23:49:00.745Z</updated>\n  <app:edited xmlns:app=\"http://www.w3.org/2007/app\">2009-03-20T23:49:00.745Z</app:edited>\n  <category scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/contact/2008#contact\"/>\n  <title>No-email</title>\n  <link rel=\"http://schemas.google.com/contacts/2008/rel#photo\" type=\"image/*\" href=\"http://www.google.com/m8/feeds/photos/media/eric%40example.com/5834fb5d0b47bfdb\" gd:etag=\"&quot;eRJhPnolbCp7ImBjG0U0GBtuHmVAdnsJYzMz&quot;\"/>\n  <link rel=\"self\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full/5834fb5d0b47bfdb\"/>\n  <link rel=\"edit\" type=\"application/atom+xml\" href=\"http://www.google.com/m8/feeds/contacts/eric%40example.com/full/5834fb5d0b47bfdb\"/>\n  <gContact:groupMembershipInfo deleted=\"false\" href=\"http://www.google.com/m8/feeds/groups/eric%40example.com/base/6\"/>\n</entry>\n</feed>\n"