I'm trying to put the rspec for active link condition present in the application_helper.rb. Application_helper.rb code:
def active_class(link_path) current_page?(link_path) ? 'active' : '' end i tried to put the rspec for this active_class method, i used stub for this purpose.This is my rspec code for active_class method. Application_helper_spec.rb code:
describe 'when called from "index" action' do before helper.stub!(:action_name).and_return('index') end it 'should do' do helper.active_class.should == 'active' end describe 'when called from "other" action' do before helper.stub!(:action_name).and_return('other') end it 'should do' do helper.active_class.should == 'empty' end I'm getting the error as undefined method stub.How can i get overcome from this issue?