'How run the ``rspec --init` for a sub-directory ?`
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 ?
Regards and thanks :)
Julien
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jeremy Caney |
