Monday, October 12, 2009

TechMixer University 2009



October 13th, 2009: TechMixer University is a one-day conference in Birmingham AL. This year it had ~500 people attending. I gave the "Getting Started with Ruby" presentation to ~40 people. Almost everyone in the meeting had never seen Ruby before, so this presentation was perfect for them.

This presentation is an update from last year's presentation. The differences are: 1) shortened the Ruby language syntax details 2) Changed the Bonus Slides to "Ruby in Action" and added Cucumber, Sinatra, Rake to this section.

Thanks to all that attended. If anyone needs help getting started, please post questions to the Rubyham message board.

Wednesday, August 19, 2009

Free E-Book: O'Reilly C# 3 Pocket Reference

RedGate is running a marketing campaign where they are giving away O’Reilly’s C# 3 Pocket Reference. You can get it by following this link. The book is available by a download link at the bottom of the page. Kudos to RedGate, especially since you dont have to fill out any forms to get the book.

Thursday, July 16, 2009

IronRuby 0.6 and TofuHash

I took a quick look at IronRuby 0.6 which was release earlier this month. My first test of it was to run the TofuHash gem's unit tests.

Running in MRI (Matt's Ruby Interpreter) the result was:


Loaded suite test-tofuhash
Started
............................................................
Finished in 0.031 seconds.

60 tests, 220 assertions, 0 failures, 0 errors

.

Running in Iron Ruby the result was:


Loaded suite test-tofuhash
Started
...........................F.................F..............
Finished in 2.031315 seconds.

{stack traces for the failed cases removed to keep the output short}

60 tests, 220 assertions, 2 failures, 0 errors

.

The first thing to notice is the execution time difference 0.03 sec vs 2.03; which shows IronRuby still needs work on it's performance. These times are a good improvement over prior versions. Not show here is the start-up time. MRI was practically unnoticable, while IronRuby was noticable at ~5 seconds. The startup time is now fast enough to not be annoying.

The second noticable difference is that two tests failed under IronRuby.

The first was the #invert method. TofuHash doesn't have a custom implementation of #invert because in MRI's Hash #invert makes use of other methods in Hash. In IronRuby, it appears #invert has it's own implementation, so I'll have to give TofuHash a custom #invert to get that test to pass in IronRuby.

The second failed test was with YAML serialization and deserialization. I'll have to dig to find the root cause. Making a roundtrip from TofuHash to YAML and back, IronRuby resulted in a Hash object instead of a TofuHash. Just like the prior error, TofuHash doesn't have a custom implementation for #to_yaml, it just inherits it from Hash. I'm guessing there are differences between the implementations of Hash#to_yaml in MRI and IronRuby that work for Hash but dont work for the subclass TofuHash.

I'll probably wait until IronRuby 1.0 is released before updating TofuHash to correct these two errors. Until then, it appears TofuHash 1.0 will work in IronRuby 0.6 except for #invert and #to_yaml.

Wednesday, June 03, 2009

White - UI Testing Library (.Net)

White is an open source .Net library designed to support Unit Testing of Windows GUIs. I used it for the first time this week. The results were good enough to recommend using it again. The performance was a little slow, so I wouldn't want to have lots of tests. I prefer to avoid UI Unit Tests by separating the presentation from the logic. However, sometimes you need to unit test an interaction. For those cases, White can be useful.

I'm not going to blog an example here. The documentation for White has some examples. See Getting Started.

Wednesday, April 29, 2009

Using Cucumber Testing Framework without Rails

Most of the articles for Cucumber are given as Rails examples. While Cucumber was born for Rails testing, it isn't limited to that environment. A few simple steps will allow you to use Cucumber with any Ruby project.

This example will use Rake to run cucumber because the Cucumber::Rake::Task does a lot of work for you. It will automatically load (require) the features and steps for you.

First, you should follow Cucumber's pattern for directories:




{project home}/featuresstores all the .feature files
{project home}/features/step_definitionsstores the .rb files containing steps
{project home}/features/supportcontains the env.rb file


First create a rakefile for your project and add a Cucumber::Rake::Task as follows...



Next create the features file(s). The rake task will automatically require all the .feature files in the features directory. This example reproduces the additions.feature shown on Cucumber's homepage.



At this time, you may run "rake features" to see Cucumber runs. The results will show that 4 steps are undefined. To define the steps create features\step_definitions\addition_steps.rb. The rake task will automatically require all the step_definitions files.



This example uses a class Calculator from my project. So lets define that class under lib\calculator.rb.



This calculator isn't very exciting. It just uses a stack to remember values. The first item in the stack is the "screen". The add method will add the top two values. This is the bare minimum needed to meet the defined feature. (Normally you would define the class and fill in the details in a test-first fashion. But to keep this article short, I've posted the completed class.)

The rake features task doesn't automatically require the calculator.rb file. Also, if you noticed the addition_steps.rb makes use of rspec expectations, which isn't available by default. To require these files, create the features/support/env.rb file. The rake features task will automatically require any file under features/support



Now when you run "rake features" everything will work together. Your steps should all run and pass with green color!

Saturday, April 04, 2009

TofuHash is done!

I've released TofuHash v1.0 which supports the entire Hash interface for both Ruby 1.8.x and Ruby 1.9.1.

On Monday April 6, I'll be presenting a lightning talk on TofuHash to Rubyham. The talk will mostly cover the ruby 1.9.1 issues encountered.

Thursday, March 12, 2009

TofuHash is now a ruby gem.

I've released v0.1.0 as a ruby gem. The documentation is online at http://tofuhash.rubyforge.org/

To install it, simply use:

gem install tofuhash

Tuesday, February 03, 2009

wordle.net



I found wordle.net which can generate word clouds from text, blogs, etc. Just for fun, I created one from my blog.