在仍处于开发阶段时,如何测试我的Ruby CLI应用程序? [英] How can I test my Ruby CLI app while still in development?
问题描述
早上好,
我正在为自己编写一个小型的Ruby CLI应用程序,但遇到了一个小问题,希望大家能为您提供帮助.抱歉,这是一个愚蠢的问题,我是Ruby的新手.
I am writing a small Ruby CLI app for myself, and I have run into a small issue that I hope you guys can help with. Apologies if this is a stupid question, I am very new to Ruby.
我正在使用 https://github.com/davetron5000/gli 作为构建我的基础我的应用程序,因为它们使我所有的命令和其他操作变得容易.
I am using https://github.com/davetron5000/gli as a foundation to build my my app since they make it easy to have all my commands and whatnot.
问题是,在我开发应用程序时,可以使用 bundle exec bin/konstruct
运行它,但这仅在代码所在的文件夹中有效.
Question is, while I develop the app, I can run it using bundle exec bin/konstruct
, but that only works from the folder where the code lies.
我想从测试文件夹中运行该应用程序,以便可以查看所添加的代码是否正在执行应做的工作(制作文件,删除文件,查看目录是否为空等).
I want to run the app from a test folder so I can see whether the code I'm adding is doing what it should (make files, remove files, see if directory is empty, etc).
当我使用NodeJS时,我可以链接该应用程序,并且该应用程序可以在任何地方使用.对于仍在开发中的Ruby应用程序,有类似的东西吗?
When I played around with NodeJS, I could link the app, and it would work anywhere. Is there something like that for Ruby apps that are still in development?
推荐答案
两种简单方法:1.使 bin/konstruct
可执行.因此,您可以在没有 bundle exec
的情况下运行它.然后将其链接到 $ PATH
中的任何目录中,并使用 ln -s
.(对于基于Unix的系统)2.在您的外壳中创建一个别名.像这样的东西:
Two simple way:
1. Make bin/konstruct
executable. So you can run it without bundle exec
. Then link it in any directory in your $PATH
with ln -s
. (For Unix based systems)
2. Create a alias in your shell. something like this:
alias konstruct="bundle exec /FULL/PATH/TO/bin/konstruct"
(对于基于Unix的系统也是如此)
(Also for Unix based systems)
这篇关于在仍处于开发阶段时,如何测试我的Ruby CLI应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!