guilleiguaran/fakeredis — pull request #86 by larrylv (2013-12-26 10:43:25+00:00)
Title: Transaction commands support

The old way of `#multi` and `#exec` is not the exact
redis transaction commands. It just run every command after `multi`,
and save the result to buffer. Then when `#exec` is called, return
the buffer. So `#discard` couldn't work. (Actually it is not implemented)

The real `#multi` and `#exec` should be like this: save all the commands
after `#multi`, when `#exec` is called, run the commands saved. And if
`#discard` is called before `#exec`, client should forget all commands
after `#multi`, don't run any one of them.

My implementation is:
* when `#multi` is called, alias all command methods to `real_#{command}`
* and re-define the original command method: put the called command in a queue
* when `#exec` is called, fetch every command from the queue, and run them.

Some specs codes are referenced from [mock-redis](https://github.com/causes/mock_redis/blob/v0.10.0/spec/transactions_spec.rb).