Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Requiring factory definition files now works in 1.9 outside of tests
Ruby 1.9 doesn't automatically include . in the load path; if we do a require to a relative path (eg a file within spec or test), 1.9 will raise a LoadError because spec or test isn't normally in the load path.
- Loading branch information
1 parent
a51b970
commit c47affb
Showing
4 changed files
with
52 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Feature: Factory girl can find factory definitions correctly | ||
Scenario: Find definitions with a path | ||
Given a file named "awesome_factories.rb" with: | ||
""" | ||
FactoryGirl.define do | ||
factory :awesome_category, :parent => :category do | ||
name "awesome!!!" | ||
end | ||
end | ||
""" | ||
When "awesome_factories.rb" is added to Factory Girl's file definitions path | ||
And I create a "awesome_category" instance from Factory Girl | ||
Then I should find the following for the last category: | ||
| name | | ||
| awesome!!! | | ||
|
||
Scenario: Find definitions with a folder | ||
Given a file named "nested/great_factories.rb" with: | ||
""" | ||
FactoryGirl.define do | ||
factory :great_category, :parent => :category do | ||
name "great!!!" | ||
end | ||
end | ||
""" | ||
When "nested" is added to Factory Girl's file definitions path | ||
And I create a "great_category" instance from Factory Girl | ||
Then I should find the following for the last category: | ||
| name | | ||
| great!!! | |
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,10 @@ | ||
When /^"([^"]*)" is added to Factory Girl's file definitions path$/ do |file_name| | ||
new_factory_file = File.join(current_dir, file_name.gsub(".rb", "")) | ||
FactoryGirl.definition_file_paths ||= [] | ||
FactoryGirl.definition_file_paths << new_factory_file | ||
FactoryGirl.find_definitions | ||
end | ||
|
||
When /^I create a "([^"]*)" instance from Factory Girl$/ do |factory_name| | ||
FactoryGirl.create(factory_name) | ||
end |
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