未定义Meteor / Jasmine对象

时间:2015-02-23 10:37:26

标签: meteor coffeescript jasmine

我正在尝试了解如何使用jasmine编写 server-unit-test

这是我到目前为止所做的:

/both/posts.coffee

@Posts = new Mongo.Collection('posts');

class @Post extends Minimongoid
  @_collection: @Posts

  @defaults:
    title: ''

  validate: ->
    unless @title.length > 5
      @error('title', 'Title is required and should be longer than 5 letters.')

/tests/server/unit/posts/spec/postSpec.coffee

describe 'Post', ->
  post = undefined
  beforeEach ->
    post = new Post()

  describe 'fields', ->
    it 'should be able to assign title with strings', ->
      title = "The Title"
      post.title = title

      expect(post.title).toBe title

服务器控制台:

(STDERR) [sanjo:jasmine]: The code has syntax errors. [ReferenceError: Minimongoid is not defined]

那里有什么问题?我怎样才能通过这个简单的测试?

1 个答案:

答案 0 :(得分:0)

当我将UNIT-Test的整个内容移动到INTEGRATION-Test文件夹并在代码前加上

时,我已经开始工作了

/tests/server/integration/posts/spec/postSpec.coffee

Jasmine.onTest ->
 # my code

现在全是绿色的。谢谢@Marius Darila