In Rails, how do you functional test a Javascript response format?
Posted
by Teflon Ted
on Stack Overflow
See other posts from Stack Overflow
or by Teflon Ted
Published on 2010-03-01T18:49:23Z
Indexed on
2010/06/12
6:33 UTC
Read the original article
Hit count: 207
If your controller action looks like this:
respond_to do |format|
format.html { raise 'Unsupported' }
format.js # index.js.erb
end
and your functional test looks like this:
test "javascript response..." do
get :index
end
it will execute the HTML branch of the respond_to block.
If you try this:
test "javascript response..." do
get 'index.js'
end
it executes the view (index.js.erb) withOUT running the controller action!
© Stack Overflow or respective owner