1

I try several ways like stubbing STDOUT, using highline-test and aruba gems, but it still stops my cucumber tests and asking for user input. Are there best practices for testing such applications with Cucumber?

Michael
  • 135
  • 2
  • 11

1 Answers1

0

Aruba gives me solution. First of all, my mistake was creating new instance of app's root class without checking if __FILE__ == $0.

And finally it looks like this:

dashboard.feature:

Feature: Manage app with dashboard
As an app user
In order to control application
I want to have a dashboard

Scenario: View dashboard
  When I run `../../lib/reporter.rb` interactively
  Then I should see following choices
    | 1 | Choice 1 |
    | 2 | Choice 2 |
    | 3 | Choice 3 |

steps.rb:

Then(/^I should see following choices$/) do |table|
  menu = ''
  table.rows_hash.each do |key, value|
    menu << "#{key}. #{value}\n"
  end
  Timeout::timeout(exit_timeout) do
    loop do
      break if assert_partial_output_interactive(menu)
      sleep 0.1
    end
  end
end
Michael
  • 135
  • 2
  • 11