如何运行``rspec - init''用于子目录?''

发布于 2025-01-23 16:58:56 字数 343 浏览 1 评论 0原文

我试图编写一个简单的红宝石代码来自动化任务。任务之一是初始化不是当前目录的目录的RSPEC GEM。

在Ruby文件中编写代码之前,我直接在终端中进行了第一次尝试。这是我尝试过的(在终端窗口中):

$rspec --init a_sub_directory

$rspec a_sub_directory --init

两种情况下的结果:所有RSPEC元素(.rspec + spec/spec_helper.rb)均在当前目录中创建,并且子目录没有更改其内容。

是否有可能在当前目录的子目录中创建RSPEC元素?

I'am trying to write a simple ruby code supposed to automate tasks. One of the task is initializing the rspec gem for a directory which is not the current directory.

I made first tries directly in the terminal before writing my code in he ruby file. Here is what I have tried (in a terminal window) :

$rspec --init a_sub_directory

OR

$rspec a_sub_directory --init

The result in both cases : all the rspec elements ( .rspec + spec/spec_helper.rb) are created in the current directory and the sub directory did not change its content.

Is there anything possible to get the rspec elements created in a sub directory of the current directory ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疯到世界奔溃 2025-01-30 16:58:56

使用dir.chdir方法更改当前目录,然后执行rspec-init。可能是:

Dir.mkdir("a_sub_directory")
Dir.chdir("a_sub_directory")
system("rspec --init)

就是这样;我已经尝试过,它有效。

Use the Dir.chdir method to change the current directory and then execute rspec --init. It could be :

Dir.mkdir("a_sub_directory")
Dir.chdir("a_sub_directory")
system("rspec --init)

And that's it; I've tried this, it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文