Quick ‘n dirty Lindo step for Cucumber
Lindo is great for verifying your Rails tests by opening the HTTP response body in a browser for inspection. It works with most popular testing frameworks including Test::Unit and RSpec. But what about Cucumber?
It’s actually pretty easy to build a custom Cucumber step that triggers Lindo from your cukes. First, install the Lindo gem in your Rails app. Then create features/steps/lindo_steps.rb and insert this code:
Then /^render the current page$/ do extend Lindo vr end
The step can be named whatever you like best, but “render the current page” works for me. To trigger Lindo from within your cukes, simply reference the step like so:
Given I am logged in When I follow "some link" Then render the current page
When Cucumber hits the last step, the default browser window will open and the contents of the page at that step in the scenario will be displayed. This is very handy when troubleshooting why a specific scenario is failing. It’s also useful for determining what you should be testing for on a given page.
About Matthew Bass
Matthew Bass is an independent software developer, entrepreneur, speaker, and writer. He has over ten years of experience across a diverse set of technologies and has worked at places like SAS Institute, the world's largest privately held software company. An agilist from the very beginning, he continues evangelizing and experimenting with pair programming, test-first and behavior-driven development, and continuous integration. Matthew has spoken at several regional and national software conferences and regularly writes for publications like InfoQ.
More About Matthew »Why Attend the NFJS Tour?
- » Cutting-Edge Technologies
- » Agile Practices
- » Peer Exchange
Current Topics:
- Languages on the JVM: Scala, Groovy, Clojure
- Enterprise Java
- Core Java, Java 7
- Agility
- Testing: Geb, Spock, Easyb
- REST
- NoSQL: MongoDB, Cassandra
- Hadoop
- Spring 3
- Automation Tools: Git, Hudson, Sonar
- HTML5, Ajax, jQuery, Usability
- Mobile Applications - iPhone and Android
- More...
NFJS, the Magazine
May Issue Now AvailableClient-Side MVC with Spine.js, Part 1
by Craig WallsOn Prototypal Inheritance, Part 2
by Raju GandhiMaking use of Scala Lazy Collections
by Venkat SubramaniamIntegration Testing Web Applications Using Gradle
by Kenneth Kousen


