Run specs from nested folder

10 views
Skip to first unread message

Jens Møllerhøj

unread,
Jan 28, 2022, 3:32:48 PM1/28/22
to rspec
Hi, a quick question / feature request / how would you do it?

We have a few local gems in our libs folder. E.g. libs/mygem/...

The gems have their own specs in libs/mygem/spec/...

It's getting tiresome to cd in and out of folders to run the different spec. Ideally, something like:

`rspec lib/mygem/spec/` would run the specs of the folder as if it was initialized in in the lib/mygem folder - so the paths etc works.

Do you guys have any smart solution to this? Would it make sense to support redirectly in rspec? Am I just being too lazy?

Interested to hear what you think :-)

Jon Rowe

unread,
Jan 28, 2022, 3:41:13 PM1/28/22
to rspec
There is no reason why you can't run `rspec lib/mygem/spec` that should work as is, to RSpec it's no different to running say, `rspec spec/unit/model` but it does require the specs written to know that they might be run in such a fashion. Mostly thats modifying the path, you could do this in their spec helpers and make sure youj always require the spec helper relative to the files calling, or just add all the spec folders into rspec path from the top level spec helper etc
Reply all
Reply to author
Forward
0 new messages