Today I wrote some IronRuby tests targetting C# code (using both MSpec and the bundled Test::Unit). Things went out absolutely well.
While I won’t share the code in question yet, here’s a working example provided by John Lam on his blog a while back. This morning I decided I would start running it myself, to see how it goes. You’ll have to git clone MSpec under the gems folder to get it working.
$LOAD_PATH << File.dirname(__FILE__) + "/gems/mspec/lib"
require 'mspec'
require 'mscorlib'
include System::Collections
describe ".Net Stack" do
it "creates an instance with zero elements" do
Stack.new.count.should == 0
end
it "contains one element after push" do
s = Stack.new
s.push "bob"
s.count.should == 1
end
it "let us peek the element pushed" do
s = Stack.new
s.push "bob"
s.peek.should == "bb"
s.count.should == 1
end
end
Notice how it mixes IronRuby code with the Stack CLR class.
My belief is that IronRuby and IronPython are going to deeply change the way people work with .Net.
I have the same feeling I had in 2001, when I started using C#. That feeling was: C++ is going to be used at the driver/infrastructure level, and most application code will move away to C#. Today it’s very clear to me that the same thing is going to happen: IronRuby or IronPython will be used for most of the daily code, while C# will gradually serve as an infrastructure.
As well my feeling is that given the dynamic nature of Ruby, a lot of the features of MbUnit or NUnit (such as combinatorial tests or row tests, see here for instance) are going to be easy to reproduce by yourself, as you need it.
Here’s an imaginary example so you get the idea:
$LOAD_PATH << File.dirname(__FILE__) + "/gems/mspec/lib"
require 'mspec'
describe "SupaComputa" do
(1..400).each do |value|
it "computes 2^#{value} without blowing" do
SupaComputa.new.pow(2,value)
end
end
end
It doesn’t remove the need for testing frameworks like MbUnit of course, but this is definitely going to change the way we test.
If you made it to the end of this post, be sure to check out John Lam’s talk at RubyConf 2008 (should be embedded below as well).
The comments system is brand new - don't be afraid to comment!
- Monitoring File Changes and Getting Notified via Growl (February 14th, 2010)
- How to use Google Calendar and Rufus-Google for Basic Time Tracking (November 27th, 2009)
- Using JRuby to prototype VST plugins (November 17th, 2009)
- Introducing Learnivore.com (September 15th, 2009)
- How to create small, unique tokens in Ruby (July 2nd, 2009)
- Detecting Which Ruby Interpreter is Running (JRuby, IronRuby) (March 4th, 2009)
- How to create an empty Rails Edge application (January 28th, 2009)
- How to Freeze Gems with Rails >= 2.1 (December 23rd, 2008)
- How to Retrieve Delicious Tags and Number of Bookmarks for a Given Url (November 30th, 2008)
- Fixing Symbol not found _rl_filename_completion_function (November 6th, 2008)
- How to Generate a Gradient for your CSS using RMagick (October 21st, 2008)
- Analyzing Your GMail History (September 18th, 2008)
- Data Visualization with Ruby and RMagick - Where Are Those Bikes ? (March 31st, 2008)
- All-Time Classics: a Selection of Recommended Books for Software Developers (February 23rd, 2008)

