Adventures with Ruby

Cover art

View Comments

I haven’t forgotten you all, it just has been a very busy few weeks, and it will stay that way for the moment. Next month and a half I’ll be spending finishing up a nice big Ruby on Rails application, currently having over 2500 lines of code (LOC of course) and 2000 lines of test code, doing a thousand assertions. I’ll keep you posted on that one.

I am finally done re-ordering my music. Having 10,000 songs is a lot, and having to add cover art, proper release years and genres is a pain in the ass. It took me a bunch of weekends but the result is nice… (thank you MediaMonkey)

Album art for Iron MaidenAlbum art for artists (spot the pirate)

Now getting it on my iPod was an interesting challenge. My iPod should be big enough to contain it all, but WinAmp fucked it all up. Using the sync button it put more than one copy of a song on my iPod and when it had only 16KB free space, it couldn’t story the database, so all my songs were orphaned. Then it couldn’t find my iPod anymore, so I had to use up to 4 different applications. But luckily I didn’t have to install iTunes to get it fixed. Read the rest of this entry »

Written by Iain Hecker

January 16th, 2008 at 1:02 am

Posted in Uncategorized

Plain Text Stories and Vim

View Comments

Update: Updated the syntax file, redownload it if you got it before December 19th 2007.

More news about my adventures with Selenium. It’s hot and juicy, so lot’s of exciting new things to do. I made a syntax highlighter for plain text stories in vim. Here’s how it looks:

An example of vim with plain text story highlighting

To make it look like this, I adjusted the slate colorscheme and added my own story syntax file. Click Continue Reading to download the files and read how to install it.
Read the rest of this entry »

Written by Iain Hecker

December 18th, 2007 at 2:46 pm

Posted in Uncategorized

Selenium clicking a label

View Comments

Story: Selenium clicking a label

As a developer
I wanted to make acceptence tests
So I installed

  Scenario: I am making some acceptance tests for the LevenAls website, using plain text stories from David Chelimsky together with the Selenium runner from Kerry Buckley
    When I wanted to make the stories as clean as possible
    And I wanted to click a rails generated radiobutton
    Then the story became ugly
    And it had lines like 'the user clicks a customer_gender_m button'

  Scenario: I made a step for labels, getting the text
    When I wanted to get rid of it
    And I couldn't find an easy answer
    And I spent the better part of my evening googling it
    Then I made a post on the Selenium forum
    And asked for advice

  Scenario: I found a solution myself
    When I was sitting in the train
    And I was trying all kinds of solutions
    Then I stumbled upon the solution
    And I was overjoyed
    And it was: $selenium.click("//label[text()='#{label}']")

So here is the entire step:

When "the user clicks on a $element labelled $label" do |element, label|
  $selenium.click "//label[text()='#{label}']"
end

Written by Iain Hecker

December 18th, 2007 at 9:55 am

Posted in Uncategorized

The Agile Grail and the Knights Templater

View Comments

I’ve been working on a very rapid implemented website with Rails this week. It has been an exiting week. It all started on a Monday, when I overslept, and my colleague (Arie) smiled at me and said: “You’ll be working with me this week”. I liked the idea. Since we started working there we both worked on our own Rails projects, but never together. He continued: “You know the Leven Als website? It’s deadline has been changed… to this week, preferably to yesterday!” That certainly was a challenge. I knew that the functional and graphical designers had been working on it for quite some time, but I’ve never heard of it ever coming to the implementation phase. Three quarters of the HTML were done and we had 4 days to start a Ruby project from scratch and make it. Read the rest of this entry »

Written by Iain Hecker

December 14th, 2007 at 2:51 pm

Posted in Uncategorized

Rcov all the way

View Comments

I installed the rails_rcov plugin to see the coverage like any good programmer ;-) But when I want to know what all the tests combined produce in coverage, it just produced the coverage reports of each individual test (units, functionals and integration) and replacing each with one another. I am not a briliant googler, and when I couldn’t find the answer in time, I decided to make my own rake task for it. Here it is:

namespace :test do
  desc "Run all tests at once through rcov."
  task :rcov do
    test_files = FileList['test/**/*_test.rb']
    output_dir = File.expand_path("./coverage/all/")
    command = "rcov -o \"#{output_dir}\" --rails --sort=coverage -T -x \"gems/*,rcov*,lib/*\" \"#{test_files.join('" "')}\""
    puts command
    puts `#{command}`
    puts "View all results at <file://#{output_dir}/index.html>"
  end
end

Now, it doesn’t take any argument yet, but it works quite all right.

Written by Iain Hecker

December 10th, 2007 at 9:12 pm

Posted in Uncategorized

Fork me on GitHub