anchor.diff:  
   http://badge.fury.io/rb/shell_mock[image:https://badge.fury.io/rb/shell_mock.png[Gem Version]]
   http://travis-ci.org/yarmiganosca/shell_mock[image:https://secure.travis-ci.org/yarmiganosca/shell_mock.png[Build Status]]
  +
  +toc::[]
   
   == What Is It?
   
  
positive.code: :source-highlighter: coderay
  :sectanchors:
  :linkattrs:
  :toc: left
  :toclevels: 3
  ifdef::env-github[]
  :tip-caption: :bulb:
  
negative.code: 
  === You can narrow what invocations are matched to your command stub:
  
  Match env vars as well as the command: `ShellMock.stub_command('ls').with_env({'FOO' => 'bar'})`
  
  Provide a more complete invocation: `ShellMock.stub_command('ls $HOME')`
  
  Shelling out to run `"ls"` won't match this command stub, but shelling out to run `"ls $HOME"` will.
  
  NOTE: ShellMock always matches as strictly as possible, so if you stubbed both `"ls"` and `"ls $HOME"`, invocations of `"ls $HOME'` will only ever match against the `"ls $HOME"` stub and never the `"ls"` stub.
  
  === Setting the behavior of the command invocation:
  
  Have the mock command invocation write to stdout: `ShellMock.stub_command('ls').and_output("\n")`
  
  Set the mock command invocation's exit status: `ShellMock.stub_command('ls').and_exit(2)`
  
  If you want to both write to stdout and set the exit code (a common pair), `ShellMock.stub_command('ls').and_return("\n")` will both have the command invocation write the passed string to stdout, and will set the mock command invocation's exit status to `0`.
  
  === Specifying the expected number of command invocations:
  
  Called exactly once: `expect(stub).to have_been_called.once`
  
  Not called: `expect(stub).to have_been_called.never`
  
  Not called (using RSpec expectation negation): `expect(stub).to_not have_been_called`
  
  Called exactly `n` times: `expect(stub).to have_been_called.times(n)`
  
  Called more than `n` times: `expect(stub).to have_been_called.more_than(n)`
  
  Called fewer than `n` times: `expect(stub).to have_been_called.fewer_than(n)`
  
  `less_than` can be used as an alias for `fewer_than`
  
  