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