Rspec multiple spec folders

痴心易碎 提交于 2020-01-06 05:27:30

问题


Im currently building a project using Rspec in which I sepparated in two different folders with domain code and infrastructure code. Both folders have their own specs in a spec folder. The domain/spec folder is the one containing the spec_helper.rb file, thats required from the tests inside the other folder infrastructure/spec

I'd like to know how to have a spec folder in the root of the project, including the spec_helper file and also tests, and being able to run all the tests with just one command (right now I do it running rspec domain/ infrastructure/)


回答1:


RSpec is designed to work with all tests in one folder. By default, this folder is called spec/, but you can use a different name with the --default-path option.

So, your options as I see it are:

  1. Edit the source code of rspec-core to let that configuration support multiple directories. Hopefully your PR will be approved and merged.
  2. Or, write a simple wrapper script that runs rspec against both directories. For example, you could alias rspecs='rspec domain/ infrastructure/'.
  3. Or (what I would recommend!), you could just restructure your tests slightly to use spec/domain/ and spec/infrastructure/ folders -- and then everything will just work, by convention, out of the box.


来源:https://stackoverflow.com/questions/51648304/rspec-multiple-spec-folders

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!