qed icon indicating copy to clipboard operation
qed copied to clipboard

Bash Code Sections

Open ghost opened this issue 17 years ago • 2 comments

It would be nice if code section could support shell (bash) code, for testing bin/ commands. At this point, however, I am not at all certain how this would integrate with the testing of Ruby code.

ghost avatar Nov 28 '09 14:11 ghost

One option is to have #Transform clauses that works like #When matchers but that transform the code section in some fashion. Eg. a $ echo line could be transformed into system('echo').

ghost avatar Jan 09 '10 20:01 ghost

As of the upcoming release, fenced code blocks tagged with non-Ruby languages (e.g. ```bash) are now properly skipped by the parser, so they won't cause errors in your demos.

For testing CLI tools today, you can use Ruby blocks with backticks or system():

output = `myapp greet`
output.assert == "Hello, World!\n"

More direct bash execution support (e.g. automatically running ```bash blocks) is something we may revisit in a future release.

trans avatar Mar 30 '26 14:03 trans