<?xml version='1.0' encoding='utf-8' ?>
<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'>
  <channel>
    <title>Wolfmans Howlings: Using RSpec to test HAML helpers</title>
    <link>http://blog.wolfman.com/articles/2007/7/14/using-rspec-to-test-haml-helpers</link>
    <description>A programmers Blog about Ruby, Rails and a few other issue</description>
    <language>en-us</language>
    <ttl>40</ttl>
    <item>
      <title>Using RSpec to test HAML helpers</title>
      <description>
        &lt;p&gt;&lt;em&gt;UPDATED&lt;/em&gt; for HAML 2.0 and RSpec 1.1.5 - Changed open to haml_tag, prefix helper. to all rspec calls...&lt;/p&gt;
        
        &lt;p&gt;The most recent release of &lt;a href=&quot;http://haml.hamptoncatlin.com/&quot;&gt;HAML&lt;/a&gt;
        introduced a neat feature that allows you to use HAML-like syntax in
        your helpers to generate HTML
        &lt;a href=&quot;http://haml.hamptoncatlin.com/docs/rdoc/classes/Haml/Helpers.html#M000019&quot;&gt;HAML#haml_tag&lt;/a&gt;.&lt;/p&gt;
        
        &lt;p&gt;A question on the HAML news group asked how to test a helper that uses
        HAML#haml_tag (used to be open/puts) and thanks to Nathan on that
        &lt;a href=&quot;http://groups.google.com/group/haml/browse_thread/thread/e2c6cba548a4eb00/4e3ac1007485e902#4e3ac1007485e902&quot;&gt;list&lt;/a&gt;
        I finally got RSpec to do it. As shown below.&lt;/p&gt;
        
        &lt;p&gt;However a really good point was made that really in RSpec the way to
        test anything is to use mocks to mock any call to an outside method
        thus focusing the test on the specific module under test.
        Generally I agree with that philosophy. But this is way cool so I
        thought I'd do it anyway, and also as it is a new feature in HAML one
        may not want to simply trust HAML to generate the correct HTML.&lt;/p&gt;
        
        &lt;p&gt;So in my application_helper.rb I have a simple helper...&lt;/p&gt;
        
        &lt;pre&gt;&lt;span class=&quot;keyword&quot;&gt;module &lt;/span&gt;&lt;span class=&quot;module&quot;&gt;ApplicationHelper&lt;/span&gt;
        
         &lt;span class=&quot;punct&quot;&gt;...&lt;/span&gt;
        
          &lt;span class=&quot;keyword&quot;&gt;def &lt;/span&gt;&lt;span class=&quot;method&quot;&gt;display_flash&lt;/span&gt;
            &lt;span class=&quot;keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:notice&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:warning&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:error&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;]&lt;/span&gt;
              &lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;flash&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;]&lt;/span&gt;
                &lt;span class=&quot;ident&quot;&gt;haml_tag&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:div&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;flash&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:class&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;}&lt;/span&gt;
              &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
            &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
            &lt;span class=&quot;constant&quot;&gt;nil&lt;/span&gt;
          &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
        
          &lt;span class=&quot;punct&quot;&gt;...&lt;/span&gt;
        
        &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
        &lt;/pre&gt;
        
        &lt;p&gt;This is called in my views as...&lt;/p&gt;
        
        &lt;pre&gt;&lt;code&gt;- display_flash
        &lt;/code&gt;&lt;/pre&gt;
        
        &lt;p&gt;Notice the - instead of =, this is because the open (and puts) write
        output directly to the HAML buffer, and so this routine should return
        nothing. (This is also a very simply case and does not show off the
        utility of the open/puts methods, I'll show one of those later on).&lt;/p&gt;
        
        &lt;p&gt;The RSpec helper test that tests this is as follows...&lt;/p&gt;
        
        &lt;pre&gt;&lt;span class=&quot;comment&quot;&gt;# File: spec/helpers/application_helper_spec.rb&lt;/span&gt;
        &lt;span class=&quot;ident&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;dirname&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant&quot;&gt;__FILE__&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;/../spec_helper&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;'&lt;/span&gt;
        
        &lt;span class=&quot;ident&quot;&gt;describe&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;ApplicationHelper&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;do&lt;/span&gt;
        
          &lt;span class=&quot;ident&quot;&gt;before&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:each&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;do&lt;/span&gt;
            &lt;span class=&quot;ident&quot;&gt;helper&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;extend&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;Haml&lt;/span&gt;
            &lt;span class=&quot;ident&quot;&gt;helper&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;extend&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;Haml&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;constant&quot;&gt;Helpers&lt;/span&gt; 
            &lt;span class=&quot;ident&quot;&gt;helper&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;send&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:init_haml_helpers&lt;/span&gt;
          &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
        
          &lt;span class=&quot;ident&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;should display flash&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;do&lt;/span&gt;
            &lt;span class=&quot;keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:notice&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:warning&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:error&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;]&lt;/span&gt;
              &lt;span class=&quot;ident&quot;&gt;flash&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;]=&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;flash &lt;span class=&quot;expr&quot;&gt;#{name.to_s}&lt;/span&gt; message&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;
              &lt;span class=&quot;ident&quot;&gt;helper&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;capture_haml&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;ident&quot;&gt;helper&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;display_flash&lt;/span&gt;
              &lt;span class=&quot;punct&quot;&gt;}.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;should&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=~&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;regex&quot;&gt;&amp;lt;div class='&lt;span class=&quot;expr&quot;&gt;#{name.to_s}&lt;/span&gt;'&amp;gt;&lt;span class=&quot;escape&quot;&gt;\s&lt;/span&gt;*&lt;span class=&quot;expr&quot;&gt;#{flash[name]}&lt;/span&gt;&lt;span class=&quot;escape&quot;&gt;\s&lt;/span&gt;*&amp;lt;&lt;span class=&quot;escape&quot;&gt;\/&lt;/span&gt;div&amp;gt;&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;/&lt;/span&gt;
              &lt;span class=&quot;ident&quot;&gt;flash&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;]=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;nil&lt;/span&gt;
            &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
          &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
        
        &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
        &lt;/pre&gt;
        
        &lt;p&gt;Excellent, a simple test for the HTML generated by my haml helper.
        NOTE the setup required in the before :each, this sets up the haml helpers in the helpers context&lt;/p&gt;
        
        &lt;p&gt;Why would I want to use HAML#open you ask?&lt;/p&gt;
        
        &lt;p&gt;Well it makes the helpers look so much tidier IMHO, take this example
        from my previous post on 
        &lt;a href=&quot;http://blog.wolfman.com/articles/2007/06/23/developing-a-social-networking-site-part-3-tag-cloud&quot;&gt;tag clouds&lt;/a&gt;,
        the re-factored helper now looks like this...&lt;/p&gt;
        
        &lt;pre&gt;  &lt;span class=&quot;comment&quot;&gt;# display a tag cloud for the given model&lt;/span&gt;
          &lt;span class=&quot;keyword&quot;&gt;def &lt;/span&gt;&lt;span class=&quot;method&quot;&gt;tag_cloud&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;ident&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;camelcase&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;constantize&lt;/span&gt;
            &lt;span class=&quot;ident&quot;&gt;plural&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;capitalize&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;pluralize&lt;/span&gt;
            &lt;span class=&quot;ident&quot;&gt;title&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;plural&lt;/span&gt;
            &lt;span class=&quot;ident&quot;&gt;tags&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;tag_counts&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:order&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;tags.name&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;')&lt;/span&gt;
            &lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;tags&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;empty?&lt;/span&gt;
            &lt;span class=&quot;ident&quot;&gt;urlmeth&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;tagged_&lt;span class=&quot;expr&quot;&gt;#{model.to_s.pluralize}&lt;/span&gt;_path&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;to_sym&lt;/span&gt;
            &lt;span class=&quot;ident&quot;&gt;haml_tag&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:div&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:class&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;tagcloud&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;}&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;do&lt;/span&gt;
              &lt;span class=&quot;ident&quot;&gt;haml_tag&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:h3&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;title&lt;/span&gt;
              &lt;span class=&quot;ident&quot;&gt;tags&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;|&lt;/span&gt;
                &lt;span class=&quot;keyword&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;FAQ&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;'&lt;/span&gt;
                &lt;span class=&quot;ident&quot;&gt;haml_tag&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:span&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;:style&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;font-size:&lt;span class=&quot;expr&quot;&gt;#{calc_size(t.count)}&lt;/span&gt;%&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;}&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;do&lt;/span&gt;
                  &lt;span class=&quot;ident&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;link_to&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;urlmeth&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;:tag&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;))&lt;/span&gt;
                &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
              &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
            &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
            &lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;true&lt;/span&gt;
          &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;      
        &lt;/pre&gt;
        
        &lt;p&gt;So much cleaner, plus I can return a boolean to indicate if there was
        anything output or not, which tells me if I need to output an &lt;code&gt;&amp;lt;hr/&amp;gt;&lt;/code&gt; or
        not.&lt;/p&gt;
        
        &lt;p&gt;&lt;a href=&quot;http://technorati.com/tag/rspec+haml&quot; rel=&quot;tag&quot;&gt;&lt;/a&gt;
        &lt;a href=&quot;http://technorati.com/tag/haml+haml_tag&quot; rel=&quot;tag&quot;&gt;&lt;/a&gt;&lt;/p&gt;
      </description>
      <author>Jim Morris</author>
      <pubDate>Sat, 14 Jul 2007 16:44:33 -0700</pubDate>
      <link>http://blog.wolfman.com/articles/2007/7/14/using-rspec-to-test-haml-helpers</link>
      <guid isPermaLink='false'>urn:uuid:0697a7d8-7846-4c80-b786-603324e4e321</guid>
    </item>
    <item>
      <title>"Using RSpec to test HAML helpers" by Evgeny</title>
      <description>
        I guess the file you will put that in will be spec/helpers/application_spec.rb
        Because you, and http://rspec.rubyforge.org/documentation/rails/writing/helpers.html don't specify the file naming. I took a guess, and it seems to be okey ...
        
        
        Thanks for the helper, and the spec for the helper! :)
        
        
        Do you know of any repository of small+usefull helpers that one would usually put in application helpers? That kind of helpers that you take with you to each new application you write .... 
        
        Like for example (that I have in my apps):
        
            def whitespace(times = 1)
              &quot;&amp;nbsp;&quot; * times
            end
      </description>
      <pubDate>Sun, 15 Jul 2007 13:00:25 -0700</pubDate>
      <link>http://blog.wolfman.com/posts/31#comment-141</link>
      <guid isPermaLink='false'>urn:uuid:b65c5108-bced-4a41-ae26-d1d08e757613</guid>
    </item>
    <item>
      <title>"Using RSpec to test HAML helpers" by wolfmanjm</title>
      <description>
        Yes that is where I put it.
        
        I'm not aware of a place for those helpers, but if you find one let me know :)
      </description>
      <pubDate>Sun, 15 Jul 2007 13:25:28 -0700</pubDate>
      <link>http://blog.wolfman.com/posts/31#comment-142</link>
      <guid isPermaLink='false'>urn:uuid:e7c4c856-92e2-4c42-90f5-c36fdefac82c</guid>
    </item>
    <item>
      <title>"Using RSpec to test HAML helpers" by Evgeny</title>
      <description>
        &lt;pre&gt;
          it &quot;should display flash&quot; do
            for name in [ :notice, :warning, :error ]
              flash[name]= &quot;flash #{name.to_s} message&quot;
              capture_haml {
                display_flash
              }.should have_tag &quot;div.#{name.to_s}&quot;, 1, :text =&gt; flash[name]
            end
          end
        &lt;/pre&gt;
      </description>
      <pubDate>Thu, 19 Jul 2007 15:58:11 -0700</pubDate>
      <link>http://blog.wolfman.com/posts/31#comment-143</link>
      <guid isPermaLink='false'>urn:uuid:95db41bc-ac33-4201-a887-e6270f49c233</guid>
    </item>
    <item>
      <title>"Using RSpec to test HAML helpers" by Evgeny</title>
      <description>
        Ohh... I actually just used :
        &lt;pre&gt;
          before(:each) do
            @haml_is_haml = true
            @haml_stack = [Haml::Buffer.new(:attr_wrapper =&gt; &quot;'&quot;)]
          end
        &lt;/pre&gt;
        &lt;br/&gt;
        because I have more haml helpers to test than just one.
      </description>
      <pubDate>Thu, 19 Jul 2007 15:59:10 -0700</pubDate>
      <link>http://blog.wolfman.com/posts/31#comment-144</link>
      <guid isPermaLink='false'>urn:uuid:5539a23b-8f59-4acc-8a0f-af09670d8240</guid>
    </item>
    <item>
      <title>"Using RSpec to test HAML helpers" by wolfmanjm</title>
      <description>Thanks I wasn't sure that ` have_tag` would work, but its good to know thats an option.</description>
      <pubDate>Thu, 19 Jul 2007 16:05:40 -0700</pubDate>
      <link>http://blog.wolfman.com/posts/31#comment-145</link>
      <guid isPermaLink='false'>urn:uuid:6ba78a10-7788-4310-8a35-377ab7856f3f</guid>
    </item>
    <item>
      <title>"Using RSpec to test HAML helpers" by Evgeny</title>
      <description>
        Is there a way to add those
          include ActionView::Helpers
          include Haml::Helpers
        
        into spec_helper.rb ?
        and perhaps even the `@haml_is_haml` and `@haml_stack` ....
        
        It's kind of annoying adding those to each description I have of helpers. Not DRY at all. Especially for a non-rails project I am working on.
      </description>
      <pubDate>Sun, 22 Jul 2007 05:50:21 -0700</pubDate>
      <link>http://blog.wolfman.com/posts/31#comment-146</link>
      <guid isPermaLink='false'>urn:uuid:b383935e-859d-4caf-8bea-e86e5498dd14</guid>
    </item>
    <item>
      <title>"Using RSpec to test HAML helpers" by Evgeny</title>
      <description>
        One can also use automatic inclusion for haml helpers for all helper tests&lt;br/&gt;
        by editing `spec/spec_helper.rb`, like so:
        
            Spec::Runner.configure do |config|
              config.include Haml::Helpers
              config.include ActionView::Helpers
        
              config.before(:each, :behaviour_type =&gt; :helper) do
                @haml_is_haml = true
                @haml_stack = [Haml::Buffer.new(:attr_wrapper =&gt; &quot;'&quot;)]
              end
            end
        
        Or if using Haml trunk, then you can also do it like so: 
        
            Spec::Runner.configure do |config|
              config.before(:each, :behaviour_type =&gt; :helper) do
                init_haml_helpers
              end
            end
        
        Though I didn't test this enough, and it could be a bit wrong ... especially regarding the trunk method.
      </description>
      <pubDate>Sun, 22 Jul 2007 08:42:30 -0700</pubDate>
      <link>http://blog.wolfman.com/posts/31#comment-147</link>
      <guid isPermaLink='false'>urn:uuid:6d684506-6180-4763-a9c7-059cd4c14b8b</guid>
    </item>
    <item>
      <title>"Using RSpec to test HAML helpers" by meekish</title>
      <description>That's very nice. I learn something new every day.</description>
      <pubDate>Sun, 19 Aug 2007 11:12:26 -0700</pubDate>
      <link>http://blog.wolfman.com/posts/31#comment-148</link>
      <guid isPermaLink='false'>urn:uuid:b6ccc4ad-e0db-4ce7-bd93-2e97ad5d7983</guid>
    </item>
  </channel>
</rss>
