ruby-on-rails - 将参数附加到 docker compose test service 命令
问题描述
我试图找出一种方法来制作一个服务,该服务采用可选参数附加到服务(或条目)命令。例如:
testing:
<<: *backend
environment:
# Use the system rails environment or default to test
- RAILS_ENV=${RAILS_ENV:-test}
command: bash -c "bundle exec rspec"
ports:
- '3000:3000'
因此,如果我运行docker-compose run testing
它将测试我的所有规范(这很有效),但我也可以附加参数来指定文件和/或行号,例如docker-compose run testing /specs/models/something.rb:33
编辑:我的目标是减少本地测试所需的打字量。目前将采取以下方式来指定特定的测试:
docker-compose run testing bundle exec rspec spec/models/something.rb:133
解决方案
答案是entrypoint
。设置服务,例如:
testing:
<<: *backend
environment:
# Use the system rails environment or default to testing
- RAILS_ENV=${RAILS_ENV:-test}
entrypoint: ["bundle", "exec", "rspec"]
ports:
- '3000:3000'
然后运行特定的测试docker-compose run testing spec/models/something.rb:139
推荐阅读
- c++ - c++:类类型引用运算符=用法
- visual-studio - VisualStudio SDK,运行时更新错误
- linux - 如何在 Linux 中按用户获取所有文件和目录
- python - 无法从字典创建 pd.Series | TypeError:“值”未排序
- java - Jersey 2.27 无法处理 POST
- javascript - 如何在全球范围内向茉莉花添加自定义匹配器?
- php - 不推荐使用 PHPUnit Symfony v3.4 继承
- sas - SAS循环创建数据集
- javascript - 如何将对象的两个对象合并为一个对象
- tensorflow - Tensorflow:训练和评估过程