This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.
Message originally sent by slack user U71DGIY2XJP
Hey everyone! First off wanted to thank you for supporting these awesome open source tools! I am a developer at ezCater, and we are having some issues setting up Stimpack in one of our apps, it is unable to fin the routes file within the pack. Hoping this is the right place to get some help. Details in the thread!
We are following the docs on how to split routes between packs. We moved all existing routes into packs/v1/config/routes/v1.rb, and in the main config/routes.rb, simply do draw(:v1). We are seeing the error:
Your router tried to #draw the external file v1.rb,
but the file was not found in:
* /usr/src/app/config/routes
<@U71DGIY2XJP> It seems that for some reason, stimpack is not recognising your pack root path. If the stimpack was enabled, the error that you get when trying to draw a non-existing route file would include the pack’s route folder:
... but the file was not found in:
* /usr/src/app/config/routes
* /usr/src/packs/v1/config/routes
Because of that, I suspect the problem is with correctly enabling stimpack rather than with that single v1.rb route file (which seems like correctly placed).
If you haven’t manually configured Stimpack.config.root path, the default path for the packs is expected to be in the root folder - "#{Rails.root}/packs" (not in the "#{Rails.root}/app/packs/ ). <@U71DGIY2XJP> Just to confirm - is that the case in your application?
Hi again <@U71DGIY2XJP>, sorry for not responding during the weekend.
Thanks for sharing the full paths. They look correct. I tested it on my local machine, with Rails 6.1.7 and stimpack 0.7.1 and the routes were loaded correctly. So let’s try to investigate it a bit further.
I have two questions now:
In your package folder, is package.yml file present? (The path of that file should be /Users/ritambanerjee/code/work/pos-rails/packs/v1/package.yml)
Could you please run bin/rails runner 'pp Stimpack::Packs.root' and bin/rails runner 'pp Stimpack::Packs.all' to check the Stimpack config?
No worries hope you had a good weekend! Ohhh I had the package.yml in the package in the wrong place! Moved it where you specified and it seems to work! Thanks so much!!
Great to hear that <@U71DGIY2XJP>! Good luck - and please share your experiences of using packwerk in the <#C02TLU33RNW|packwerk> channel, it will be super interesting to hear them
I will definitely do that!
Quick follow up question, is there anything that needs to be done to get Rspec to pick up on tests in the pack? rspec packs/v1/spec/models/* → no specs run rspec packs/v1/spec/models/foobar_spec.rb → runs the one file
After a quick look at README and the source code, it looks like running tests from just one folder within the package might not be supported… But I’m not 100% sure