Thursday, 23 January 2014

rails rspec stub system call

I've tried everything to make this work. Here is my problem


if system("command")
  -- do something --
else
  -- do something else --
end

I obviously wanted to stub the system command. For that you can do something like this in your rspec file:

module Kernel

  def system(cmd)
    return true
  end

end