Mystery Article

Posted by Rick DeNatale Mon, 23 Jul 2007 00:59:06 GMT

If you subscribe to my feed, you might have noticed a mysterious "Testing Testing" article today.

I was trying a desktop blogging client called BloGTK, and it doesn't appear to honor the checkbox in the UI which is suppose to prevent actually posting an article.

Posted in  | no comments | no trackbacks

How Fast Can You Make YOUR Rails App Go?

Posted by Rick DeNatale Fri, 20 Jul 2007 02:49:00 GMT

Charlie Savage just posted a long article about how he reduced the rendering time on his rails app by an order of magnitude.

The article is full of advice on what to do and not to do in coding rails apps. The important message though is the approach to performance tuning by profiling.

t

Posted in  | Tags  | no comments | no trackbacks

Do You Ever Have Those Kind of Days?

Posted by Rick DeNatale Thu, 19 Jul 2007 18:19:00 GMT

Yesterday I wrote about some code I wrote to control what Time.now and Date.today return to support time-dependent testing.

This afternoon I discovered a critical, but easy to fix bug. I’ve updated the original article.

The good news is that the testcase for the time machine now has another test!

Posted in  | Tags , ,  | no comments | no trackbacks

Time Flies While You're Having Fun Testing

Posted by Rick DeNatale Wed, 18 Jul 2007 19:45:00 GMT

I’ve been working on adding support for localization of the user’s time zone on an existing Rails app for a client. In order to test this, I found myself building a time machine.

At first, I did a fairly simple hack which monkey patched the system methods Time.now, and Date.today. This worked until I got into some testcases of code which was triggered off of updated_at fields in various ActiveRecord models. Since I had to deal with these implicit dates, I found that I needed to have finer control than my simple patch gave.

The code has now evolved to the point where I think that it shows some interesting aspects of basic Ruby metaprogramming.

Read more...

Posted in ,  | Tags ,  | 1 comment | 1 trackback

Most People Don't Like Working Without a Net

Posted by Rick DeNatale Wed, 18 Jul 2007 01:51:00 GMT

Good article about a basic principle of UI goodness by Jef Raskin’s son Aza.
Have you ever had that sinking feeling when you realize—just a split second too late—that you shouldn’t have clicked “Okay” in the “Are you sure you want to quit?” dialog?

Posted in ,  | Tags  | no comments | no trackbacks

Tracking Down Missing Fixtures

Posted by Rick DeNatale Tue, 17 Jul 2007 17:50:00 GMT

The other day I wrote about problems with undeclared fixtures in Rails ActiveRecord tests.

Here’s a little code snippet which might be useful in tracking down such problems. Read more...

Posted in  | Tags ,  | no comments | no trackbacks

Qui ipso probo probatur?

Posted by Rick DeNatale Sat, 14 Jul 2007 19:28:00 GMT

The other day I was working on adding support for user selected time-zones to an existing rails app for a client. As usual I was doing test-first development. One of the things that makes rails such a pleasure is that a good set of tests give confidence that you aren’t breaking “legacy” code.

I also use, and really like, the rails plugin for vim which does lots of nice things like making navigation between the files of rails apps much easier. It also has a nice feature which adds a :Rake command to vim which “does the right” thing contextually. For example if you are editing a migration and enter :Rake, it runs rake db:migrate. If you are in a test file it runs just the single test selected by the cursor, or just that test file if you aren’t positioned to a particular test.

I was doing the latter, and my test was failing, and I was having a hard time debugging it. I tried executing just that single test from the bash command line with:

$ruby test/unit/my_test.rb -n"test_mytest"
and it still failed, no surprise. The same thing happened if I ran the entire test file, in fact, other tests which had worked before were now failing, and I was really mystified now because I didn’t see how I had done anything which had a remote chance of breaking those.

So I figured I probably should test everthing so:

$rake test

And, surprise of surprises, but every test worked. Not only my failing unit tests, but the functional and integration tests as well.

To make a long story short, the problem turned out to be that the tests were failing because, now that the particular model was sensitive to the user’s timezone, it needed access to it’s associated user model, and I hadn’t told the testcase that the users fixture was needed. Running the testcase in isolation, the users table wasn’t being populated for the test case. But running rake test, or rake test:units meant that other tests run before had left the data I needed behind.

Just a little thing that makes fixtures less than ideal.

Posted in ,  | Tags , ,  | no comments | no trackbacks

Active Record and Referential Integrity

Posted by Rick DeNatale Sat, 14 Jul 2007 19:10:00 GMT

Josh Susser just posted a new Rails plugin which adds a validates_existence_of method to ActiveRecord::Base.. The idea is that beyond validates_presence_of, which simply checks that a foreign key field is non-nil, or validates_associated which validates the model referenced by a foreign key, validate_existence ensures that the referenced model exists in the database, no more no less.

It’s brand new, but it sure looks like a nice idea.

Posted in  | Tags ,  | no comments | no trackbacks

The other Dave Thomas and the Birth of the Agile Alliance

Posted by Rick DeNatale Mon, 09 Jul 2007 17:17:00 GMT

“Uncle Bob” Martin of Object Mentor just published an article containing his personal recollection of how the

... Dave Thomas of OTI fame. (We call him “Big Dave” to differentiate him from the Pragmatic Programmer of the same name.)
Agile Alliance got started and the writing of the “Agile Manifesto”

He gives a bit more background than has previously been told. Of particular interest to me is the role of “Big Dave” Thomas, the founder of OTI in kick-starting the organization.

“Big Dave,” not to be confused with Dave Thomas of the Pragmatic Programmers, has been one of the movers and shakers of the object-oriented technology community for many years, and doesn’t always get the credit he deserves, particularly now that he has “retired” to the Carribean island of Anguilla. He might not be as visible now as he was in the heyday of OTI, but he’s still active. Had Anguilla been easier to reach, the Agile Manifesto would have been written at Dave’s place instead of in Utah.

I’m proud of my experiences working with and for “Big Dave” and to count him as a friend.

Posted in  | Tags , ,  | 1 comment | no trackbacks

Rails rake_freeze_other_gems

Posted by Rick DeNatale Mon, 02 Jul 2007 15:36:00 GMT

I’m working on a team rails project and adding some timezone support. I installed the tzinfo gem and, since I want to make sure that it gets to the production server, I used the freeze_other_gems rake task, which I’d found by doing a rake -T.

I’d never used it before so I googled to find some documentation. It wasn’t exactly clear, but it turns out that you need to edit the fourth line of the lib/tasks/gems.rake file

libraries = %w(progressbar tzinfo)

The progressbar gem was already there so I added tzinfo.

Then I invoked:

$ rake freeze_other_gems

Only to get the error:

rake aborted! undefined method `version’ for nil:NilClass

This problem had been seen by others and commented on. I guessed that the problem was not with my newly added gem, but the progressbar gem which was already listed, apparently by one of the other developers.

The Quick Fix

The first step was to determine the version of the progressbar gem. I looked at lib where it had been installed, and found that it was version 0.3. I then installed the gem, and reran the freeze_other_gems rake task.

Success

Posted in  | Tags , ,  | no comments | no trackbacks

Older posts: 1 2