A little RubyGem for faking out execution in your tests and inspecting afterwards what was run.
Why FakeExecution?
I’ve been creating internal tools for developers to help improve productivity. These tools written in Ruby, ended up doing lots of shell scripting. These scripts started becoming fairly complicated so I wanted some test feedback. How could I easily test execution?
Enter FakeExecution.
Installing
gem install fake_execution
How do I use it?
12345678910111213141516171819
require'fake_execution/safe'FakeExecution.activate!`echo *`# This is not executed`git checkout git://github.com/josephwilk/fake-execution.git``touch monkeys`system("git add monkeys")system('git commit -m "needs more monkeys"')`git push`FakeExecution.deactivate!cmds[0].should=~/echo/cmds[1].should=~/git checkout/cmds[2].should=='touch monkeys'`echo *`# outputs: echo *
But I use Rspec
1234567891011
require'fake_execution/spec_helper'describe"monkeys"doincludeFakeExecution::SpecHelpersit"should touch the monkey"do`touch monkey`cmds[0].should=='touch monkey'endend