[rspec-users] mocking the shell command (Kernel module)

Joaquin Rivera Padron joahking at gmail.com
Fri Sep 12 09:12:56 EDT 2008


ooopssss, sorry the last one goes out unfinished (some gmail hotkey)...

hello there,
what is the best (or any) way of mocking the running of shell commands?

e.g.
code like the following:

def method
  %{ ls }
end

spec:

it "should list the directory contents"
  shell = mock(Object) # %{} lives in Kernel module and its sugar for `
  shell.should_receive(:`).with(:ls)
end

sorry about latter one, thanks in advance
joaquin

2008/9/12 Joaquin Rivera Padron <joahking at gmail.com>

> hello there,
> what is the best (or any) way of mocking the running of shell commands?
>
> e.g.
> code like the following:
>
> %{ ls }
>
> spec:
>
> it "should list the directory contents"
>   shell = mock(Object) # %{} lives in Kernel module and its sugar for `
>
> end
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080912/e0fea507/attachment.html>


More information about the rspec-users mailing list