it "should have edit button if user has permission to edit" do EntitiesHelper.stubs(:permission_to_edit_entity?).returns(true) get :index @entities[0..3].each do |entity| response.should have_selector("form", :method => "get", :action => "/entities/edit/#{entity[:id]}") do |form| form.should have_selector("input", :value => "Edit") end end end
I am trying to write a simple test case that checks that the edit button is displayed if the user has permission to edit. I am trying to use stubbing for this. However, this does not seem to work. In the output view, the edit button does not appear next to each individual entity that I expect if stubbing works. I'm new to mocha and insult - am I doing something wrong?
Thank!
, EntitiesHelper - , , (, permission_to_edit_entity?) , ( )... :
EntitiesHelper
permission_to_edit_entity?
controller.stubs(:permission_to_edit_entity?).returns(true)
, , ( , , , ):
controller.expects(:permission_to_edit_entity?).returns(true)
, , ...