spec/gems/client_spec.rb in gems-0.0.5 vs spec/gems/client_spec.rb in gems-0.0.6

- old
+ new

@@ -59,21 +59,55 @@ versions.first.number.should == '0.6.3' end end describe ".downloads" do - before do - stub_get("/api/v1/versions/coulda-0.6.3/downloads.json"). - to_return(:body => fixture("downloads.json")) + context "with no dates specified" do + before do + stub_get("/api/v1/versions/coulda-0.6.3/downloads.json"). + to_return(:body => fixture("downloads.json")) + end + + it "should return the number of downloads by day for a particular gem version" do + downloads = Gems.downloads 'coulda', '0.6.3' + a_get("/api/v1/versions/coulda-0.6.3/downloads.json"). + should have_been_made + downloads["2011-06-22"].should == 8 + end end - it "should return the number of downloads by day for a particular gem version" do - downloads = Gems.downloads 'coulda', '0.6.3' - a_get("/api/v1/versions/coulda-0.6.3/downloads.json"). - should have_been_made - downloads["2011-06-22"].should == 8 + context "with from date specified" do + before do + stub_get("/api/v1/versions/coulda-0.6.3/downloads/search.json"). + with(:query => {"from" => "2011-01-01", "to" => Date.today.to_s}). + to_return(:body => fixture("downloads.json")) + end + + it "should return the number of downloads by day for a particular gem version" do + downloads = Gems.downloads 'coulda', '0.6.3', Date.parse('2011-01-01') + a_get("/api/v1/versions/coulda-0.6.3/downloads/search.json"). + with(:query => {"from" => "2011-01-01", "to" => Date.today.to_s}). + should have_been_made + downloads["2011-06-22"].should == 8 + end end + + context "with from and to dates specified" do + before do + stub_get("/api/v1/versions/coulda-0.6.3/downloads/search.json"). + with(:query => {"from" => "2011-01-01", "to" => "2011-06-28"}). + to_return(:body => fixture("downloads.json")) + end + + it "should return the number of downloads by day for a particular gem version" do + downloads = Gems.downloads 'coulda', '0.6.3', Date.parse('2011-01-01'), Date.parse('2011-06-28') + a_get("/api/v1/versions/coulda-0.6.3/downloads/search.json"). + with(:query => {"from" => "2011-01-01", "to" => "2011-06-28"}). + should have_been_made + downloads["2011-06-22"].should == 8 + end + end end describe ".dependencies" do before do stub_get("/api/v1/dependencies"). @@ -113,9 +147,37 @@ it "should list all gems that you own" do gems = Gems.gems a_get("/api/v1/gems.#{format}"). should have_been_made gems.first.name.should == "congress" + end + end + + describe ".owners" do + before do + stub_get("/api/v1/gems/gems/owners.json"). + to_return(:body => fixture("owners.json")) + end + + it "should list all owners of a gem" do + owners = Gems.owners("gems") + a_get("/api/v1/gems/gems/owners.json"). + should have_been_made + owners.first.email.should == "sferik@gmail.com" + end + end + + describe ".web_hooks" do + before do + stub_get("/api/v1/web_hooks.json"). + to_return(:body => fixture("web_hooks.json")) + end + + it "should list the webhooks registered under your account" do + web_hooks = Gems.web_hooks + a_get("/api/v1/web_hooks.json"). + should have_been_made + web_hooks.rails.first.url.should == "http://example.com" end end end end end