Permalink
Browse files

Adds test of dependency api json version

  • Loading branch information...
1 parent c59ea8f commit 3ceaf639b58a58c719116c53b62963e0ba7b5e31 @reggieb reggieb committed Nov 7, 2013
Showing with 31 additions and 18 deletions.
  1. +0 −2 config.ru
  2. +31 −16 test/integration/dependency_api/dependencies_api_test.rb
View
@@ -1,6 +1,4 @@
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
require "geminabox"
-ENV['RUBYGEMS_PROXY'] ||= 'false'
-
run Geminabox::Server
@@ -47,29 +47,44 @@ class DependenciesApiTest < Geminabox::TestCase
end
test "dependency cache is cleared as expected" do
-# assert_can_push(:a, :deps => [[:b, '>= 0']])
-#
-# deps = fetch_deps("a")
-# expected = [
-# {:name=>"a", :number=>"1.0.0", :platform=>"ruby", :dependencies=>[["b", ">= 0"]]}
-# ]
-# assert_equal expected, deps
-#
-# assert_can_push(:a, :deps => [[:b, '>= 1']], :version => "2.0.0")
-#
-# deps = fetch_deps("a")
-# expected = [
-# {:name=>"a", :number=>"1.0.0", :platform=>"ruby", :dependencies=>[["b", ">= 0"]]},
-# {:name=>"a", :number=>"2.0.0", :platform=>"ruby", :dependencies=>[["b", ">= 1"]]}
-# ]
-# assert_equal expected, deps
+ assert_can_push(:a, :deps => [[:b, '>= 0']])
+
+ deps = fetch_deps("a")
+ expected = [
+ {:name=>"a", :number=>"1.0.0", :platform=>"ruby", :dependencies=>[["b", ">= 0"]]}
+ ]
+ assert_equal expected, deps
+
+ assert_can_push(:a, :deps => [[:b, '>= 1']], :version => "2.0.0")
+
+ deps = fetch_deps("a")
+ expected = [
+ {:name=>"a", :number=>"1.0.0", :platform=>"ruby", :dependencies=>[["b", ">= 0"]]},
+ {:name=>"a", :number=>"2.0.0", :platform=>"ruby", :dependencies=>[["b", ">= 1"]]}
+ ]
+ assert_equal expected, deps
end
test "dependency api with empty params" do
deps = Marshal.load HTTPClient.new.get_content(url_for("api/v1/dependencies"))
assert_equal [], deps
end
+ test "get dependencies for multiple gems as json" do
+ cache_fixture_data_dir "multiple_gems_with_deps" do
+ assert_can_push(:a, :deps => [[:b, '>= 0']])
+ assert_can_push(:another_gem, :deps => [[:fred, '>= 0'], [:john, '= 2.0']])
+ end
+
+ gems = %w(a another_gem)
+ deps = JSON.parse HTTPClient.new.get_content(url_for("api/v1/dependencies.json?gems=#{gems.join(",")}"))
+ expected = Set[
+ {"name"=>"a", "number"=>"1.0.0", "platform"=>"ruby", "dependencies"=>[["b", ">= 0"]]},
+ {"name"=>"another_gem", "number"=>"1.0.0", "platform"=>"ruby", "dependencies"=>[["fred", ">= 0"], ["john", "= 2.0"]]}
+ ]
+ assert_equal expected, Set[*deps]
+ end
+
protected
def fetch_deps(*gems)
Marshal.load HTTPClient.new.get_content(url_for("api/v1/dependencies?gems=#{gems.join(",")}"))

0 comments on commit 3ceaf63

Please sign in to comment.