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
Showing
20 changed files
with
1,727 additions
and
2 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
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,88 @@ | ||
--- !ruby/object:Gem::Specification | ||
name: thoughtbot-factory_girl | ||
version: !ruby/object:Gem::Version | ||
version: 1.1.3 | ||
platform: ruby | ||
authors: | ||
- Joe Ferris | ||
autorequire: | ||
bindir: bin | ||
cert_chain: [] | ||
|
||
date: 2008-09-12 00:00:00 +07:00 | ||
default_executable: | ||
dependencies: | ||
- !ruby/object:Gem::Dependency | ||
name: activesupport | ||
type: :runtime | ||
version_requirement: | ||
version_requirements: !ruby/object:Gem::Requirement | ||
requirements: | ||
- - ">=" | ||
- !ruby/object:Gem::Version | ||
version: "1.0" | ||
version: | ||
description: factory_girl provides a framework and DSL for defining and using factories - less error-prone, more explicit, and all-around easier to work with than fixtures. | ||
email: jferris@thoughtbot.com | ||
executables: [] | ||
|
||
extensions: [] | ||
|
||
extra_rdoc_files: | ||
- README.textile | ||
files: | ||
- Changelog | ||
- LICENSE | ||
- Rakefile | ||
- README.textile | ||
- lib/factory_girl/aliases.rb | ||
- lib/factory_girl/attribute.rb | ||
- lib/factory_girl/attribute_proxy.rb | ||
- lib/factory_girl/factory.rb | ||
- lib/factory_girl/sequence.rb | ||
- lib/factory_girl.rb | ||
- test/aliases_test.rb | ||
- test/attribute_proxy_test.rb | ||
- test/attribute_test.rb | ||
- test/factory_test.rb | ||
- test/integration_test.rb | ||
- test/models.rb | ||
- test/sequence_test.rb | ||
- test/test_helper.rb | ||
has_rdoc: true | ||
homepage: | ||
post_install_message: | ||
rdoc_options: | ||
- --line-numbers | ||
- --inline-source | ||
- --main | ||
- README.textile | ||
require_paths: | ||
- bin | ||
- lib | ||
required_ruby_version: !ruby/object:Gem::Requirement | ||
requirements: | ||
- - ">=" | ||
- !ruby/object:Gem::Version | ||
version: "0" | ||
version: | ||
required_rubygems_version: !ruby/object:Gem::Requirement | ||
requirements: | ||
- - ">=" | ||
- !ruby/object:Gem::Version | ||
version: "0" | ||
version: | ||
requirements: [] | ||
|
||
rubyforge_project: | ||
rubygems_version: 1.2.0 | ||
signing_key: | ||
specification_version: 2 | ||
summary: factory_girl provides a framework and DSL for defining and using model instance factories. | ||
test_files: | ||
- test/aliases_test.rb | ||
- test/attribute_proxy_test.rb | ||
- test/attribute_test.rb | ||
- test/factory_test.rb | ||
- test/integration_test.rb | ||
- test/sequence_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,19 @@ | ||
1.1.3 (September 12, 2008) | ||
Automatically pull in definitions from factories.rb, test/factories.rb, or | ||
spec/factories.rb | ||
1.1.2 (July 30, 2008) | ||
Improved error handling for invalid and undefined factories/attributes | ||
Improved handling of strings vs symbols vs classes | ||
Added a prettier syntax for handling associations | ||
Updated documentation and fixed compatibility with Rails 2.1 | ||
|
||
1.1.1 (June 23, 2008) | ||
The attribute "name" no longer requires using #add_attribute | ||
|
||
1.1.0 (June 3, 2008) | ||
Added support for dependent attributes | ||
Fixed the attributes_for build strategy to not build associations | ||
Added support for sequences | ||
|
||
1.0.0 (May 31, 208) | ||
First version |
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 @@ | ||
Copyright (c) 2008 Joe Ferris and thoughtbot, inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
147 changes: 147 additions & 0 deletions
147
vendor/gems/thoughtbot-factory_girl-1.1.3/README.textile
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,147 @@ | ||
h1. factory_girl | ||
|
||
Written by "Joe Ferris":mailto:jferris@thoughtbot.com. | ||
|
||
Thanks to Tammer Saleh, Dan Croak, and Jon Yurek of thoughtbot, inc. | ||
|
||
Copyright 2008 Joe Ferris and thoughtbot, inc. | ||
|
||
h2. Download | ||
|
||
Github: "Page":http://github.com/thoughtbot/factory_girl/tree/master "Clone":git://github.com/thoughtbot/factory_girl.git | ||
|
||
Gem: <pre>gem install thoughtbot-factory_girl --source http://gems.github.com</pre> | ||
|
||
Note: if you install factory_girl using the gem from Github, you'll need this | ||
in your environment.rb if you want to use Rails 2.1's dependency manager: | ||
|
||
config.gem "thoughtbot-factory_girl", | ||
:lib => "factory_girl", | ||
:source => "http://gems.github.com" | ||
|
||
h2. Defining factories | ||
|
||
<pre><code># This will guess the User class | ||
Factory.define :user do |u| | ||
u.first_name 'John' | ||
u.last_name 'Doe' | ||
u.admin false | ||
end | ||
|
||
# This will use the User class (Admin would have been guessed) | ||
Factory.define :admin, :class => User do |u| | ||
u.first_name 'Admin' | ||
u.last_name 'User' | ||
u.admin true | ||
end</code></pre> | ||
|
||
|
||
It is recommended that you create a test/factories.rb file and define your | ||
factories there. This file can be included from test_helper or directly from | ||
your test files. Don't forget: | ||
<pre><code>require 'factory_girl'</code></pre> | ||
|
||
|
||
h2. Lazy Attributes | ||
|
||
Most attributes can be added using static values that are evaluated when the | ||
factory is defined, but some attributes (such as associations and other | ||
attributes that must be dynamically generated) will need values assigned each | ||
time an instance is generated. These "lazy" attributes can be added by passing | ||
a block instead of a parameter: | ||
|
||
<pre><code>Factory.define :user do |u| | ||
# ... | ||
u.activation_code { User.generate_activation_code } | ||
end</code></pre> | ||
|
||
|
||
h2. Dependent Attributes | ||
|
||
Some attributes may need to be generated based on the values of other | ||
attributes. This can be done by calling the attribute name on | ||
Factory::AttributeProxy, which is yielded to lazy attribute blocks: | ||
|
||
<pre><code>Factory.define :user do |u| | ||
u.first_name 'Joe' | ||
u.last_name 'Blow' | ||
u.email {|a| "#{a.first_name}.#{a.last_name}@example.com".downcase } | ||
end | ||
|
||
Factory(:user, :last_name => 'Doe').email | ||
# => "joe.doe@example.com"</code></pre> | ||
|
||
|
||
h2. Associations | ||
|
||
Associated instances can be generated by using the association method when | ||
defining a lazy attribute: | ||
|
||
<pre><code>Factory.define :post do |p| | ||
# ... | ||
p.author {|author| author.association(:user, :last_name => 'Writely') } | ||
end</code></pre> | ||
|
||
|
||
When using the association method, the same build strategy (build, create, or attributes_for) will be used for all generated instances: | ||
|
||
<pre><code># Builds and saves a User and a Post | ||
post = Factory(:post) | ||
post.new_record? # => false | ||
post.author.new_record # => false | ||
|
||
# Builds but does not save a User and a Post | ||
Factory.build(:post) | ||
post.new_record? # => true | ||
post.author.new_record # => true</code></pre> | ||
|
||
Because this pattern is so common, a prettier syntax is available for defining | ||
associations: | ||
|
||
<pre><code># The following definitions are equivilent: | ||
Factory.define :post do |p| | ||
p.author {|a| a.association(:user) } | ||
end | ||
|
||
Factory.define :post do |p| | ||
p.association :author, :factory => :user | ||
end</code></pre> | ||
|
||
If the factory name is the same as the association name, the factory name can | ||
be left out. | ||
|
||
|
||
h2. Sequences | ||
|
||
Unique values in a specific format (for example, e-mail addresses) can be | ||
generated using sequences. Sequences are defined by calling Factory.sequence, | ||
and values in a sequence are generated by calling Factory.next: | ||
|
||
<pre><code># Defines a new sequence | ||
Factory.sequence :email do |n| | ||
"person#{n}@example.com" | ||
end | ||
|
||
Factory.next :email | ||
# => "person1@example.com" | ||
|
||
Factory.next :email | ||
# => "person2@example.com"</code></pre> | ||
|
||
|
||
h2. Using factories | ||
|
||
<pre><code># Build and save a User instance | ||
Factory(:user) | ||
|
||
# Build a User instance and override the first_name property | ||
Factory.build(:user, :first_name => 'Joe') | ||
|
||
# Return an attributes Hash that can be used to build a User instance | ||
attrs = Factory.attributes_for(:user)</code></pre> | ||
|
||
h2. More Information | ||
|
||
"Our blog":http://giantrobots.thoughtbot.com | ||
|
||
"factory_girl rdoc":http://dev.thoughtbot.com/factory_girl |
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,69 @@ | ||
require 'rubygems' | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
require 'rake/gempackagetask' | ||
require 'date' | ||
|
||
desc 'Default: run unit tests.' | ||
task :default => :test | ||
|
||
desc 'Test the factory_girl plugin.' | ||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = true | ||
end | ||
|
||
desc 'Generate documentation for the factory_girl plugin.' | ||
Rake::RDocTask.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'Factory Girl' | ||
rdoc.options << '--line-numbers' << '--inline-source' << "--main" << "README.textile" | ||
rdoc.rdoc_files.include('README.textile') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end | ||
|
||
desc 'Update documentation on website' | ||
task :sync_docs => 'rdoc' do | ||
`rsync -ave ssh rdoc/ dev@dev.thoughtbot.com:/home/dev/www/dev.thoughtbot.com/factory_girl` | ||
end | ||
|
||
spec = Gem::Specification.new do |s| | ||
s.name = %q{factory_girl} | ||
s.version = "1.1.3" | ||
s.summary = %q{factory_girl provides a framework and DSL for defining and | ||
using model instance factories.} | ||
s.description = %q{factory_girl provides a framework and DSL for defining and | ||
using factories - less error-prone, more explicit, and | ||
all-around easier to work with than fixtures.} | ||
|
||
s.files = FileList['[A-Z]*', 'lib/**/*.rb', 'test/**/*.rb'] | ||
s.require_path = 'lib' | ||
s.test_files = Dir[*['test/**/*_test.rb']] | ||
|
||
s.has_rdoc = true | ||
s.extra_rdoc_files = ["README.textile"] | ||
s.rdoc_options = ['--line-numbers', '--inline-source', "--main", "README.textile"] | ||
|
||
s.authors = ["Joe Ferris"] | ||
s.email = %q{jferris@thoughtbot.com} | ||
|
||
s.platform = Gem::Platform::RUBY | ||
s.add_dependency(%q<activesupport>, [">= 1.0"]) | ||
end | ||
|
||
Rake::GemPackageTask.new spec do |pkg| | ||
pkg.need_tar = true | ||
pkg.need_zip = true | ||
end | ||
|
||
desc "Clean files generated by rake tasks" | ||
task :clobber => [:clobber_rdoc, :clobber_package] | ||
|
||
desc "Generate a gemspec file" | ||
task :gemspec do | ||
File.open("#{spec.name}.gemspec", 'w') do |f| | ||
f.write spec.to_ruby | ||
end | ||
end |
16 changes: 16 additions & 0 deletions
16
vendor/gems/thoughtbot-factory_girl-1.1.3/lib/factory_girl.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 @@ | ||
require 'active_support' | ||
require 'factory_girl/factory' | ||
require 'factory_girl/attribute_proxy' | ||
require 'factory_girl/attribute' | ||
require 'factory_girl/sequence' | ||
require 'factory_girl/aliases' | ||
|
||
# Shortcut for Factory.create. | ||
# | ||
# Example: | ||
# Factory(:user, :name => 'Joe') | ||
def Factory (name, attrs = {}) | ||
Factory.create(name, attrs) | ||
end | ||
|
||
Factory.find_definitions |
Oops, something went wrong.