{"id":3285,"date":"2015-09-24T17:53:02","date_gmt":"2015-09-24T16:53:02","guid":{"rendered":"https:\/\/www.devco.net\/?p=3285"},"modified":"2015-09-24T17:55:07","modified_gmt":"2015-09-24T16:55:07","slug":"using-ruby-mocha-outside-of-unit-testing-frameworks","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2015\/09\/24\/using-ruby-mocha-outside-of-unit-testing-frameworks.php","title":{"rendered":"Using ruby mocha outside of unit testing frameworks"},"content":{"rendered":"
I find myself currently writing a lot of orchastration code that manages hardware. This is very difficult because I like doing little test.rb<\/em> scripts or testing things out in irb<\/em> or pry<\/em> to see if APIs are comfortable to use.<\/p>\n The problem with hardware is in order to properly populate my objects I need to query things like the iDRACs or gather inventories from all my switches to figure out where a piece of hardware is and this take a lot of time and requires constant access to my entire lab.<\/p>\n Of course my code has unit tests and so all the objects that represents servers and switches etc are already designed to be somewhat comfortable to load stub data for and to be easy to mock. So I ended up using rspec as my test.rb<\/em> environment of choice.<\/p>\n I figured there has to be a way to use mocha in a non rspec environment, and turns out there is and it’s quite easy.<\/p>\n