epf icon indicating copy to clipboard operation
epf copied to clipboard

Fixtures

Open ayarulin opened this issue 11 years ago • 10 comments

Will it have FixtureAdapter for testing?

ayarulin avatar Jul 10 '13 18:07 ayarulin

Right now the closest thing is Ep.LocalAdapter, which simply does not interface with a backend. In EPF it is quite easy to load data into a session. For instance you could do the following:

session.merge(App.Post.create({id: '1', title: 'testing'}));

session.load(App.Post, 1).then ... // will return the post merged above.

This should make up for many of the features a fixture adapter might have, however I would like to give this more thought and come up with an official story. I will keep this issue open to track.

ghempton avatar Jul 15 '13 05:07 ghempton

+1

I'd like to try epf instead of Ember Data, but I need to be able to use Fixtures.

taras avatar Jul 16 '13 20:07 taras

Just leaving a note here for future googlers. The id must be a string, an integer won't work.

// works
session.merge(App.Post.create({id: '1', title: 'testing'}));

// doesn't work
session.merge(App.Post.create({id: 1, title: 'testing'}));

Perhaps this should be documented - or I actually feel that a numeric id should also be accepted. The current behavior is rather unexpected to me, because it doesn't parallel

session.load(App.Post, 1); // works with numeric argument!

The behind-the-scenes coercion of id to string could be consistently applied everywhere, IMO.

heartsentwined avatar Jul 23 '13 14:07 heartsentwined

@heartsentwined I agree w/ that. We should coerce during merge. Could you open up a separate issue?

ghempton avatar Jul 23 '13 17:07 ghempton

New issue over at #27

heartsentwined avatar Jul 23 '13 17:07 heartsentwined

Just as a side note for people looking into testing, I am working on tests for an EPF project and am quite successfully using sinonjs with the normal rest adapter for testing. IMO this could ultimately produce a smoother transition from a local solution to a real backend (I have heard horror stories about people transitioning from ED's fixture adapter to a real rest adapter).

ghempton avatar Aug 06 '13 18:08 ghempton

@ghempton : I can't bring the Ep.LocalAdapter to work.. it's behaving like the restadapter and trying to GET data from the server (resulting in 404 and breaking the app) :confused:

IderAghbal avatar Mar 17 '14 19:03 IderAghbal

@iguider I am having the same issue, did you manage to resolve it?

anthillape avatar May 22 '14 11:05 anthillape

@anthillape no, I returned to ember-data

IderAghbal avatar May 23 '14 20:05 IderAghbal

As I said in my previous comment, I would recommend using sinon.js rather than Ep.LocalAdapter. I would give the same recommendation over ED's fixture adapter as well.

ghempton avatar May 23 '14 21:05 ghempton