forked from Sutto/rubyflow
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b79fd2f
commit 4cb7812
Showing
8 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
vendor/plugins/factory_girl_on_rails/rails_generators/factory/USAGE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Description: | ||
Stubs out a new factory. Pass the factory name name, under_scored, | ||
and an optional list of attribute pairs as arguments. | ||
|
||
Attribute pairs are column_name:sql_type arguments specifying the | ||
model's attributes. Timestamps are added by default, so you don't have to | ||
specify them by hand as 'created_at:datetime updated_at:datetime'. | ||
|
||
This generates a file in test/factories. | ||
|
||
Examples: | ||
`./script/generate factory account` | ||
|
||
creates an Account factory: test/factories/account_factory.rb | ||
|
||
`./script/generate factory post title:string body:text published:boolean` | ||
|
||
creates a Post factory with a string title, text body, and published flag. |
17 changes: 17 additions & 0 deletions
17
vendor/plugins/factory_girl_on_rails/rails_generators/factory/factory_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class FactoryGenerator < Rails::Generator::NamedBase | ||
def manifest | ||
record do |m| | ||
m.directory File.join('test/factories', class_path) | ||
m.template 'factory.rb', File.join('test/factories', class_path, "#{file_name}_factory.rb") | ||
end | ||
end | ||
|
||
def factory_line(attribute) | ||
"#{file_name}.#{attribute.name} '#{attribute.default}'" | ||
end | ||
|
||
protected | ||
def banner | ||
"Usage: #{$0} #{spec.name} FactoryName [field:type, field:type]" | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/factory.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Factory.define :<%= file_name %> do |<%= file_name %>| | ||
<% for attribute in attributes -%> | ||
<%= factory_line(attribute) %> | ||
<% end -%> | ||
end |
19 changes: 19 additions & 0 deletions
19
vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/fixtures.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
||
<% unless attributes.empty? -%> | ||
one: | ||
<% for attribute in attributes -%> | ||
<%= attribute.name %>: <%= attribute.default %> | ||
<% end -%> | ||
|
||
two: | ||
<% for attribute in attributes -%> | ||
<%= attribute.name %>: <%= attribute.default %> | ||
<% end -%> | ||
<% else -%> | ||
# one: | ||
# column: value | ||
# | ||
# two: | ||
# column: value | ||
<% end -%> |
16 changes: 16 additions & 0 deletions
16
vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/migration.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class <%= migration_name %> < ActiveRecord::Migration | ||
def self.up | ||
create_table :<%= table_name %> do |t| | ||
<% for attribute in attributes -%> | ||
t.<%= attribute.type %> :<%= attribute.name %> | ||
<% end -%> | ||
<% unless options[:skip_timestamps] %> | ||
t.timestamps | ||
<% end -%> | ||
end | ||
end | ||
def self.down | ||
drop_table :<%= table_name %> | ||
end | ||
end |
2 changes: 2 additions & 0 deletions
2
vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/model.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class <%= class_name %> < ActiveRecord::Base | ||
end |
7 changes: 7 additions & 0 deletions
7
vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/unit_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class <%= class_name %>Test < ActiveSupport::TestCase | ||
<% for attribute in attributes -%> | ||
should_have_db_column :<%= attribute.name %> | ||
<% end -%> | ||
end |