I had a similar problem stubbing the File system classes. The way that I have been solving this problem is as follows.
::File.stub(:exists?).with(anything).and_call_original
::File.stub(:exists?).with('/tmp/deploy/crontab').and_return true
open_file = double('file')
allow(open_file).to receive(:each_line).and_yield('line1').and_yield('line2')
::File.stub(:open).and_call_original
::File.stub(:open).with('/tmp/deploy/crontab').and_return open_file