[rspec-users] describe 'a spec for a helper that takes a block' i.should need_to_do_this?

Higgaion BrianPatrickDunn at gmail.com
Mon Apr 27 14:40:31 EDT 2009

i have a helper like this:

def swf_upload_tag( upload_url, options = {},  &block)
    # irelavant stuff removed
    button_text = capture(&block)
    unless button_text.blank?
      options.merge!( :button_text => button_text )
    # irelavant stuff removed
    concat( content_tag( :div, '',  :id => opts
[:button_placeholder_id] ) <<
      update_page_tag do |page|
        page.call "SWFUpload.init", recursive_options_for_javascript
      end, block.binding

to spec it i had to do this in my before block:

      before do
        helper.output_buffer = '' # wouldn't empty string make a good
        helper.instance_variable_set(:@template, helper ) # i probably
shouldn't have to do this.

otherwise capture_helper.rb and prototype_helper.rb would raise.
these things seem to be reasonable defaults: the output_buffer a blank
screen, and @template set to the context of the helper...

what do you all think? is there some reason *not* to always set these?

More information about the rspec-users mailing list