I am having trouble writing to standard input with Aruba. I have tried three approaches.
Approach 1:
Scenario: Write to stdin take 1
Given a file named "infile" with:
"""
Hello World!
"""
When I run `cat < infile`
Then the output should contain exactly:
"""
Hello World!
"""
For this I get the following error:
expected: "Hello World!"
got: "Hello World!cat: <: No such file or directory\n" (using ==)
Diff:
@@ -1,2 +1,2 @@
-Hello World!
+Hello World!cat: <: No such file or directory
(RSpec::Expectations::ExpectationNotMetError)
features/cgi.feature:17:in `Then the output should contain exactly:'
Aruba is passing the '<' through literally whereas the shell would do some magic with pipes.
Approach 2:
Scenario: Write to stdin take 2
When I run `cat` interactively
And I type "Hello World!"
Then the output should contain:
"""
Hello World!
"""
I get the following error:
process still alive after 3 seconds (ChildProcess::TimeoutError)
features/cgi.feature:25:in `Then the output should contain:'
I don't know but I assume that cat is not receiving a EOF character and so cat remains open waiting for further input before writing. Is there any way to signal an end to input?
Approach 3:
Scenario: Write to stdin take 1
Given a file named "infile" with:
"""
Hello World!
"""
When I run `sh -c "cat < infile"`
Then the output should contain exactly:
"""
Hello World!
"""
This approach works, but passing the input through a shell process does not appear to be the ideal solution.
I would have expected this was a fairly standard requirement but have not had any success getting it to work yet.
Any suggestions?
Thanks.