Videos of my presentations at #NDC2010 and #QConLondon2010

From NDC2010 – IronRuby – A brave new world for .Net
From NDC2010 – Testing C# and ASP.NET Applications with Ruby
From QCon London 2010 – Testing C# and ASP.NET Applications with Ruby

While QCon and NDC sessions have the same title, QCon was more focused on the why with NDC2010 being more focused on the how. Don’t forget, if you want to know more about Testing there is a (great) book available –

QCon London 2010 – Testing C# and using Ruby

Last week I had the amazing honour of presenting at QCon London 2010 on Testing using Ruby. QCon was an amazing conference with some truly amazing speakers, and I did feel a little out of place 🙂

Nonetheless, it was a great experience. A huge thank you to Josh Graham from HashRocket who organised the track and invited me to speak!

For those who are interested, my slides are below. Within the next six months the video should be online too.

Testing using Ruby – CodeMash session

This week I went over to CodeMash, an amazing community and cross-language conference in the US. I had some amazing conversations, meet some amazing people and gave a session on Testing using Ruby.

I would like to say thank you to everyone who attended and the organisers for giving me the opportunity to speak. If you have any questionscomments, then please give me a shout, Twitter is the best way.

The code I used during the demo can be found on GitHub – 

I created a tag so you can download the zip of the code, now and in the future without being affected by other changes – In future I plan to keep working on this code as a sample so you might want to keep an eye on the repository. 

Also, if you would like to know more about Testing web applications, then I recommend you take a look at the book I co-authored, check out

RSpec, IronRuby and RubyMine

RSpec, IronRuby and RubyMine is an amazing combination. Here is a screenshot of an example I’m currently working on…


All I do is execute the Rake command below, which exists in my rakefile.rb. Rubymine does the rest! Very cool.

desc "Run all examples"'examples') do |t|
  t.spec_files = FileList['examples/**/*.rb']

Dynamic Languages and .NET – Developer Day Scotland slides and code samples

This weekend I was in Glasgow presenting my ‘dynamic languages and .NET’ presentation at DeveloperDay Scotland. I demonstrated how you can take advantage of IronRuby as a language, but also how you could host the DLR within your own application to enhance your feature set. I had a great time and the conference was a great success. A massive thank you to Colin Mackay and the others for organising the event, as well as everyone who attended my session.

Slides can be found below, hosted via SlideShare. Code samples can be downloaded here. Photos can be found here.

I was also involved in the Database Testing panel. Very interesting discussion on how to test databases, thank you to everyone who attend the discussion.

One slight disappointment, Gary Short left before giving his IronSmalltalk grok talk –

Next up, DDD South West.

Embedding IronRuby and the DLR into Red Gate’s SQL Data Generator

Over the past few months there has been a lot of discussions online about how embedding the DLR (Dynamic Language Runtime) into your application opens up some amazing use cases. For example, Phil Haack recently wrote about how MVC views can be stored in the database thanks for the DLR.  Resolver Systems have been doing with with great success.

Tonight, my latest article for Simple Talk was published. The article explains how I went about creating a new generator for SQL Data Generator which allows the user to define the data to be generated based on IronRuby code.  I think this is an amazing use case, both for SQL Data Generator and the DLRIronRuby. By taking advantage of the DLR, we have opened up some extremely useful use-cases within the application. To find out more take a look at the article on Simple Talk.

An example of the generator in action is shown in the screenshot.


The article includes the source code and binaries for the SQL Data Generator example generator which you can start using within your project.

NOTE: This Plug-in generator is provided ‘as-is’ and is completely unsupported.

MSDN Magazine: Getting Started With IronRuby And RSpec, Part 1


My latest article has been published in this months MSDN Magazine. The article is an introduction to IronRuby, finishing with an initial focus on how you can use RSpec and IronRuby together to test C# applications. 

Using IronRuby to test C# applications is an interesting concept and I look forward to seeing how people use the two technologies in the future.


I’m really pleased to have been published within the magazine. I have been reading it since I started with .Net so it feels a little strange to know that I’m actually one of the authors…

I still need to get my hands on a physical copy.

Read it here:

Keep an eye out for part 2 in next months edition.

IronTwitter – Sending a tweet from the IronRuby REPL

In my previous post, I discussed how to parse XML from a REST service. As it happens, the REST service I was interested in was the Twitter API. My aim was to use IronRuby to update my Twitter status from the REPL (Read-eval-print loop) – the interactive console. The result is IronTwitter 🙂

While I’m no expert on REST, I understand that you simply ping a URL with a correctly formed URL and process the response in the correct format (xml, json etc).

One of the great things about IronRuby is the REPL, this is the ir.exe console application and allows you to interact with the language and .net at runtime, they are very simple – type a line, hit enter and the line is executed.  They are great for executing quick lines of code, or learning how do a task in the language. I used the REPL a lot while creating the XML parser as I could easily modify the code dynamically to see if something worked as I expected.

Interacting with IronTwitter

Interacting with IronTwitter is very easy. First you need to reference the library.

require ‘IronTwitter’

You then need to construct the object, providing your username and password

@twitter = ‘username’, ‘password’

The IronTwitter object has a method called update which has a parameter for your new status. Under the covers, it calls the API and updates your status. However, in order to make this easier to type, I added an alias for the method called t. To update your status, you simply type.

@twitter.t “Hello from IronTwitter!”

This will send a request to ‘ from IronTwitter!’ and your twitter status will be updated.

We can now start taking advantage of IronRuby and we can start constructing tweets dynamically!  For example, if we had a method which counted all the files and directories, we could tweet the result.

def count(dir)
   num = 1
   Dir[dir + ‘/*’].each do |d|
     if File.file? d
       num = num + 1
       num = num + count(d)
   return num

All we would need to do is call the method and join the response onto the string argument for the method.

twitter.t ‘The number of files currently in %TEMP% is ‘ + count(‘C:/Users/BENHAL~1/AppData/Local/Temp’).to_s

While this isn’t the most interesting tweet, it’s an interesting concept. You can see my various test tweets at, note my main twitter account is


After being able to send a tweet, I wanted to see how to process the response. The API has a FriendsTimeline method, this will return the timeline you see on your twitter homepage, the tweets of you and the people your following. Using my xml wrapper, when you call the method friends_timeline, you then use a block to process each status, which is a monkey patched XmlElement object from the Xml Parser I created.

>>> @twitter.friends_timeline {|status| puts status.get(‘text’)}
Hello from IronTwitter!

Under the covers of IronTwitter

While that is very interesting, what happens under the covers is more relevant. When dealing with the API, there are two important items, the first is the url, the second is the options. For update, I send a request to ‘statuses/update.xml’ with a parameter status containing my message.

def update(msg)
  url = “”
  options = { :status => msg }
  send_request url, options
alias :t :update

This is then passed into my send_request method, this uses the WebRequest object from System.Net to send the correctly formatted request.

def send_request(url, options)
  requestUrl = convert url, options
  request = WebRequest.Create(requestUrl)
  request.Method = “POST”;
  request.ContentLength = 0;
  request.UserAgent = “IronTwitter”
  request.Credentials =, @password)

  @response = request.GetResponse

The URL which is requested looks like this. As we use HTTPAuth, your status is updated. from IronTwitter!

A similar approach is taken when it comes to the friends timeline.  First, I’ve used an optional parameter so you can define the limit of statuses returned – by default it is 20. The method then takes a block, this is used to process the request.  If a block is not provided, I raise an exception. I then use the Xml Parser I created to start processing the xml response.

def friends_timeline(tweetCount=20, &b) 
  url = “”
  options = { :count => tweetCount }
  send_request url, options

  readStream =
  doc =
  if block_given?
    doc.elements(‘statuses/status’) do |status| status
    raise ‘Block required for processing statuses’

From the calling code, I simply access the elements on the node and output them to the screen.

twitter.friends_timeline do |status|
      status.node(‘user’) {|u| print u.get(‘name’) }
      print ‘    ‘
      puts status.get(‘text’)

The name and the status of the user is then sent to the console, the result being this:

E:IronTwitter>ir sample.rb
Ben Hall    This is a test tweet

Download the code and sample from here. I’ve also uploaded the code to the MSDN Code Gallery

Technorati Tags: ,