How to output result to text file?

I would like to pipe the output of a ruby script to a text file. On
unix, I can easily type
mycommand > output.txt

With ruby, I typed
ruby mytestscript.rb > output.txt

The result still prints out to the standard microsoft commandline
console output and not to the file output.txt. How can I achieve the
output to a text file?

Stdout is redirected in this fashion, but stderr is not. My guess is
your testscript prints to stderr. To redirect both do:

c:\Temp>ruby t.rb > out 2>&1

c:\Temp>cat out
stdout is redirected
stderr is redirected

c:\Temp>cat t.rb
                                       
STDOUT.puts "stdout is redirected"
STDERR.puts "stderr is redirected"