rspec: mocking

# To mock any object's method
allow_any_instance_of(MyClass).to receive(:my_method).and_return(false)

Make sure you put this in the before(:each) do block, before your tests, if you put it on the test itself, it may be too late, and you don't get the behavior you are expecting (the overwriting of the method you requested)

Also, this doesn't work with before(:all)