Figured this out last night, with the help of some strategically placed
`puts` statements.

Turns out that this piece of code here was the "secret sauce" that was
allowing rspec to work:
https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/ruby_project.rb#L8-L14

The spec/ and lib/ folders weren't being included by spinach in the
$LOAD_PATH, and thus the reason the autoload wasn't working.

For any one trying to run spinach and tie it in with the rails_helper.rb in
the future, here's what I had to do to get this working:

features/support/env.rb (spinach config file)
  # Help Spinach find the spec directory for autoloading
  $LOAD_PATH.unshift(::File.expand_path('../../spec', __dir__))
  require './config/environment'
  # Most of the desired config is already in rspec
  require 'rails_helper'
  ...

Thank you very much for allowing me to crash the rspec party!

On Sun, Sep 2, 2018 at 12:38 AM Dewey Garwood <[email protected]>
wrote:

> Been using RSpec for a while (great testing tool!), and I'm trying to get
> another test framework to integrate with it (spinach-rails, specifically).
>
> In rails 4.x, everything was working with the following Spinach config:
>
> features/support/env.rb
>   ENV["RAILS_ENV"] = "test"
>   require './config/environment'
>   require './spec/spec_helper.rb'
>   ...
>
> However, now when I import rails_helper.rb (in rails 5.2) in place of
> spec_helper.rb, I get an error indicating that it can't find the
> spec_helper file (required in the rails_helper file).  It seems clear to me
> that rails isn't autoloading the rest of the environment.
>
> Rspec doesn't have these issues, and loads correctly, even when I remove
> the rspec-rails library from the rails_helper.rb.
>
> Would you be able to help me understand how rspec/rspec-rails loads the
> rails env files and what role railties plays in that?  I was expecting to
> be able to use `require 'rails_helper'` and have everything else "just
> work".
>
> Thank you for your help!
>
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rspec/940d9178-227a-42c9-8ea8-0b060d05a6c8%40googlegroups.com
> <https://groups.google.com/d/msgid/rspec/940d9178-227a-42c9-8ea8-0b060d05a6c8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/CA%2BKX80zow1KSXTnmgFGVaDjF82b2ocgjv0YGG1e3-H5LeQPRHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to