I am testing an action on a controller and cannot seem to find the syntax to stub a method call off of the controller I am testing. pseudo code class SomeController < < ApplicationController def some_action stuff stuff stuff some_protected_method_call stuff redirect_to something end protected def some_protected_method_call end end describe SomeController do it "should have some description of behavior here" do #how do I stub some_protected_method_call get ''some_action'' response.should be_redirect end end
On Feb 21, 10:40 am, Anthony Broad-Crawford <abroad- crawf... at within3.com> wrote:> I am testing an action on a controller and cannot seem to find the > syntax to stub a method call off of the controller I am testing. > > pseudo code > > class SomeController < < ApplicationController > > def some_action > > stuff > stuff > stuff > some_protected_method_call > > stuff > redirect_to something > end > > protected > def some_protected_method_call > > end > end > > describe SomeController do > > it "should have some description of behavior here" do > > #how do I stub some_protected_method_call > > get ''some_action'' > response.should be_redirect > end > endcontroller.stub! (:some_protected_method_call).and_return(whatever_it_should_return) That work?> _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
yes, thank you very much! On Feb 21, 2008, at 5:23 PM, dchelimsky at gmail.com wrote:> On Feb 21, 10:40 am, Anthony Broad-Crawford <abroad- > crawf... at within3.com> wrote: >> I am testing an action on a controller and cannot seem to find the >> syntax to stub a method call off of the controller I am testing. >> >> pseudo code >> >> class SomeController < < ApplicationController >> >> def some_action >> >> stuff >> stuff >> stuff >> some_protected_method_call >> >> stuff >> redirect_to something >> end >> >> protected >> def some_protected_method_call >> >> end >> end >> >> describe SomeController do >> >> it "should have some description of behavior here" do >> >> #how do I stub some_protected_method_call >> >> get ''some_action'' >> response.should be_redirect >> end >> end > > controller.stub! > (:some_protected_method_call).and_return(whatever_it_should_return) > > That work? > >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users