is there any good way to test a controller with rspec? Actually, I’m testing the complete output (including the rendered view) with rack/test.
Take the following minimal controller for example:
MyApp.controllers :cool_controller do
get :index do
some_var = DateTime.now
render 'some_view', :locals => { :dont_know => nil, :some_var => some_var }
end
end
What would be the best option to test, that the values in the locals hash are like I expect them to be?
For this case, it seems you want to test:
a) DateTime.now gives you a valid value – test that directly using classical rspec.
b) the var some_var is passed to render, but that is trivial.
It sounds like you might actually want to test the view in isolation. Somthing like this (untested):