2010-06-11
By Ivo Dancet
Tags:

Rails

rSpec

Haml

Rails 3, rSpec 2 and Haml: 2 issues

Rails 3, rSpec 2 and Haml: 2 issues

I lost the better part of this friday evening setting up Rails 3 with rSpec. The solution to these problems may be documented somewhere, but I sure had trouble finding and solving these. Hopefully this information can help you!

issue 1: testing Rails helpers that render Haml

If you need to test Haml with rSpec, make sure you have the following lines in your spec_helper (within Rspec.configure do |config|):

Nothing changed in comparison to rSpec 1 but config.prepend_before, which is now config.before(:each).

issue 2: undefined method `has_tag?'

I allways took the availability of this matcher for granted. Not anymore! To use it in a helper method (which renders a piece of haml in my case), I needed to add another line to Rspecs configure block:

Didn't even know this method is defined in Webrat in the first place. If someone knows a better solution, let me know, but I allready lost an embarrassing amount of time looking into this. Off to bed now …

blog comments powered by Disqus
About
This blog is written by Wouter Vancraeynest and Ivo Dancet and is about what we come across while working at our company by2.be, located in Bruges, Belgium. This can be anything related - though sometimes only remotely - to programming, testing, marketing, Ruby, Apple and other things we do and love ...
Recent posts
Optimizing Vim: tab style
haml-js and jammit
VimRoom
Hudson for a Rails3 project
Looking up Rails(3) routes
Horror story, part II
All tags
Jammit - SaaS - Rails - WriteRoom - Haml - rSpec - Vim - Ruby on Rails - rcov - Cucumber - humans - continuous integration - Hudson - Rails3 - testing - rSquery - haml-js - Bundler - rvm - backbone.js - Selenium
rSquery
Some time ago we made rSquery to be able to easily use jQuery matchers in Selenium projects. You may want to check it out on github. By now this project is not in active development anymore but older projects can still profit from it. (We still use it)