You are here: Browse Railsplugins vizres (response_visualizer)
= Response Visualizer
Enables rendering of the body of an HTTP response from inside a functional test. This makes it easy to diagnose problems when building assert_select statements or just sanity check the output of the test.
Installation script/plugin install http://respvisualizer.rubyforge.org/svn/response_visualizer/ UsageInsert the visualize_response method in your functional test immediately after an HTTP request has been sent:
def test_new
post :new
visualize_response
assert_select "div[id=header]"
end
visualize_response attempts to open the response body in the default web browser. If you want to open the raw HTML in the default text editor instead, simply pass the :html symbol to the method:
def test_new
post :new
visualize_response(:html)
...
end
By default, visualize_response looks for an instance variable named @response and calls the #body method on it. If your page body is stored in a different variable, such as when testing a mailer, you can pass the raw HTML directly to visualize_response and it will do the right thing:
def test_mailer
mail = Mailer.create_notification
visualize_response(mail.body)
...
end
If you get tired of typing “visualize_response” everywhere, use the shortcut:
def test_new
post :new
vr
...
end
Note that to use the default web view, your Rails application must be running locally on port 3000. This will ensure that the page renders correctly with the appropriate images and stylesheets. The server doesn’t need to be running if you use the HTML-only view.
Compatibilityresponse_visualizer requires OS X. Subversion must be installed and accessible on the command line. Support for Windows is planned.
Running Unit TestsUse the rake command to run the unit tests for the plugin. The tests require that the Mocha gem be installed locally:
sudo gem install mocha
== Resources
Subversion
Blog
Author
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly
Homepage: http://github.com/pelargir/vizres/
Categories: Consulting, E-Commerce, Technology