Testing binary downloads with Webrat

I’m using Webrat to keep some sanity when approaching maintenance of new application. Customers often come to me with legacy code, which somehow is not covered by tests. In such case integration tests are way to go, since they provide most bang of Yours bucks – each written test could cover many parts of application. […]

Are ActiveRecord validations worth anything?

ActiveRecord, which is core component of Rails framework (at least before Rails 3.0 become reality) provides a lot features which developers do love. Validations are one of those features. They are methods which provide easy way to check if model is valid and protect consistency our data in database. Sounds good, but this is bullshit. […]

Paperclip, passenger and “not recognized by the ‘identify’ command”

If You do use awesome :) Paperclip library, and on application served by Passenger You get errors like: Avatar /tmp/stream.1170.0 is not recognized by the ‘identify’ command. most probably Passenger does not have setup environment and is missing a path. On FreeBSD identify is placed in /usr/local/bin and AFAIR this path is not included by […]

Associations and to_json on collections of objects

ActiveRecord’s Serialization module does provide to_json method. It allows include associations when dumping to JSON, but it works only for single objects. If You want to run it against collection, returned by find :all You will get: >> Model.all.to_json :include =>:association TypeError: wrong argument type Hash (expected Data) from (irb):13:in `to_json’ from (irb):13 If You […]