Skip to content

Commit

Permalink
Adding platform into the hash
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 fcaf22c commit 948d4d5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/models/dependency.rb
Expand Up @@ -38,13 +38,13 @@ def to_a

# rails,rack,bundler
def self.for(gem_list)
# [{:name => 'name', :number => 'version', :dependencies => []}, ...]
gem_list.split(',').map do |rubygem_name|
rubygem = Rubygem.find_by_name(rubygem_name)
rubygem.versions.includes(:dependencies).map do |version|
{
:name => rubygem.name,
:number => version.number,
:platform => version.platform,
:dependencies => version.dependencies.runtime.map(&:to_a)
}
end
Expand Down
32 changes: 17 additions & 15 deletions features/resolve.feature
Expand Up @@ -3,31 +3,33 @@ Feature: Resolver endpoint
Given a rubygem exists with a name of "terran"
And a rubygem exists with a name of "zerg"
And a rubygem exists with a name of "protoss"
And a version exists for the "terran" rubygem with a number of "1.0.0"
And a version exists for the "terran" rubygem with a number of "2.0.0"
And a version exists for the "protoss" rubygem with a number of "1.0.0"
And a version exists for the "zerg" rubygem with a number of "1.0.0"
And the following versions exist:
| Rubygem | Number | Platform |
| terran | 1.0.0 | mswin32 |
| terran | 2.0.0 | mswin32 |
| protoss | 1.0.0 | ruby |
| zerg | 1.0.0 | java |
And the following dependencies exist:
| Version | Rubygem | Requirements |
| terran-1.0.0 | scv | >= 0 |
| terran-1.0.0 | marine | = 0.0.1 |
| terran-2.0.0 | reaper | >= 0 |
| terran-2.0.0 | siegetank | ~> 1.0.0 |
| protoss-1.0.0 | stalker | <= 2.0.0 |
| protoss-1.0.0 | zealot | = 1.0.0 |
| zerg-1.0.0 | drone | >= 0 |
| Version | Rubygem | Requirements |
| terran-1.0.0-mswin32 | scv | >= 0 |
| terran-1.0.0-mswin32 | marine | = 0.0.1 |
| terran-2.0.0-mswin32 | reaper | >= 0 |
| terran-2.0.0-mswin32 | siegetank | ~> 1.0.0 |
| protoss-1.0.0 | stalker | <= 2.0.0 |
| protoss-1.0.0 | zealot | = 1.0.0 |
| zerg-1.0.0-java | drone | >= 0 |

Scenario: Resolve terran and protoss
When I request "/api/v1/dependencies?gems=terran,protoss"
Then I should see the following dependencies for "terran" version "1.0.0":
Then I should see the following dependencies for "terran-1.0.0-mswin32":
| Name | Requirements |
| scv | >= 0 |
| marine | = 0.0.1 |
And I should see the following dependencies for "terran" version "2.0.0":
And I should see the following dependencies for "terran-2.0.0-mswin32":
| Name | Requirements |
| reaper | >= 0 |
| siegetank | ~> 1.0.0 |
And I should see the following dependencies for "protoss" version "1.0.0":
And I should see the following dependencies for "protoss-1.0.0":
| Name | Requirements |
| stalker | <= 2.0.0 |
| zealot | = 1.0.0 |
Expand Down
10 changes: 9 additions & 1 deletion features/step_definitions/factory_girl_steps.rb
Expand Up @@ -29,4 +29,12 @@
rubygem = Rubygem.find_by_name!(rubygem_name)
user = User.find_by_email(user_email)
Factory(:subscription, :rubygem => rubygem, :user => user)
end
end

Given "the following versions exist:" do |table|
table.hashes.each do |row|
Factory(:version, :rubygem => Rubygem.find_by_name!(row["Rubygem"]),
:number => row["Number"],
:platform => row["Platform"])
end
end
9 changes: 6 additions & 3 deletions features/step_definitions/view_steps.rb
Expand Up @@ -24,11 +24,14 @@
assert_select("h3", :text => version_number)
end

Then /^I should see the following dependencies for "([^"]*)" version "([^"]*)":$/ do |rubygem_name, version_number, table|
data = Marshal.load(response.body)
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] == rubygem_name && hash[:number] == version_number }
gem_hash = data.detect { |hash| hash[:name] == version.rubygem.name &&
hash[:number] == version.number &&
hash[:platform] == version.platform }

assert gem_hash.present?

Expand Down

0 comments on commit 948d4d5

Please sign in to comment.