[mocha-developer] Stubbing a module method

Christophe anaema_ml at yahoo.fr
Thu Sep 27 19:20:14 EDT 2007


Unfortunately I already tried this too - And it doesn't work...


le 28/09/2007 01:10, Duncan Beevers nous a dit:
> SiteController.any_instance.stubs(:login_required).returns(true)
>
> perhaps?
>
> On 9/27/07, Christophe <anaema_ml at yahoo.fr> wrote:
>   
>> 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