I want to capture output which I'm running from the cucumber feature file.
I created one shell script program and placed it in /usr/local/bin/ so it can be accessible from anywhere in system.
if [[ $arg = 1 ]]
gem 'aruba', '~> 0.14.2'
Scenario: First Run
When I run `bash abc_qa.sh 1`
You can use
%x(command) to get the stdout of your command.
You can then use Time.parse to convert
"Sat Nov 5 12:04:18 CET 2016" to
2016-11-05 12:04:18 +0100 as Time object, and compare it to Time.now :
require 'time' time_from_abc_script = Time.parse(%x(bash abc_qa.sh 1)) puts (Time.now-time_from_abc_script).abs < 5 # No more than 5s difference between 2 times
You could use this boolean in any test file you want.
For example :
Feature: Cucumber Scenario: First Run When I run `bash abc_qa.sh 1` Then the output should be the current time
require 'time' Then(/^the output should be the current time$/) do time_from_script = Time.parse(last_command_started.output) expect(time_from_script).to be_within(5).of(Time.now) end