mfncooper / mockery

Simplifying the use of mocks with Node.js
Other
1.1k stars 60 forks source link

Can't get mockery to work #15

Closed cyrusdavid closed 11 years ago

cyrusdavid commented 11 years ago

File: lib/movie.js

var Movie = module.exports = {
  text: 'newmoon'
}

File: tests/movie.js

describe('movie test', function(){
  it('should have mock text', function(){
    var movieMock = {
      text: 'twilight'
    };
    mockery.registerMock('movie', movieMock);

    var movie = require('movie');
    movie.text.should.equal('twilight');
  });
});

Command:

$ NODE_PATH=lib mocha -R spec tests

Output:

movie test
    1) should have mock text

  0 passing (10 ms)
  1 failing

  1) movie test should have mock text:

      actual(red) expected(green)

      twilight(green) newmoon(red)

What have I done wrong?