What
A very small coffeescript mocking framework.
A very small coffeescript mocking framework.
$ npm install https://github.com/milewdev/TinyMock/raw/master/TinyMock-0.4.0.tgz
chai = require("chai") should = chai.should() Copier = require("../src/Copier")describe "Copier", -> it "copies streams", ->mock = require("TinyMock")
Copier.copy_stream(mocked_input, mocked_output) it "copies files", ->mock (mocked_input, mocked_output) -> mocked_input.expects("read").returns("a message in a stream") mocked_output.expects("write").args("a message in a stream")
Copier.copy_file("source.txt", "target.txt") it "throws an error if the source file does not exist", ->mock -> fs.expects("readFileSync").args("source.txt").returns("a message in a file") fs.expects("writeFileSync").args("target.txt", "a message in a file")
(-> Copier.copy_file("unknown.txt", "target.txt") ).should.throw("'unknown.txt' does not exist")mock -> fs.expects("readFileSync").args("source.txt").throws(new Error("'unknown.txt' does not exist"))