title: How To test in rspec if file is deleted?
body: <p>I would like to know how to test in rspec is specific file is deleted.  Here is code that I am testing</p>
  
  <pre><code>def check_status
    filename = File.join('test', 'status.txt')
    File.delete(filename ) if File.exist?(filename)
  end
  </code></pre>
  
  <p>Here is test: </p>
  
  <pre><code>before do
    allow(File).to receive(:exist?).and_return(true)
    allow(File).to receive(:delete)
  end
  
  it {expect(File).to receive(:delete).with("test/status.txt") }
  </code></pre>
  
  <p>I am getting error </p>
  
  <pre><code>(File (class)).delete("test/status.txt")
      expected: 1 time with arguments: ("test/status.txt")
      received: 0 times
  </code></pre>
  
  <p>Could you please help me with this issue. I am sure that my code delete the file, but in tests it receive it 0 times. </p>