[rspec-users] Mocking and specing command line (cli) execution, file operations etc. ?

David Chelimsky dchelimsky at gmail.com
Sun Jun 6 23:06:56 EDT 2010

On Jun 6, 2010, at 7:42 PM, Kristian Mandrup wrote:

> What are the options for creating specs for file operations, executing
> commands in the CLI etc.?
> If I build a generator or something which runs a lot of things in the
> command line, how do I check the results of these operations, fx
> mocking file system updates and/or mocking the STDOUT/STDIN from the
> terminal?
> There must be some add-on libraries or options for this out there to
> make it easy to accomplish.

Check out Fakefs (http://github.com/defunkt/fakefs) for file operations.

There's a cucumber library called aruba (http://github.com/aslakhellesoy/aruba) that was extracted from spec suites for rspec and cucumber specifically to deal with command line applications and their output. It's got cucumber step definitions, but there is a separate api file that has methods you should be able to use to help with this stuff if you're using rspec. Or, you could just use cucumber for that stuff as well.


More information about the rspec-users mailing list