title: How can I validate exits and aborts in RSpec?
body: <p>I am trying to spec behaviors for command line arguments my script receives to ensure that all validation passes.  Some of my command line arguments will result in <code>abort</code> or <code>exit</code> being invoked because the parameters supplied are missing or incorrect.</p>
  
  <p>I am trying something like this which isn't working:</p>
  
  <pre><code># something_spec.rb
  require 'something'
  describe Something do
      before do
          Kernel.stub!(:exit)
      end
  
      it "should exit cleanly when -h is used" do
          s = Something.new
          Kernel.should_receive(:exit)
          s.process_arguments(["-h"])
      end
  end
  </code></pre>
  
  <p>The <code>exit</code> method is firing cleanly preventing RSpec from validating the test (I get "SystemExit: exit").</p>
  
  <p>I have also tried to <code>mock(Kernel)</code> but that too is not working as I'd like (I don't see any discernible difference, but that's likely because I'm not sure how exactly to mock Kernel and make sure the mocked Kernel is used in my <code>Something</code> class).</p>