So the other day when I posted about SQLite and Single Table Inheritance, I never did actually get around to writing any tests. Today, I wrote my first test. An easy one, and it exploded all up in my face.
<pre>
5 tests, 5 assertions, 0 failures, 0 errors
rcov.rb:642:in `[]': no implicit conversion from nil to integer (TypeError)
from /usr/local/lib/ruby/gems/1.8/gems/rcov-0.7.0.1/lib/rcov.rb:642:in `aggregate_data'
</pre>
Grr. I keep fussing with various things and nothing works. I take out my test and rcov runs fine, but of course that’s with out any real tests. Oh a hunch, I set up a MySQL database and run my tests there, and they run great. I turn to google, and nothing. I have SWIG installed- or do I? As it turns out I must have skipped installing SWIG on my mac when setting everything up. I uninstall the SQLite3/Ruby gem, build and install SWIG, reinstall the SQLite3/Ruby, and boom. My tests are up and running.
Steps for building and installing SQLite3, SWIG, and SQLite3/Ruby on OS X Tiger if you need them. These assume you’ve already installed the Xcode Tools, and possibly already followed Dan Benjamin’s Guide to install Rails.
Install SQLite3
<pre>
curl -O http://www.sqlite.org/sqlite-3.3.7.tar.gz
tar xzvf sqlite-3.3.7.tar.gz
cd sqlite-3.3.7
./configure --prefix=/usr/local
make
sudo make install
cd ..
</pre>
Install SWIG
SWIG is distributed through SourceForge, so download the latest release (currently, 1.3.29 at the time I’m writing this).
<pre>
tar xzvf swig-1.3.29.tar.gz
cd swig-1.3.29
./configure --prefix=/usr/local
make
sudo make install
cd ..
</pre>
Install SQLite3/Ruby
sudo gem install sqlite3-ruby
Select which gem to install for your platform (i686-darwin8.6.1)
1. sqlite3-ruby 1.1.0 (mswin32)
2. sqlite3-ruby 1.1.0 (ruby)
3. sqlite3-ruby 1.0.1 (mswin32)
4. sqlite3-ruby 1.0.1 (ruby)
...
10. sqlite3-ruby 0.5.0 (ruby)
11. Cancel installation
> 2
Choose the most recent “ruby”; version, in this case I chose “2”;. And that’s it you should be good to go. Some more info about using RCOV with Rails.






