I am trying to test my application_helper yield_for method, but I do not know how to do this. I tried the code below, but getting the following error:
Failure/Error: self.stub(:content_for).with(:foo).and_return('bar') Stub :content_for received unexpected message :with with (:foo)
application_helper.rb
def yield_for(content_sym, default = '') content_for?(:content_sym) ? content_for(content_sym) : default end
application_helper_spec.rb
describe '#yield_for' do it 'should fetch the yield' do self.stub(:content_for).with(:foo).and_return('bar') helper.yield_for(:foo).should == 'bar' end end
source share