SameShirtEveryDay.com

Personal blog of the one called Alex Gorbatchev, from Toronto, Canada.

Missing ‘a’ character on Windows with rspec and cucumber

Posted on April 18th, 2009 by Alex Gorbatchev. Tagged with , , , . In Rails, Ruby, Testing, Web Development. 10 comments!

cucumber_a_characters_missing

Trying to get a windows rails environment going this morning I stumbled upon something interesting – all ‘a’ characters were missing from cucumber and rspec output.

This has something to do with UTF-8 encoding and there’s a ticket and wiki post on cucumber about it, but no solution that I found acceptable.

Everything comes down to having change encoding in the current cmd window. This is achieved via a simple call to chcp 1252, but nobody want’s to do this every time, right?

To get this executed automaticaly and without resorting to serious registry editing, simply add this line to your cucmber.bat and any other batch files that are exhibiting this problem. You can find cucumber.bat in your /ruby/bin folder.

Here’s what it looks like:

chcp 1252
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "c:/ruby/bin/cucumber" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

10 comments.

  1. Aninda

    I was getting aggravated when I tried to copy and paste the undefined steps. I tried to think of words which didn’t have ‘a’. lol. Thanks!

  2. LRTom

    Thanks for posting this -especially the batchfile trick. I ran into this many months ago, and forgot how I resolved it.

    Now on a new machine, and I was seeing the same thing. Didn’t look forward to spending an hour hunting down a fix, and now I don’t have to – this is just what I needed. Worked perfectly – thanks!

    Tom

  3. Guillermo Velasquez

    Hi Alex…

    I was wondering if your cucumber performance is good enough… Mine (Win Vista 64bit) it’s awful. Even though cucumber tells that the features took only a few hundred of ‘ms’ actually the whole process takes more than 20 seconds….

    Have you read about this?

    Which version of windows you have?

    Btw I’m testing with rspec, rspec-rails and webrat….

    Thanks in advance…

  4. A minor tweak is to munge the cucumber.bat file so the first two lines are:

    @ECHO OFF
    chcp 1252 > NUL

    This has the effect of preventing the text Active code page: 1252 from appearing in the console output.

  5. Abhi

    Hi,

    The Trick mentioned above adding “chcp 1252″ to cucumber.bat file didn’t work.
    Still letter ‘a’ is missing.
    I am using
    cucumber-0.4.2
    watir-1.6.2

    Is this Solution meant for Old Version of cucumber?

  6. ravi

    thanx a lot it worked for me

  7. Ghanimaid

    worked great, thx a lot

  8. bt

    Any idea how to fix this for Cygwin?

  9. bean

    Thank you, thank you, thank you. This has been driving me mad.

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> , rel="nofollow" in use - no link dropping, no keywords or domains as names; do not spam, and do not advertise!

home
Subscribe to this blog Follow me on Twitter My bookmarks on Delicious My photography on Flickr