-
Notifications
You must be signed in to change notification settings - Fork 0
IronRuby and .NET
Developing in .NET? You can use Cucumber with IronRuby. You need both IronRuby and MRI (Matz Ruby Interpreter).
You’ll need MRI to build IronRuby. You also need MRI to install gems since IronRuby can
not install its own gems yet (although it can use them). When you have installed IronRuby you
can use gems installed into MRI from IronRuby.
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:
ruby --version
and
rake --version
With MRI installed we can install IronRuby. At the time of this writing there is no installer
for IronRuby, so you have to download the IronRuby sources from the Subversion repository and build
it yourself.
If you don’t have Subversion installed, install the Subversion command line toolset (or TortoiseSvn
if you have command line fobia).
svn checkout http://ironruby.rubyforge.org/svn/trunk ironruby cd ironruby
Note: checkout means “pull down a copy of the sources to my local machine”. It’s not the same
as checkout in TFS or Visual SourceSafe (which I truly hope you have moved past).
Open a Visual Studio command prompt and cd to where you downloaded the IronRuby sources. Build it:
rake build
When you have completed this step you should be able to run
build\debug\ir.exe
This should give you a new prompt (Interactive IronRuby shell). Just type exit
and hit enter. You have installed IronRuby!
You can now close your Visual Studio command prompt. From here on a regular command prompt
will suffice.
Since IronRuby doesn’t yet know how to install gems you have to install them using MRI:
gem install cucumber ruby gem install rspec
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
with IronRuby.
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 paths).
@ECHO OFF
REM This is to tell IronRuby where to find gems.
SET GEM_PATH=%~dp0..\lib\ruby\gems\1.8
@"C:\scm\ironruby\build\debug\ir.exe" "%~dp0cucumber" %*
Tip: %~dp0 evaluates to “current script’s directory with trailing backslash” in case
you’re wondering what this is.
Now you should be able to run Cucumber:
icucumber --help<code>
Open a command prompt and cd to the Cucumber examples directory for C#. If you have installed MRI to the default
location you’ll find them under C:\ruby\lib\ruby\gems\1.8\gems\cucumber-X.Y.Z\examples
(Replace X.Y.Z with the Cucumber version you installed above)
cd i18n\en
icucumber features
cd cs
icucumber features
There is a deliberate error in the C# code. See if you can fix it!