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

Cannot get record in tests #33

Closed
cibernox opened this issue Feb 26, 2015 · 4 comments
Closed

Cannot get record in tests #33

cibernox opened this issue Feb 26, 2015 · 4 comments

Comments

@cibernox
Copy link
Collaborator

I'm not sure of that's going on, but I can't get individial records in tests.

The exact error is:

Pretender intercepted GET /api/schools/1 but encountered an error: Cannot read property 'findBy' of undefined

that references to this line: https://github.com/samselikoff/ember-pretenderify/blob/ab7f70d0073e14a047ac753152d39573743212e7/addon/store.js#L27

My config.js:

export default function() {
  this.namespace = 'api';
  this.timing = 100;

  this.get('/schools/:id');
  this.get('/schools');
  this.get('/teachers/:id');
  this.get('/teachers');
}

and my fixtures in app/pretender/data/schools.js

export default [
  {
    id: 1,
    name: "Copley High School",
    subdomain: "copley",
    school_type: 'secondary_school',
    address: '11 Test Road',
    teachers: [1, 2]
  }, {
    id: 2,
    name: "Tendring Tech",
    subdomain: "tendringtech",
    school_type: 'secondary_school',
    address: '11 Test Road',
    teachers: [3]
  }, 
  /* and a few more */
];

Everything seems to be by the book, but in my acceptance tests it fails. The only special bit is that I'm using ember-cli-simple-auth and ember-cli-simple-auth-oauth2, but I don't see why it would affect this.

I'm open to pairing to fix this is that helps

@samselikoff
Copy link
Collaborator

Some better error handling would sure be helpful :)

Does it work in development? i.e. when you run ember serve?

The fixtures don't actually work in tests, you use factories instead. Check out the acceptance testing section part of the readme and let me know if it makes sense.

@cibernox
Copy link
Collaborator Author

@samselikoff I saw this after opening this PR. I was fighting this error yesterday afternoon and this morning you release the new version with the factories. #maximum-trolling

@cibernox
Copy link
Collaborator Author

I'll close this while I explore the possibility of using factories. Factories look more interesting that just using static fixtures.

@samselikoff
Copy link
Collaborator

Haha, ok great. The wiki has the guides now, too, fyi.

The fixtures are really there to be an easy way to get some test data in for development

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