Fixtures not being isolated #408

Closed
svenfuchs opened this Issue May 3, 2011 · 4 comments

Projects

None yet

2 participants

@svenfuchs

According to http://wiki.sproutcore.com/w/page/12412884/DataStore-Using%20Fixtures fixtures are meant for being used in tests (and "hacking away" :)

Now, when I load fixtures in my test setup (using jasmine) like so:

beforeEach(function() {
  // ...
  App.store = SC.Store.create().from(SC.Record.fixtures);
});

and I modify any record in a test case like so:

record.set('foo', 'bar');

then this seems to modify the underlying fixture data object so that in subsequent record.get('foo') will still yield 'bar'.

Erich Ocean's answer on the mailing list:

"Unfortunately you are correct. The copy thing (if that turns out to be
what is happening) could be corrected, but it is not currently
possible in the shipping version of the datastore to "reset"
everything. Various items are stored in places that are not removed
when an SC.Store instance is destroyed. All of these can be fixed
should someone want to take the time; it is an implementation issue,
not an issue with the architecture of the store itself."

@svenfuchs

Btw a workaround seems to be to do the following after each test case:

Travis.store.dataSource._fixtures = null;
@wagenet

Interesting. Seems like it shouldn't be hard to automate that.

@wagenet

@svenfuchs, would a MyApp.store.reset() function do the trick? I could probably set one up that calls reset on the dataSource which in this case would be set up to clear out _fixtures.

@wagenet wagenet closed this in 2f1cc85 May 27, 2011
@wagenet

I just added a reset function to the fixtures data source. I also updated SC.Store.reset to call the reset on the datasource if it has one. So, you should be able to set up a teardown in your test modules that calls Travis.store.reset(). Hope that helps.

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