> Basically, there are two situation. > 1) I want to check if a function was called and I want to execute the > function code
I don't think that's possible. Setting a method expectation (Eg: template.should_receive(:render)) automatically stubs #render. > 2) I want to check if a function was called and I don't want to > execute the function code so I used stubbing. That's how #should_receive works. > I thought that for the first scenario the solution would be: > template.should_receive(:render) #only checks if render function was > called You're correct that the only thing that's checked is whether or not #render was called on the "template" object. However, creating that expectation causes RSpec to stub #render . If you want to confirm this, call #render , and you'll see that it returns nil. nil is the default return value for a stubbed method. > and for the second scenario > template.stub!(:render) #stub render function > template.should_receive(:render) #check if render function was called Mostly! All you need is the call to #should_receive . The call to #stub! doesn't do anything bad...it just doesn't do anything at all. Cheers, Nick _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users