<commit_before># Mocks

When testing software that depends on Gearman, it's useful to have objects that resemble the various
`gearman-coffee` classes.
Usually, if you're testing a Gearman worker, you'd like to avoid running a Gearman server and
instead give it a mock to communicate with.
If you're testing something that is a Gearman client, you'll want to mock out the response of
`client.submitJob` and the the side effects of that job.

## Usage

### MockWorkers

```coffee
{MockWorker} = require('gearman-coffee/mocks').Workers
worker = new MockWorker()
worker.on 'data', console.log
worker.on 'done', (err) ->
  console.log "GOT DONE WITH ERR", err
  assert.equal @received.data.length, 11
worker_function = (payload, worker) ->
  worker.data el for el in payload
  worker.done()
worker_function [0..10], worker
```

### MockClient/MockJobs

```coffee
assert        = require 'assert'
GearmanCoffee = require 'gearman-coffee'
GearmanMocks  = require 'gearman-coffee/mocks'
sinon         = require 'sinon'

{DataJob} = GearmanMocks.Jobs
MockClient = GearmanMocks.Client

client = new MockClient()
client_stub = sinon.stub GearmanCoffee, 'Client'
client_stub.returns client
client.intercept 'worker_name', new DataJob(['1', '2']), (payload) ->
  assert.deepEqual payload, expected_payload
```
<commit_msg>Update README to reflect package<commit_after># Mocks

When testing software that depends on Gearman, it's useful to have objects that resemble the various
`gearman-node` classes.
Usually, if you're testing a Gearman worker, you'd like to avoid running a Gearman server and
instead give it a mock to communicate with.
If you're testing something that is a Gearman client, you'll want to mock out the response of
`client.submitJob` and the the side effects of that job.

## Usage

### MockWorkers

```coffee
{MockWorker} = require('gearman-node/mocks').Workers
worker = new MockWorker()
worker.on 'data', console.log
worker.on 'done', (err) ->
  console.log "GOT DONE WITH ERR", err
  assert.equal @received.data.length, 11
worker_function = (payload, worker) ->
  worker.data el for el in payload
  worker.done()
worker_function [0..10], worker
```

### MockClient/MockJobs

```coffee
assert        = require 'assert'
GearmanCoffee = require 'gearman-node'
GearmanMocks  = require 'gearman-node/mocks'
sinon         = require 'sinon'

{DataJob} = GearmanMocks.Jobs
MockClient = GearmanMocks.Client

client = new MockClient()
client_stub = sinon.stub GearmanCoffee, 'Client'
client_stub.returns client
client.intercept 'worker_name', new DataJob(['1', '2']), (payload) ->
  assert.deepEqual payload, expected_payload
```

{'fraction_non_alphanumeric': 0.1087866108786611, 'fraction_numerical': 0.005325218714340053, 'mean_word_length': 4.729847494553377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '308918', 'n_tokens_mistral': 872, 'n_tokens_neox': 809, 'n_words': 288}