Skip to content

Instantly share code, notes, and snippets.

@burningTyger
Created October 15, 2011 09:11
Show Gist options
  • Save burningTyger/1289312 to your computer and use it in GitHub Desktop.
Save burningTyger/1289312 to your computer and use it in GitHub Desktop.
Rubinius: Fixing a failing spec for 1.9 mode. A simple introduction.

Last week I decided to fix some failing specs for Rubinius 1.9 mode. If you haven't done that before continue reading you will be surprised how easy that can be.

To get started you need a working clone of Rubinius. You can find instructions in the docs.

Now let's see what specs are failing. I consult the failing tags which can be found in:

rubinius/spec/tags/19/ruby/core

There are many specs still failing so I go through some and find something interesting in:

spec/tags/19/ruby/core/time/to_s_tags.txt

the specs sound easy enough:

fails:Time.to_s formats the time following the pattern 'yyyy-MM-dd HH:mm:ss Z' 	
fails:Time.to_s formats the UTC time following the pattern 'yyyy-MM-dd HH:mm:ss UTC'

As far as I can see all that is required to fix these specs is setting a different strftime. So I start moving things around a bit.

Ever since Ruby 1.9 mode was introduced to Rubinius all classes can be loaded in either this or that mode but require some set up. While in the original Rubinius 1.8 mode there were only files like time.rb to be found there are now a set of new files like time18.rb or time19.rb. As you can guess they have a purpose. During the bootstrapping process, which is described elsewhere in more detail, the load_order files are read which tell Rubinius which files have to be loaded for which mode. So we need to move some old code from the original time.rb file to its new home in time18.rb and create a new Time#to_s method in time19.rb which will make the 1.9 specs pass. It is as simple as it sounds.

  • create time18.rb and time19.rb files
  • add time18.rbc to load_order18.txt
  • add time19.rbc to load_order19.txt
  • move Time#to_s from time.rb to time18.rb
  • create a new Time#to_s method in time19.rb that will pass the tests
  • rake and check the specs.
  • run the Time#to_s specs in both modes
  • commit to git
  • delete the tags for failing specs and make a second commit

See the commits I made:

fix Time#to_s failing spec for 1.9

remove spec tags for Time#to_s in 1.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment