I'm running what should be a basic BDD demonstration using Cucumber and Aruba on Windows in Ruby 1.8.7. The idea is to have a simple "greeter" application prompt the user for a name, then say hello to them by name.
The Cucumber scenarios look like this:
# name_prompt.feature
Feature: Name prompt
In order to interact with the bot
As a friendly user
I want to tell the app my name
Scenario: Be asked
Given the application is running
Then I should see "What is your name?"
Scenario: Talk back
Given the application is running
And I type "Tim" and press Enter
Then I should see "Hello, Tim"
My step implementations use a few Aruba-provided functions, and looks like:
# cli_steps.rb
Given /^the application is running$/ do
run_interactive(unescape("ruby chatbot.rb"))
end
Then /^I should see "([^"]*)"$/ do |arg1|
assert_partial_output(arg1)
end
Given /^I type "([^"]*)" and press Enter$/ do |arg1|
type(arg1)
end
The bot itself is pretty simple, and just looks like:
# chatbot.rb
$stdout.sync = true
puts "What is your name?"
name = gets.chomp
puts "Hello, #{name}"
On Mac/Linux, this works fine and passes all scenarios. On Windows, however, I'm consistently seeing that the output being tested in assert_partial_output
doesn't include the last line (the "Hello, Tim").
I've tried using pp
on the contents of @interactive.stdout
, which should contain the entire output of the program, but it just contains the first "What is your name?" line, plus a line break.
Are there any issues on Windows that would cause this kind of trouble with Cucumber and Aruba? Why won't these tests pass?