A little RubyGem for faking out execution in your tests and inspecting afterwards what was run.
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?
gem install fake_execution
How do I use it?
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.should=~/echo/cmds.should=~/git checkout/cmds.should=='touch monkeys'`echo *`# outputs: echo *
But I use Rspec
require'fake_execution/spec_helper'describe"monkeys"doincludeFakeExecution::SpecHelpersit"should touch the monkey"do`touch monkey`cmds.should=='touch monkey'endend