Ruby: DummyDropbox, mocking the Dropbox API calls.
Playing with the Dropbox API for an another experimental pet-project I needed to test how my mini-application was responding to different Dropbox contents. On the beginning I was configuring a real Dropbox account for testing but this was not agile and flexible. So this is because I decided to mock the dropbox ruby gem and this is because DummyDropbox has been born.
The working is simple: you point the gem to a local folder, all the dropbox API calls will think that this local folder is a real Dropbox account.
Example:
require 'dummy_dropbox' DropboxDummy.root_path = "#{File.dirname(__FILE__)}/test/fixtures/dropbox" session = Dropbox::Session.new('key', 'secret') assert_equal( File.read( "#{File.dirname(__FILE__)}/test/fixtures/dropbox/file1.txt" ), session.download( '/file1.txt' ) )
Wondering if this could be helpful for someone.