How can I test my Ruby CLI app while still in development?

为君一笑 提交于 2019-12-12 03:23:29

问题


Morning guys,

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.

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.

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).

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:


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"

(Also for Unix based systems)



来源:https://stackoverflow.com/questions/34626386/how-can-i-test-my-ruby-cli-app-while-still-in-development

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