Linting should not be the first chapter of "getting started"

In fact, it probably shouldn't be in a "getting started" guide at all, but this commit simply moves it down towards the bottom.
This commit is contained in:
Jared Beck 2015-02-25 10:54:10 -05:00 committed by Joshua Clayton
parent ebb8bebb20
commit d2ceaac72e
1 changed files with 50 additions and 50 deletions

View File

@ -66,56 +66,6 @@ end
If you do not include `FactoryGirl::Syntax::Methods` in your test suite, then all factory_girl methods will need to be prefaced with `FactoryGirl`.
Linting Factories
-----------------
factory_girl allows for linting known factories:
```ruby
FactoryGirl.lint
```
`FactoryGirl.lint` creates each factory and catches any exceptions raised
during the creation process. `FactoryGirl::InvalidFactoryError` is raised with
a list of factories (and corresponding exceptions) for factories which could
not be created. Recommended usage of `FactoryGirl.lint` is to invoke this once
before the test suite is run.
With RSpec:
```ruby
# spec/support/factory_girl.rb
RSpec.configure do |config|
# additional factory_girl configuration
config.before(:suite) do
begin
DatabaseCleaner.start
FactoryGirl.lint
ensure
DatabaseCleaner.clean
end
end
end
```
After calling `FactoryGirl.lint`, you'll likely want to clear out the
database, as records will most likely be created. The provided example above
uses the database_cleaner gem to clear out the database; be sure to add the
gem to your Gemfile under the appropriate groups.
You can lint factories selectively by passing only factories you want linted:
```ruby
factories_to_lint = FactoryGirl.factories.reject do |factory|
factory.name =~ /^old_/
end
FactoryGirl.lint factories_to_lint
```
This would lint all factories that aren't prefixed with `old_`.
Defining factories
------------------
@ -866,6 +816,56 @@ built_users = build_pair(:user) # array of two built users
created_users = create_pair(:user) # array of two created users
```
Linting Factories
-----------------
factory_girl allows for linting known factories:
```ruby
FactoryGirl.lint
```
`FactoryGirl.lint` creates each factory and catches any exceptions raised
during the creation process. `FactoryGirl::InvalidFactoryError` is raised with
a list of factories (and corresponding exceptions) for factories which could
not be created. Recommended usage of `FactoryGirl.lint` is to invoke this once
before the test suite is run.
With RSpec:
```ruby
# spec/support/factory_girl.rb
RSpec.configure do |config|
# additional factory_girl configuration
config.before(:suite) do
begin
DatabaseCleaner.start
FactoryGirl.lint
ensure
DatabaseCleaner.clean
end
end
end
```
After calling `FactoryGirl.lint`, you'll likely want to clear out the
database, as records will most likely be created. The provided example above
uses the database_cleaner gem to clear out the database; be sure to add the
gem to your Gemfile under the appropriate groups.
You can lint factories selectively by passing only factories you want linted:
```ruby
factories_to_lint = FactoryGirl.factories.reject do |factory|
factory.name =~ /^old_/
end
FactoryGirl.lint factories_to_lint
```
This would lint all factories that aren't prefixed with `old_`.
Custom Construction
-------------------