Patching tests for Salted Login Generator

It’s odd, but I was having problems with the SaltedLoginGenerator for Rails. I wasn’t able to run the tests at all with rake. I was getting:

/usr/local/bin/ruby -Ilib:test "/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb" "test/unit/entry_test.rb" "test/unit/user_test.rb" "test/unit/localization_test.rb" "test/unit/stencil_test.rb" "test/unit/publisher_test.rb" "test/unit/annolog_test.rb"
/usr/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:74:in `load_specification': undefined method `parse' for Time:Class (NoMethodError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/specification.rb:307:in `date='
...clipped...

and then later on, after a fix (I’ll describe it later), I was getting:

/usr/local/bin/ruby -Ilib:test "/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb" "test/unit/entry_test.rb" "test/unit/user_test.rb" "test/unit/localization_test.rb" "test/unit/stencil_test.rb" "test/unit/publisher_test.rb" "test/unit/annolog_test.rb"
/home/wil/proj/3cgworkspace/annologger/config/../test/mocks/test/time.rb:5: undefined method `cattr_accessor' for Time:Class (NoMethodError)

I think that problem was that I had an older version of rails and ruby, so I’ve updated to both ruby 1.8.4 and rails 1.1.4. And because I didn’t generate rails with the new version, I had to insert these two lines requiring both ‘rubygems’ and ‘time’ into my test_helper.rb under test/, before requiring the environment file in config

ENV["RAILS_ENV"] = "test"
require 'rubygems' # patch to fix undefined 'cattr_accessor'
require 'time' # a patch to fix undefined `parse'

require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'

class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s