I need to test a console application and check printed output, using rspec script. Example:
RSpec.describe 'Test Suite', type: :aruba do
it "has aruba set up" do
command = run("echo 'hello world'")
stop_all_commands
expect(command.output).to eq("hello world\n")
end
It fails with:
Failure/Error: command = run("echo 'hello world'")
`run` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block).
Aruba version 0.14.6, Rspec 3.7.0. Will appreciate any help. Thanks.
As the error implies, you cannot call
run
within theit
block. Aruba's documentation can get a bit confusing here because of the various branches, but therun
method is still available in thestill
branch, with documentation found here.Following the documentation, instead of defining
command
within theit
block, we can instead define it outside the block usinglet
: