RspecAbandoner version 0.1 has been released!

Posted by mig on June 13, 2008

This is a script, that when run inside of your project, will convert your RSpec specs to Test::Unit tests.

It still needs some serious work, right now it creates a bunch of obnoxious files in your spec directories, I will change that soon.

I borrowed code from spec_converter and inspiration from Barbara Boxer

Changes:

  1. 0.1 / 2008-06-13
  • Initial release

Installing Ruby 1.8.7 on Leopard (Mac OS X 10.5)

Posted by mig on June 11, 2008

The new ruby has some interesting new features, and I am hot to try them out. I’ve got Leopard installed, which comes with ruby 1.8.6, so I guess we could replace that. However, it’s generally a good idea to leave that stuff be.

So, I am going to installed it somewhere else. The ruby that comes with Leopard is installed in /usr/bin

  which ruby

I am going to put my new 1.8.7 in /usr/local/bin

First I downloaded it: ruby-1.8.7.tar.gz

Then, I opened up my terminal and:

  mv ~/Downloads/ruby-1.8.7.tar.gz ~/src && cd ~/src
  tar xvzf ruby-1.8.7.tar.gz
  cd ruby-1.8.7
  ./configure --enable-shared --enable-pthread --prefix=/usr/local
  make
  make test
  sudo make install

Make sure /usr/local/bin is at the begining of your PATH environment variable. You can now play around with ruby 1.8.7!  You will most likely want to reinstall rubygems in /usr/local as well.

Using Erubis in Rails

Posted by mig on May 07, 2008

Swapping out ERB for Erubis in a rails application is dead easy:

Install the gem:

  gem i erubis

Require it:

  # config/environment.rb
  require 'erubis/helpers/rails_helper'

Preprocessing is awesome:

  # config/environment.rb
  require 'erubis/helpers/rails_helper'
  Erubis::Helpers::RailsHelper.preprocessing = true

With that, you can use [%= %] inside your views instead of <%= %>. So doing this…

  [%= link_to "New Post", new_article_path %]

…will process the link_to when the template is loaded. However, when it comes time to render, what is being rendered is something more like this:

  <a href="/articles/new">New Post</a>

Which loads a lot faster than the ruby.

You can also preprocess enumerable statements, this is especially useful for something like this:

  [% Category.find(:all).each do |c| %]
    <li>[%= link_to c.name, category_path(c) %]</li>
  [% end %]

Very intense.