This guide is outdated. See The most recent IronRuby articles in Tutorials and related blog posts.
Developing in .NET? You can use Cucumber with IronRuby. You need both IronRuby and MRI (Matz Ruby Interpreter).
(Mono users – see IronRuby and Mono)
With the latest release of IronRuby, I believe the installation process has been simplified. The following steps appeared to work well:
igem install cucumber —no-ri —no-rdoc
igem install iron-term-ansicolor —no-ri —no-rdoc
copy IronRuby\bin\iGem.bat IronRuby\bin\iCucumber.bat
copy IronRuby\Lib\ironruby\gems\1.8\gems\cucumber-0.4.4\bin\cucumber IronRuby\bin\iCucumber
Run the following command to see if everything is working properly:
Now skip down to the section that explains how to run the examples
You may need MRI to build IronRuby. You also need MRI to install gems if IronRuby is not able to install some gem itself. When you have installed IronRuby you can use gems installed into MRI from IronRuby. See the IronRuby Gems information page for details.
Just download the latest Ruby One click installer from RubyForge and run it with the defaults.
When you open a new command prompt you should be able to run:
If you already have MRI installed, make sure you have the latest version of RubyGems:
SET HOME=C:\tmp gem update --system
You can download IronRuby from “http://ironruby.codeplex.com/:”http://ironruby.codeplex.com/
Refer to IronRuby GIT wiki for downloading the sources and building from the sources.
You can install gems with IronRuby using the
igem.bat script in the bin folder. See the IronRuby Gems information page for details. For now, it is safer to install the cucumber gem using MRI.
gem install cucumber rspec
(Note: until Cucumber 0.1.12 is released you have to get the Cucumber code from Git and build the gem yourself).
When Cucumber is installed, a
cucumber.bat script is placed under your MRI’s bin directory.
This script will run Cucumber with MRI. We’ll make a similar one that will launch Cucumber
Create an empty file called
icucumber.bat in MRI’s bin directory.
Open it in your favourite text editor (I hope you have installed something better than
Notepad, but it will do).
On my system
icucumber.bat looks like this (You may have to change the path to
@ECHO OFF REM This is to tell IronRuby where to find gems. SET GEM_PATH=c:\ruby\lib\ruby\gems\1.8 @"C:\ironruby\build\debug\ir.exe" "c:\ruby\bin\cucumber" %*
Tip: C:\ruby\… is just the path to your Ruby installation, if you’ve chosen to install it elsewhere, change that part of the script. Also C:\ironruby\… is just the path to your IronRuby installation, so again, if you’ve chosen to install it elsewhere (like C:\Languages\IronRuby), you should update the script.
Now you should be able to run Cucumber with IronRuby:
Open a command prompt and cd to the Cucumber examples directory. If you have installed MRI to the default
location you’ll find them under
X.Y.Z with the Cucumber version you installed above).
If you pulled the Cucumber code with Git, you’ll find the examples under
cd i18n\en icucumber features
The Code under test is pure Ruby, so it’s not that interesting in the context of IronRuby.
cd cs compile.bat icucumber features
The code under test is C#. Now go ahead and add some Cucumber love to your own C# code!