Ruby 1.8.7 の Windows で Cucumber と Aruba を使用して、基本的な BDD デモを実行しています。アイデアは、単純な「あいさつ」アプリケーションでユーザーに名前の入力を求め、名前で挨拶することです。
Cucumber のシナリオは次のようになります。
# 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"
私のステップの実装では、Aruba が提供するいくつかの関数を使用しており、次のようになります。
# 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
ボット自体は非常にシンプルで、次のようになります。
# chatbot.rb
$stdout.sync = true
puts "What is your name?"
name = gets.chomp
puts "Hello, #{name}"
Mac/Linux では、これは正常に機能し、すべてのシナリオに合格します。assert_partial_outputただし、Windows では、テスト対象の出力に最後の行 ("Hello, Tim") が含まれていないことが常に見られます。
ppプログラムの出力全体を含むはずの の内容を使用してみまし@interactive.stdoutたが、最初の「あなたの名前は何ですか?」だけが含まれています。行に改行を加えます。
Cucumber と Aruba でこの種の問題を引き起こす Windows の問題はありますか? これらのテストに合格しないのはなぜですか?