Being new to rails and ruby, I am trying to figure out how things fit
together. In particular i am trying to understand how attributes such
as “session” and “cookies” are made available to Controller tests.
Specifically I am working on a test from the RailsSpace book which
extends Test::Unit::TestCase and only imports the module
ApplicationHelper while attributes such as cookies and session are
defined within the ActionController::TestProcess module. I cannot
figure out how module ActionController::TestProcess is included within
the UserControllerTest.
Makes sense. My only confusion is I thought that in ruby methods and
attributes can be imported to a class either through inheritance or
importing a module. In this case, these extra attributes such as
“session”
or “cookies” do not exist within the parent class nor the imported
module.
Is rails including extra modules within my classes at runtime?
Thanks for your help!
Being new to rails and ruby, I am trying to figure out how things fit
together. In particular i am trying to understand how attributes such
as “session” and “cookies” are made available to Controller tests.
Specifically I am working on a test from the RailsSpace book which
extends Test::Unit::TestCase and only imports the module
ApplicationHelper while attributes such as cookies and session are
defined within the ActionController::TestProcess module. I cannot
figure out how module ActionController::TestProcess is included within
the UserControllerTest.
The test_helper file that you require at the top of your test file in
turn requires a bunch of stuff, in particular a file that adds those
methods to test cases.
Makes sense. My only confusion is I thought that in ruby methods and
attributes can be imported to a class either through inheritance or
importing a module. In this case, these extra attributes such as “session”
or “cookies” do not exist within the parent class nor the imported module.
Is rails including extra modules within my classes at runtime?
Thanks for your help!
You can also just reopen a class and add methods to it. if my memory
is correct that is what rails does to Test::Unit::TestCase.
Fred
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.