epf
epf copied to clipboard
Fixtures
Will it have FixtureAdapter for testing?
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.
+1
I'd like to try epf instead of Ember Data, but I need to be able to use Fixtures.
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 I agree w/ that. We should coerce during merge. Could you open up a separate issue?
New issue over at #27
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 : 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:
@iguider I am having the same issue, did you manage to resolve it?
@anthillape no, I returned to ember-data
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.