From 337dca38faca0e9931c0e778b4bf5ff8e8b0818e Mon Sep 17 00:00:00 2001 From: Javier Vegas Date: Sun, 13 Feb 2011 02:17:54 -0800 Subject: [PATCH] fixture and specs for like API --- spec/cases/client_spec.rb | 17 ++++++++++++++++- spec/fixtures/likes.xml | 18 ++++++++++++++++++ spec/spec_helper.rb | 6 ++++-- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 spec/fixtures/likes.xml diff --git a/spec/cases/client_spec.rb b/spec/cases/client_spec.rb index 68bfc5a0..c934b5ee 100644 --- a/spec/cases/client_spec.rb +++ b/spec/cases/client_spec.rb @@ -251,6 +251,21 @@ patent.title.should == "Time machine" patent.date.should == Date.civil(y=2008,m=7,d=23) end - + + it "should retrieve likes for a network update" do + stub_get("/v1/people/~/network/updates/key=gNma67_AdI/likes","likes.xml") + + likes = client.likes("gNma67_AdI") + likes.size.should == 2 + likes.first.profile.first_name.should == "George" + end + + it "should put a like to a network update" do + stub_put("/v1/people/~/network/updates/key=gNma67_AdI/is-liked","blank.xml", 201) + + result = client.like("gNma67_AdI") + result.code.should == "201" + end + end end diff --git a/spec/fixtures/likes.xml b/spec/fixtures/likes.xml new file mode 100644 index 00000000..598b3f9f --- /dev/null +++ b/spec/fixtures/likes.xml @@ -0,0 +1,18 @@ + + + + POfcN6JhcU + George + Washington + President, United States of America + + + + + ROfcN6JhcW + Napoleon + Bonaparte + Emperor, France + + + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e613e189..959ad42d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -38,8 +38,10 @@ def expect_post(url, body, result = nil) }).should have_been_made.once end -def stub_put(url, returns_xml) - stub_request(:put, linkedin_url(url)).to_return(:body => fixture(returns_xml)) +def stub_put(url, returns_xml, status=nil) + options = { :body => fixture(returns_xml) } + options.merge!({ :status => status }) unless status.nil? + stub_request(:put, linkedin_url(url)).to_return(options) end def stub_delete(url, returns_xml)