[mocha-developer] Stubbing a module method

Christophe anaema_ml at yahoo.fr
Thu Sep 27 18:43:11 EDT 2007


Hi, I'm trying to stub the login_required() method of the 
acts_as_authenticated plugin in an RoR integration test.
This method is defined in the AuthenticatedSystem module, in the 
lib/authenticated_system.rb

What happen is that the stub have no effect and the real method is still 
executed.

Here is the code. Any idea ?

Thank you



require "#{File.dirname(__FILE__)}/../test_helper"

class CheckStopsiteTest < ActionController::IntegrationTest
  fixtures :users
 
  def test_closed_site
    AuthenticatedSystem.stubs(:login_required).returns(true)
    get '/admin/maintenance/stop_site'
    assert_response :success
    get '/fr/site'
    assert_redirected_to :controller => 'site', :action => 'closed_site'
  end
 
end


More information about the mocha-developer mailing list