Skip to content

Commit

Permalink
Gems that don't exist just return an empty array for resolving
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Quaranto <nick@quaran.to>
  • Loading branch information
Matt Mongeau authored and qrush committed Aug 17, 2010
1 parent 26415cb commit b0b671c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
11 changes: 11 additions & 0 deletions features/resolve.feature
Expand Up @@ -34,3 +34,14 @@ Feature: Resolver endpoint
| stalker | <= 2.0.0 |
| zealot | = 1.0.0 |
And I should not see any dependencies for "zerg" version "1.0.0"

Scenario: Resolve zerg non-existent gem
When I request "/api/v1/dependencies?gems=zerg,XelNaga"
Then I should see the following dependencies for "zerg-1.0.0-java":
| Name | Requirements |
| drone | >= 0 |
And I should see only 1 element in the array

Scenario: Resolve non-existent gem
When I request "/api/v1/dependencies?gems=XelNaga"
Then I should see an empty array
20 changes: 14 additions & 6 deletions features/step_definitions/view_steps.rb
Expand Up @@ -25,13 +25,12 @@
end

Then /^I should see the following dependencies for "([^"]*)":$/ do |full_name, table|
data = Marshal.load(response.body)
version = Version.find_by_full_name!(full_name)

table.hashes.each do |row|
gem_hash = data.detect { |hash| hash[:name] == version.rubygem.name &&
hash[:number] == version.number &&
hash[:platform] == version.platform }
gem_hash = marshal_body.detect { |hash| hash[:name] == version.rubygem.name &&
hash[:number] == version.number &&
hash[:platform] == version.platform }

assert gem_hash.present?

Expand All @@ -40,7 +39,16 @@
end

Then /^I should not see any dependencies for "([^"]*)" version "([^"]*)"$/ do |rubygem_name, version_number|
data = Marshal.load(response.body)
gem_hash = data.detect { |hash| hash[:name] == rubygem_name && hash[:number] == version_number }
gem_hash = marshal_body.detect { |hash| hash[:name] == rubygem_name && hash[:number] == version_number }
assert_nil gem_hash
end

Then "I should see an empty array" do
assert marshal_body.is_a?(Array)
assert marshal_body.empty?
end

Then /^I should see only (\d+) element in the array$/ do |count|
assert_equal count.to_i, marshal_body.size
end

4 changes: 4 additions & 0 deletions features/support/api.rb
Expand Up @@ -2,6 +2,10 @@ module ApiHelpers
def api_key_header
header("HTTP_AUTHORIZATION", @api_key)
end

def marshal_body
@_marshal_body ||= Marshal.load(response.body)
end
end

World(ApiHelpers)

0 comments on commit b0b671c

Please sign in to comment.