Ticket #54 (closed enhancement: invalid)

Opened 1 year ago

Last modified 5 months ago

contrib - simple mock of backgroundrb for using in rails unit tests.

Reported by: julien.pervil..@free.fr Assigned to: ezmobi..@gmail.com
Priority: minor Milestone: 0.2.2 Release
Component: rails_integration Version:
Keywords: rails test mock Cc:

Description

I just had to write a simple mock of BackgrounDRb for a project I am working for and I thought it would be nice to share it with the community.

This mock does pretend to run tasks in the background but simply invokes the Worker's do_work method, mimicing the interface of the actual backgroundrb instance, and exposing the same access to the logger (piggied back to the Rails logger) and to results (as a Hash, so the to_hash method is still present). The point is to be able to run tests without having to explicitely configure and run a test instance.

To use, simply add the following line somewhere in your RAILS_ROOT/test_helper.rb:

# inject the mock backgroundrb to the test environment. require File.dirname(FILE) + '/mocks/test/backgroundrb_mock.rb'

Feel free to improve on my contribution and eventually include it in a future release of BackgrounDRb

Sincerely, Julien Pervillé

Attachments

backgroundrb_mock.rb (2.2 kB) - added by julien.pervil..@free.fr on 05/11/07 02:22:10.
mock to install in RAILS_ROOT/test/mocks/test

Change History

05/11/07 02:22:10 changed by julien.pervil..@free.fr

  • attachment backgroundrb_mock.rb added.

mock to install in RAILS_ROOT/test/mocks/test

05/11/07 02:22:47 changed by julien.pervil..@free.fr

  • type changed from defect to enhancement.

12/16/07 04:44:13 changed by gethema..@gmail.com

  • status changed from new to closed.
  • resolution set to invalid.

Something similar has been added to trunk.