[rspec-devel] spec_helper required multiple times

David Chelimsky dchelimsky at gmail.com
Tue Nov 6 10:26:48 EST 2007


On Nov 6, 2007 9:15 AM, Brandon Keepers <bkeepers at gmail.com> wrote:
> spec_helper gets run multiple times during a spec run.  Throw this at
> the bottom of spec_helper:
>
>    @x ||= 0
>    puts "requiring spec_helper: #{@x += 1}"
>
> Is this expected behavior?  This seems to be caused by #require not
> expanding paths, so it requires spec_helper once per unique require
> statement (once per spec directory).
>
> It is resolved by wrapping the require at the top of each spec file
> with expand_path:
>
>    require File.expand_path(File.dirname(__FILE__) + '/../../
> spec_helper')
>
> It seems to me like this is something that require should do
> automatically.  Thoughts?

Do you mean that Ruby's require should do the right thing, that rspec
should patch require to do the right thing, or that users should do
the right thing?

>
> Brandon
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>


More information about the rspec-devel mailing list