Skip to content

Commit

Permalink
fixture and specs for like API
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Vegas authored and Javier Vegas committed Feb 13, 2011
1 parent 992d583 commit 337dca3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
17 changes: 16 additions & 1 deletion spec/cases/client_spec.rb
Expand Up @@ -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
18 changes: 18 additions & 0 deletions spec/fixtures/likes.xml
@@ -0,0 +1,18 @@
<likes total="2">
<like>
<person>
<id>POfcN6JhcU</id>
<first-name>George</first-name>
<last-name>Washington</last-name>
<headline>President, United States of America</headline>
</person>
</like>
<like>
<person>
<id>ROfcN6JhcW</id>
<first-name>Napoleon</first-name>
<last-name>Bonaparte</last-name>
<headline>Emperor, France</headline>
</person>
</like>
</likes>
6 changes: 4 additions & 2 deletions spec/spec_helper.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 337dca3

Please sign in to comment.