no such file to load -- test/factories.rb #153

ghost opened this Issue Jul 3, 2011 · 6 comments


None yet

2 participants

ghost commented Jul 3, 2011

FactoryGirl.find_definitions gives me this error. I'm too lazy to make a pull request for such a small issue; I'll simply say that I fixed the problem locally in line 14 of find_definitions.rb:

require(File.expand_path("#{path}.rb")) if File.exists?("#{path}.rb")

If no one's complained about this then I imagine it's a Windows-related issue; I believe you need the full path of a file to require it (unless it's a Gem).


Can you actually paste a gist with the output when you run that from console? Thanks!

ghost commented Jul 4, 2011

irb(main):003:0> FactoryGirl.find_definitions
LoadError: no such file to load -- test/factories.rb
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `block in require'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `block in load_dependency'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/factory_girl-2.0.0.rc1/lib/factory_girl/find_definitions.rb:14:in `block in find_definitions'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/factory_girl-2.0.0.rc1/lib/factory_girl/find_definitions.rb:13:in `each'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/factory_girl-2.0.0.rc1/lib/factory_girl/find_definitions.rb:13:in `find_definitions'
        from (irb):3
        from D:/Ruby192/lib/ruby/gems/1.9.1/bundler/gems/padrino-framework-968e44e98d95/padrino-core/lib/padrino-core/cli/base.rb:70:in `console'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in
        from D:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
        from D:/Ruby192/bin/padrino:9:in `<main>'

File.exists? will return true but the file cannot be loaded using that same path (on Windows).

croaky commented Jul 4, 2011

Working on this in a branch:

I added the suggested line, which caused some tests to fail. I got the failing tests passing, but not able to get full test suite running due to what looks like an Appraisal issue. Pushing as "wip" for now.

croaky commented Jul 4, 2011

The error message I get is:

Finished in 0.63511 seconds
201 examples, 0 failures
rake/gempackagetask is deprecated.  Use rubygems/package_task instead
>> BUNDLE_GEMFILE=/Users/lawless/dev/factory_girl/gemfiles/2.1.gemfile bundle exec /Users/lawless/.rvm/gems/ruby-1.9.2-p180/bin/rake spec:acceptance features
Could not find yard-0.7.2 in any of the sources
ghost commented Jul 4, 2011

Ouch, OK then, sorry for assuming that the fix was trivial; I suppose that was naive of me. Didn't imagine any tests would get broken. Does my line break require for other platforms?

EDIT: I always accidentally hit that damn Comment & Close button.

@ghost ghost closed this Jul 4, 2011
@ghost ghost reopened this Jul 4, 2011


I didn't notice this issue before but we've resolved this with our 2.0.1 release of Factory Girl. Sorry I didn't comment sooner! If you're still having issues after upgrading to factory_girl_rails 1.1.0 and fg 2.0.2, please open another issue here on Github. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment