[rspec-users] How do I write specs for Rails 3 view block helpers that use #with_output_buffer(&block) ?

Kristian Mandrup kmandrup.github at gmail.com
Mon Aug 23 10:04:42 EDT 2010

I found this: http://stackoverflow.com/questions/197164/how-do-i-test-rails-block-helpers-with-rspec

  it 'should do something' do
    helper.some_block_helper { the_block_code }.should XXXX

but not sure how to use it

I have a module which is extended on top of ActiveView::Base

module MyViewExt
    def area(clazz, &block)
      content = with_output_buffer(&block)
      content_tag :div, content, :class => clazz

How would I go about testing this in isolation, especially that the
effect of using #with_output_buffer(&block)
is as expected (especially when I have nested calls of view helpers
using this approach!).


More information about the rspec-users mailing list