Testing a render of a partial in a helper

I am trying to spec my helpers, and I find a few of my helpers
actually render a partial.

My code:

module PageHelper
  def settings_menu
    render :partial => '_shared/settings_menu'
  end

  def banner_for(model)
    banner_message = ... some message ...
    render :partial => 'shared/banner', :locals => { :message =>

banner_message }
end
end

I want to be able to either capture the result of the render, or just
express the expectation that the render is called. For now neither
work. My test now looks as follows:

require 'spec_helper'

describe PageHelper do

  context "settings_menu" do
    it "render the correct partial" do
      helper.should_receive(:render).with({:partial => 'shared/

settings_menu’})
helper.settings_menu
end
it “generates the correct result” do
@result = helper.settings_menu
@result.should be == “something”
end
end
end

Both of these tests fail. The expectation is never met, and @result
is always nil.

Ignore this, I had a different problem in my code causing this.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs