Permalink
Browse files

Rubygems api docs

  • Loading branch information...
1 parent e58965a commit 6186c70bff412423462b4ffd6aa3b2ef89c1a910 @oestrich committed Mar 19, 2012
Showing with 69 additions and 0 deletions.
  1. +69 −0 spec/acceptance/api/v1/rubygems_spec.rb
@@ -100,4 +100,73 @@
end
end
end
+
+ # TODO Come back after we can handle binary data
+ post "/api/v1/gems"
+
+ delete "/api/v1/gems/yank" do
+ parameter :gem_name, "Name of gem"
+ parameter :version, "Version to be yanked"
+ parameter :platform, "Platform of gem"
+
+ required_parameters :gem_name, :version
+
+ let(:accept) { "application/json" }
+
+ let(:gem_name) { rubygem.name }
+ let(:version_gem) { rubygem.versions.first }
+ let(:version) { version_gem.number }
+
+ example "Yanking a version" do
+ do_request
+
+ response_body.should == "Successfully yanked gem: #{version_gem.to_title}"
+ status.should == 200
+ end
+
+ example "Yanking a version - Already yanked" do
+ Factory(:version, :rubygem => rubygem)
+ rubygem.yank!(version_gem)
+
+ do_request
+
+ response_body.should =~ /has already been yanked/
+ status.should == 422
+ end
+ end
+
+ put "/api/v1/gems/unyank" do
+ parameter :gem_name, "Name of gem"
+ parameter :version, "Version to be yanked"
+ parameter :platform, "Platform of gem"
+
+ required_parameters :gem_name, :version
+
+ before do
+ Factory(:version, :rubygem => rubygem)
+ rubygem.yank!(version_gem)
+ end
+
+ let(:accept) { "application/json" }
+
+ let(:gem_name) { rubygem.name }
+ let(:version_gem) { rubygem.versions.first }
+ let(:version) { version_gem.number }
+
+ example "Unyanking a version" do
+ do_request
+
+ response_body.should == "Successfully unyanked gem: #{version_gem.to_title}"
+ status.should == 200
+ end
+
+ example "Unyanking a version - Already indexed" do
+ version = Factory(:version, :rubygem => rubygem)
+
+ do_request(:version => version.number)
+
+ response_body.should =~ /already indexed/
+ status.should == 422
+ end
+ end
end

0 comments on commit 6186c70

Please sign in to comment.