Skip to content

Commit

Permalink
cookie convenience methods and tests
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/facebooker/trunk/facebooker@178 06148572-b36b-44fe-9aa8-f68b04d8b080
  • Loading branch information
drummr77 committed Feb 14, 2008
1 parent 4a4b217 commit 0d567de
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/facebooker/user.rb
Expand Up @@ -163,8 +163,14 @@ def send_email(subject, text=nil, fbml=nil)

##
# Convenience method to set cookie for the current user
def set_cookie(name, value, expires, path)
session.data.set_cookie(@id, name, value, expires=nil, path=nil)
def set_cookie(name, value, expires=nil, path=nil)
session.data.set_cookie(@id, name, value, expires, path)
end

##
# Convenience method to get cookies for the current user
def get_cookies(name=nil)
session.data.get_cookies(@id, name)
end

##
Expand Down
10 changes: 10 additions & 0 deletions test/user_test.rb
Expand Up @@ -48,6 +48,16 @@ def test_can_get_profile_photos
@user.profile_photos
end

def test_can_set_cookie
@user.expects(:set_cookie).with('name', 'value')
@user.set_cookie('name', 'value')
end

def test_can_get_cookies
@user.expects(:get_cookies).with('name')
@user.get_cookies('name')
end

def test_get_profile_photos
@user = Facebooker::User.new(548871286, @session)
expect_http_posts_with_responses(example_profile_photos_get_xml)
Expand Down

0 comments on commit 0d567de

Please sign in to comment.