Tuesday, December 30, 2008
Recently I added a configuration mechanism to Webrat. It was surprisingly easy, and mainly copied from rails core. I would suggest adding somthing like this to any plugin that has more than a few features or ones that users have asked to have turned off.
First off you’re going to have to create the actual configuration [...]
Monday, December 22, 2008
I just posted my initial cut of my generator_missing plugin. This plugin is meant to be a repository of additional generators to help workflow. The current ones are:
Library: Generates a non active record ruby object and a test class.
lib/library_name.rb
test/unit/library_name_test.rb
Module: Generates a basic module under lib and its tests.
lib/module_name.rb
test/unit/module_name_test.rb, with a mock class that mixes in [...]
Monday, November 24, 2008
I was tired of not having up to date docs for the rails gems and plugins that I use, so I created RDocul.us. Bascially, anyone is free to submit any github based rails plugin or gem and it will be kept up to date on RDocul.us. Once it’s approved it will be automatically updated within [...]
Monday, November 24, 2008
Named scopes are a nice feature that came out in rails 2.1, however, testing them is not very obvious.
Say we have a named scope in our member object which looks like this:
class Member < ActiveRecord::Base
named_scope :active, {:conditions => {:status => Member::STATUS_ACTIVE}}
end
There are 2 things we need to do to test them.
First would [...]
When I was looking for how to test protected an private methods in ruby on the net, I found many sites arguing whether you should, and several methods for doing so. I am of the opinion that if your method contains any logic at all, it should have a test. Some examples of what I [...]
Tuesday, October 14, 2008
Whether you are working on an open source app or an enterprise app, it is a good idea to keep the production database connection information out of source control. To do so, add the following to your deploy.rb file:
task :overwrite_database_yml_file do
run "[ -f /var/rails/#{application}/database.yml ] &amp;amp;amp;amp;&amp;amp;amp;amp; cp -f /var/rails/#{application}/database.yml #{latest_release}/config/ || echo 'database.yml [...]
Tuesday, September 23, 2008
Pretty simple post, but any ruby object can be post conifged in a line with somthing like:
User.new(:name => “tony”){|u| u.save}
which is great for active record tests.
Or in a bigger example:
@trip = Trip.new{|t| t.save!}
@invite1 = Invitation.new(:user => users(:aaron),
[...]
rcov and Rails
I had the good fortune of attending Rails Conf recently on behalf of the consulting company I work for, Asynchrony Solutions. One of the topics at the great Refactotem tutorial (hosted by the guys from Relevance) was rcov, a code coverage tool for Ruby. One of the things I missed in, or was [...]
Get the following rpm’s from oracle
oracle-instantclient-basic-10.2.0.3-1.i386.rpm
oracle-instantclient-devel-10.2.0.3-1.i386.rpm
(Note: this should work fine with the newer versions as well)
As root
cd PATH_TO_RPMS
rpm -ivh oracle-instantclient-basic-10.2.0.3-1.i386.rpm oracle-instantclient-devel-10.2.0.3-1.i386.rpm
echo /usr/lib/oracle/10.2.0.3/client/lib/ > /etc/ld.so.conf.d/oracle-instant-client-i386.conf
This last step, the echo, is a bit of magic. The conf files in /etc/ld.so.conf.d are run before each command is invoked to set your library path. The enviroment variable $LD_LIBRARY_PATH overrides [...]
For the new style changes for confabulus, I made use of the content_for capabilities in rails. The currently has two sections, main and sidebar. content_for makes implementing this quite easy. In your layout file (example application.html.erb under app/views/layouts), you use a to place each of the sctions. Here I used to include my [...]