In a book I’m reading the author tries to do the following from within
his controller test file:
class PagesControllerTest < ActionController::TestCase
assert_select “a[href=?]”, url_for(:action => :new), :text => ‘Neue
However the method ‘url_for’ is unknown within the class
PagesControllerTest, as it is defined in ActionController::Base.
To get around this he writes (although this is not the final solution):
assert_select “a[href=?]”, @controller.url_for(:action => :new,
:only_path => true), :text => ‘Neue Seite’
How is he able to reference a method defined in another class, simply by
prefixing the method call with ‘@controller’
Could someone explain what is ‘@controller’ in this context?
I tried Googling it, but as Google ignores the ‘@’ I couldn’t get very
Thanks in advance