Archive for category Thoughts
“resource libraries” polemic!
I’ve been off for a while but I’m planning to come back now that I resolved most of my personal and professional life issues that were not letting any time for me to write here.
I’ve been fond of Resource Libraries since I discovered resource_controller devolved by James Golick.
I’ve read some good stuff about ResourceLogic by Ben Johnson (the creator of Authlogic).
More recently emerged Inherited Resources by José Valim that claims to resolve many issues that resource_controller and ResourceLogic had.
I did not have time to study Inherited Resources or even to use it yet, but I suggest that you read the reasons why Ben Johnson decided to discontinue ResourceLogic development.
My personal opinion is: I’ll still use Resource Libraries when it is appropriate. Like everything, you must always ask yourself if it is pertinent to use it for this particular task, piece of code, controller, application, plugin, gem…
Pimp my test on Mac with Growl
Please see this very good tip on how to integrate ZenTest autotest with growl: Pimp You .autotest
Splendid!
TDD on Rails #3 – Fixtures
Yet a little post here… maybe I should gather more information and experience and write bigger post… But that will do for now… I think that in the end, I’ll try to find time to write a big article about TDD on rails, with my whole experience… I’ll just let it documented here.
Next step for my TDD application: using fixtures. Fixtures permit you to populate you database before running some tests. For example, you want to see if your User.find_admin stuff works the way you want, then you’ll just populate your database with a couple of Admin users and check if your method retrieves them from the database correctly.
Rails ships with its out of the box fixtures solution called fixtures. But reading some articles, search through the github projects and learning how the default fixtures implementation works made me realize that it can be a pain… And there is some fixtures replacement, here is a non exhaustive list:
- fixjour
- replacefixtures
- machinist
- object_daddy
- factory_girl
- …
And much more. That disconcerting, so much options. I quickly read the github (if github hosted) readme file and even before reading this prediction I choosed factory_girl because of its simplicity.
What do I mean with simplicity? INHO you should have a good idea of what the plugin/gem/code is doing giving a quick look at the github project home. Fixtures are something quite simple and the fixture replacement should quite simples too. And factory_girl caught my attention excatly because of this: clear, clean, easy to understand and to use.
TDD on Rails #2
In my new app that started as a POC of TDD, I’m going to use Authlogic. And I followed the doc and some post here .
Again, I did lots of behavior thinking without TDD/BDD in mind…. The result was that I was with some controllers and my model created without any test related thing going on…
The thought of the day is: never user ./script/generate [model|controller|...] anymore… use ./script/generate [rspec_controller|rspec_model|...]
Learning Ruby
There is a free and fun way to learn ruby: Why’s (poignant) Guide to Ruby
The book is full of humour and it makes it really easy and entertaining to read without losing the main goal of the book: learning ruby.
Although it is simple to read, on should have really good knowledge and understanding of OOP.
Rfactor: Refactoring for Textmate
For those who are missing refactoring tools in their favorite Text Editor, salvation is coming: Rfactor and its TextMate bundle.
Rfactor is a gem and hopefully there’ll be bundles or plugins for other text editor (Vim, emacs …)
Full Story> Rfactor: Ruby Refactoring for your loved editor
Stay tuned.
Reserved Words!
First thought:
Have a look at the Rails reserved words: Rails Reserved Words
On the page there is reserved words and some that can cause problems. I had a nasty waste of time trying to use resource_controller to create a Template resource. Template is not a reserved word, but you can’t have a Create action for a template controller…