packs-rails: Running bundle exec rspec packs/my_domain fails with cryptic error

Assuming I have a file structure like described in the readme:

packs/
  my_domain/
    spec/ # With stimpack, specs for a pack live next to the pack
      public/
        my_domain_spec.rb
        my_domain/
          my_subdomain_spec.rb
      services/
        my_domain/
          some_private_class_spec.rb
      models/
        some_other_non_namespaced_private_model_spec.rb
        my_domain/
          my_private_namespaced_model_spec.rb
      factories/ # Stimpack will automatically load pack factories into FactoryBot
        my_domain/
          my_private_namespaced_model_factory.rb

How do I run the specs at packs/my_domain/spec/services/my_domain/some_private_class_spec.rb?

I’ve tried both:

> bundle exec rspec packs/my_domain/spec/services/my_domain/some_private_class_spec.rb
> bundle exec rspec spec/services/my_domain/some_private_class_spec.rb

And both result in a very strange error (in fact, with stimpack bundled, no specs work any more)

An error occurred while loading rails_helper.
Failure/Error: require File.expand_path("../config/environment", __dir__)

NoMethodError:
  undefined method `<<' for nil:NilClass
# ./vendor/bundle/ruby/2.7.0/gems/stimpack-0.4.0/lib/stimpack/integrations/rails.rb:11:in `block (2 levels) in install'
# ./vendor/bundle/ruby/2.7.0/gems/stimpack-0.4.0/lib/stimpack/integrations/rails.rb:10:in `each'
# ./vendor/bundle/ruby/2.7.0/gems/stimpack-0.4.0/lib/stimpack/integrations/rails.rb:10:in `block in install'
# ./vendor/bundle/ruby/2.7.0/gems/stimpack-0.4.0/lib/stimpack/packs.rb:36:in `each_value'
# ./vendor/bundle/ruby/2.7.0/gems/stimpack-0.4.0/lib/stimpack/packs.rb:36:in `each'
# ./vendor/bundle/ruby/2.7.0/gems/stimpack-0.4.0/lib/stimpack/integrations/rails.rb:9:in `install'
# ./vendor/bundle/ruby/2.7.0/gems/stimpack-0.4.0/lib/stimpack.rb:20:in `load'
# ./vendor/bundle/ruby/2.7.0/gems/stimpack-0.4.0/lib/stimpack/railtie.rb:6:in `block in <class:Railtie>'
# ./vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.8/lib/active_support/lazy_load_hooks.rb:68:in `block in execute_hook'
# ./vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.8/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
# ./vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.8/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
# ./vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.8/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
# ./vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.8/lib/active_support/lazy_load_hooks.rb:51:in `each'
# ./vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.8/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
# ./vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.8/lib/rails/application.rb:96:in `inherited'
# ./config/application.rb:47:in `<module:ScoutRFP>'
# ./config/application.rb:40:in `<top (required)>'
# ./config/environment.rb:4:in `require'
# ./config/environment.rb:4:in `<top (required)>'
# ./spec/rails_helper.rb:13:in `require'
# ./spec/rails_helper.rb:13:in `<top (required)>'
No examples found.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 25 (5 by maintainers)

Most upvoted comments

I switched jobs and no longer have access to the repo that initially brought me here. From my end, this issue doesn’t need to be resolved.

I just started playing with this gem and I’m running into this on Rails 6.0 too. We’ve got an upgrade scheduled for the near future since Rails 6.0 goes EOL in the summer, but in the meantime I added this above our Application class in config/application.rb and it seems to make things work so far.

Packs::Rails.config.paths = %w(
  app
  app/controllers
  app/channels
  app/helpers
  app/models
  app/mailers
  app/views
  lib
  lib/tasks
  config
  config/locales
  config/initializers
  config/routes.rb
)

module AppName
  class Application < Rails::Application
    # ...
  end
end