Notes posted by avakhov
RSS feed
Require file from the same folder
If you want to require file from the same folder, the simplest way is
require File.expand_path('../file-to-require', __FILE__)
If your file is /lib/book.rb
File.expand_path('../page', '/lib/book.rb') => '/lib/page.rb'

Reverse version of camelize
Reverse version of camelize is underscore

Using custom object via :object
Sometimes you need use select not only with @object as by default. For example if you have helper method like :
def select_parent_for(page) select(:page, :parent_id, Page.all.collect{|p| [p.name, p.id]} ) # <--- mistake! end
In selected line you will use @page instead parameter of method page.
The options has parameter :object (and all form helpers has such parameter)
Solution:
def select_parent_for(page) select(:page, :parent_id, ..., :object => page) end

Small notice about recognize urls with specific HTTP verbs
This is wrong ruby syntax:
assert_recognizes {:controller => 'items', :action => 'create'}, {:path => 'items', :method => :post}
Parentheses are obligatory in this case:
assert_recognizes({:controller => 'items', :action => 'create'}, {:path => 'items', :method => :post})

To find element ant not to find element
If you want to see administration panel:
assert_select "div.admin-panel"
But if you want to NOT see administration panel just write:
assert_no_tag 'div', :attributes => {:class => 'admin-panel'}