Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Getting Started to pass instance object instead of constructor to td.object() #329

Closed
StanleySathler opened this issue Feb 2, 2018 · 0 comments

Comments

@StanleySathler
Copy link
Contributor

StanleySathler commented Feb 2, 2018

Description

The docs - actually, the Getting Started one, available here, next-to-last paragraph - say we can pass a constructor as an argument to td.object() method.

That seems not true anymore, since we currently have this:

// src/object.js
var fakeObject = function (nameOrType, config, argCount) {
  ...
  } else if (_.isFunction(nameOrType)) {
    ensureFunctionIsNotPassed()
  }
  ...
}

Since this part of the tutorial is trying to show the library is smart enough to hunt for any method defined on the function's prototype, I think we should change it to pass an instance rather than the constructor, since the td.constructor() method apparently doesn't hunt for prototyped methods:

describe('MathProblem', function(){
  var subject, createRandomProblem, savesProblem;
  beforeEach(function(){
    createRandomProblem = td.function('createRandomProblem')
    savesProblem = td.object(new SavesProblem())
    subject = new MathProblem(createRandomProblem, savesProblem)
  })
  it('POSTs a random problem', function(){
    // ...
  })
})

What you think, guys? Or am I wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants