Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

consolidate application factories into one file

  • Loading branch information...
commit d9e385ab03198b4098b54117a559cd45c1729f87 1 parent dff74ad
@nickrivadeneira nickrivadeneira authored
View
12 features/resolve.feature
@@ -4,12 +4,12 @@ Feature: Resolver endpoint
And a rubygem exists with a name of "zerg"
And a rubygem exists with a name of "protoss"
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:
+ | rubygem | number | platform |
+ | name: terran | 1.0.0 | mswin32 |
+ | name: terran | 2.0.0 | mswin32 |
+ | name: protoss | 1.0.0 | ruby |
+ | name: zerg | 1.0.0 | java |
+ And the following gem dependencies exist:
| Version | Rubygem | Requirements |
| terran-1.0.0-mswin32 | scv | >= 0 |
| terran-1.0.0-mswin32 | marine | = 0.0.1 |
View
2  features/step_definitions/dependency_steps.rb
@@ -1,4 +1,4 @@
-And "the following dependencies exist:" do |table|
+And /the following gem dependencies exist:/ do |table|
table.hashes.each do |hash|
version = Version.find_by_full_name!(hash['Version'])
rubygem = Factory(:rubygem, :name => hash['Rubygem'])
View
14 features/step_definitions/factory_girl_steps.rb
@@ -1,9 +1,3 @@
-Factory.factories.each do |name, factory|
- Given /^an? #{name} exists with an? (.*) of "([^"]*)"$/ do |attr, value|
- Factory(name, attr.gsub(' ', '_') => value)
- end
-end
-
Given /^a version exists for the "([^\"]*)" rubygem with a number of "([^\"]*)"$/ do |rubygem_name, version_number|
rubygem = Rubygem.find_by_name!(rubygem_name)
Factory(:version, :rubygem => rubygem, :number => version_number)
@@ -30,11 +24,3 @@
user = User.find_by_email(user_email)
Factory(:subscription, :rubygem => rubygem, :user => user)
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
View
2  features/support/gemcutter.rb
@@ -7,6 +7,8 @@
DatabaseCleaner.clean_with :truncation
DatabaseCleaner.strategy = :transaction
+require 'factory_girl/step_definitions'
+
Before do
WebMock.reset_webmock
DatabaseCleaner.start
View
81 test/factories/application.rb
@@ -0,0 +1,81 @@
+FactoryGirl.define do
+ factory :dependency do
+ gem_dependency { Gem::Dependency.new(Rubygem.last.name, "1.0.0") }
+ rubygem # { Factory(:rubygem) }
+ version
+ end
+
+ factory :development_dependency, :parent => :dependency do
+ gem_dependency { Gem::Dependency.new(Rubygem.last.name, "1.0.0", :development) }
+ end
+
+ factory :runtime_dependency, :parent => :dependency do
+ end
+
+ factory :linkset do
+ home 'http://example.com'
+ wiki 'http://example.com'
+ docs 'http://example.com'
+ mail 'http://example.com'
+ code 'http://example.com'
+ bugs 'http://example.com'
+ end
+
+ factory :ownership do
+ rubygem
+ user
+ end
+
+ factory :rubyforger do
+ email
+ encrypted_password Digest::SHA1.hexdigest("password")
+ end
+
+ factory :subscription do
+ rubygem
+ user
+ end
+
+ sequence :name do |n|
+ "RubyGem#{n}"
+ end
+
+ factory :rubygem do
+ linkset
+ name
+ end
+
+ factory :rubygem_with_downloads, :parent => :rubygem do
+ after_create do |r|
+ $redis[Download.key(r)] = r['downloads']
+ end
+ end
+
+ sequence :number do |n|
+ "0.0.#{n}"
+ end
+
+ factory :version do
+ authors ["Joe User"]
+ built_at 1.day.ago
+ description "Some awesome gem"
+ indexed true
+ number
+ platform "ruby"
+ rubygem
+ end
+
+ sequence :url do |n|
+ "http://example#{n}.com"
+ end
+
+ factory :web_hook do
+ rubygem
+ url
+ user
+ end
+
+ factory :global_web_hook, :parent => :web_hook do
+ rubygem nil
+ end
+end
View
14 test/factories/dependency.rb
@@ -1,14 +0,0 @@
-FactoryGirl.define do
- factory :dependency do
- gem_dependency { Gem::Dependency.new(Rubygem.last.name, "1.0.0") }
- rubygem # { Factory(:rubygem) }
- version
- end
-
- factory :development_dependency, :parent => :dependency do
- gem_dependency { Gem::Dependency.new(Rubygem.last.name, "1.0.0", :development) }
- end
-
- factory :runtime_dependency, :parent => :dependency do
- end
-end
View
4 test/factories/download.rb
@@ -1,4 +0,0 @@
-FactoryGirl.define do
- factory :download do
- end
-end
View
10 test/factories/linkset.rb
@@ -1,10 +0,0 @@
-FactoryGirl.define do
- factory :linkset do
- home 'http://example.com'
- wiki 'http://example.com'
- docs 'http://example.com'
- mail 'http://example.com'
- code 'http://example.com'
- bugs 'http://example.com'
- end
-end
View
6 test/factories/ownership.rb
@@ -1,6 +0,0 @@
-FactoryGirl.define do
- factory :ownership do
- rubygem
- user
- end
-end
View
6 test/factories/requirement.rb
@@ -1,6 +0,0 @@
-FactoryGirl.define do
- factory :requirement do
- dependency
- version
- end
-end
View
6 test/factories/rubyforge.rb
@@ -1,6 +0,0 @@
-FactoryGirl.define do
- factory :rubyforger do
- email
- encrypted_password Digest::SHA1.hexdigest("password")
- end
-end
View
16 test/factories/rubygem.rb
@@ -1,16 +0,0 @@
-FactoryGirl.define do
- sequence :name do |n|
- "RubyGem#{n}"
- end
-
- factory :rubygem do
- linkset
- name
- end
-
- factory :rubygem_with_downloads, :parent => :rubygem do
- after_create do |r|
- $redis[Download.key(r)] = r['downloads']
- end
- end
-end
View
6 test/factories/subscription.rb
@@ -1,6 +0,0 @@
-FactoryGirl.define do
- factory :subscription do
- rubygem
- user
- end
-end
View
15 test/factories/version.rb
@@ -1,15 +0,0 @@
-FactoryGirl.define do
- sequence :number do |n|
- "0.0.#{n}"
- end
-
- factory :version do
- authors ["Joe User"]
- built_at 1.day.ago
- description "Some awesome gem"
- indexed true
- number
- platform "ruby"
- rubygem
- end
-end
View
15 test/factories/web_hook.rb
@@ -1,15 +0,0 @@
-FactoryGirl.define do
- sequence :url do |n|
- "http://example#{n}.com"
- end
-
- factory :web_hook do
- rubygem
- url
- user
- end
-
- factory :global_web_hook, :parent => :web_hook do
- rubygem nil
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.