Find definitions handles subdirectories

Closes #150
This commit is contained in:
Joshua Clayton 2011-06-27 15:24:08 -04:00
parent 5147f8b2f2
commit e552dc322e
2 changed files with 10 additions and 1 deletions

View File

@ -14,7 +14,7 @@ module FactoryGirl
require("#{path}.rb") if File.exists?("#{path}.rb")
if File.directory? path
Dir[File.join(path, '*.rb')].sort.each do |file|
Dir[File.join(path, '**', '*.rb')].sort.each do |file|
require file
end
end

View File

@ -96,5 +96,14 @@ describe "definition loading" do
it { should require_definitions_from("#{dir}/factories/person_factory.rb") }
end
end
describe "with deeply nested factory files under #{dir}" do
in_directory_with_files File.join(dir, 'factories', 'subdirectory', 'post_factory.rb'),
File.join(dir, 'factories', 'subdirectory', 'person_factory.rb')
it_should_behave_like "finds definitions" do
it { should require_definitions_from("#{dir}/factories/subdirectory/post_factory.rb") }
it { should require_definitions_from("#{dir}/factories/subdirectory/person_factory.rb") }
end
end
end
end