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

Mocks: andSucceed/andFail everywhere #157

Closed
xcambar opened this issue Dec 8, 2015 · 5 comments
Closed

Mocks: andSucceed/andFail everywhere #157

xcambar opened this issue Dec 8, 2015 · 5 comments

Comments

@xcambar
Copy link
Contributor

xcambar commented Dec 8, 2015

Add andSuccess and addFail public methods to all mock classes so the user can test more use cases (500, 404...)

refs #156 (comment)

@danielspaniel
Copy link
Collaborator

I am thinking of renaming to just succeeds() and fails()
seems simpler and more along the lines of with() and returns() methods proposed in the other items.

@xcambar
Copy link
Contributor Author

xcambar commented Jan 6, 2016

Good idea.

BTW, I started working on this and it was kind of a rabbit hole, as, for example, handleFind returns an id and handleQuery returns an instance of MockQueryRequest.

Do you have an idea about how to make the transition smoother? I'd guess that returning a MockRequest (doesn't exist yet) systematically would help, but you may have another perspective.

And happy new year! :)

@danielspaniel
Copy link
Collaborator

Neato that you started on this. :)

And good point there about handleFind. One idea would be to move this id functionality from:

var id = FactoryGuy.get('fixtureBuilder').extractId(modelName, json);

var url = this.buildURL(modelName, id);
new MockGetRequest(url, modelName, json);
return id;

to something like a property on MockGetRequest

var mockRequest =  new MockGetRequest(url, modelName, json);
mockRequest.id = FactoryGuy.get('fixtureBuilder').extractId(modelName, json);
return mockRequest;

for handleReload would be similar, although redundant or not even necessary I suppose.

.. I am open to anything else really.

And same here .. happy new year!

@danielspaniel
Copy link
Collaborator

are there things you're still stuck on. I am dedicating tomorrow to work on this and finish these issues, so let me know which you have not done, or which you want help on?

@danielspaniel
Copy link
Collaborator

@xcambar .. thanks for the amazing ideas that got me going on the huge refactor. I looked at your commits and used them as a base for my changes.

you can now do this:

  let mock = mockFind('user');
  let userId = mock.get('id');

I also added ability to inspect json with get method ( huge improvement )

thanks again!

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

No branches or pull requests

2 participants