Thinking on hiring me?

Please read

Fernando Guillén

a Freelance Web Developer

cabecera decorativa

software development as an artistic expression

Ruby: DummyDropbox, mocking the Dropbox API calls.

Dummy Dropbox

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.

Leave a comment

a Freelance Web Developer is proudly powered by WordPress
Entries (RSS) and Comments (RSS).

Creative Commons License
Fernando Guillen's blog by Fernando Guillen is licensed under a Creative Commons Attribution-NoDerivs 3.0 Unported License.