Introducing the Lindo (response_visualizer) plugin for Rails

Being at RubyConf this weekend has provided the necessary motivation for me to finally release a new Ruby gem I’ve been building. It’s an extraction from a project I’ve been working on for Relevance.

I’m a regular user of assert_select in my functional tests. I find myself frequently doing something like this when the assertion is failing and I can’t figure out why:

def test_something
  post :something
  raise @response.body.inspect
  assert_select "div[id=header]"

Inspecting the response body usually leads me to a solution, but it’s tedious parsing through the huge amount of HTML that gets returned, often in a semi-unreadable format. Enter the response_visualizer plugin (which has since been renamed Lindo):

script/plugin install

Or clone the project directly:

git clone

The plugin provides a vr method to your functional tests. When this method is called, the response body is automatically opened in the default browser allowing for easy visual inspection of the page’s content:

post :new

If you’d prefer to jump straight to the source code, passing the :html symbol will open the formatted HTML in the default text editor:

post :new

This has saved me a lot of time in figuring out why a specific assertion is failing. Instead of parsing through the HTML, I can view the entire page and immediately tell if something is missing or out of place. I find myself calling vr even before I write my assertions now.

After installing, check out the README file for additional documentation. There is also a GitHub project if you’d like to contribute a patch or fork the code. Enjoy!

5 thoughts on “Introducing the Lindo (response_visualizer) plugin for Rails

  1. Pingback: Ruby, Rails, Rails Plugin, JavaScript, CSS, TextMate « exceptionz

  2. Phlip Plumlee has been recommending this technique for any UI development for years — using TDD to show the screen being developed during a test run to avoid having to exercise the whole app every time you want to see the changes you’ve made.

    He calls the method reveal(). Thanks for making a Rails version. I wonder if there could be a way to make Ajax, etc. work?

    And background on the principles he’s working from, which reading I really recommend:

Comments are closed.