Skip to content

Commit

Permalink
Install ember-cli-mirage.
Browse files Browse the repository at this point in the history
  • Loading branch information
pattisdr committed May 23, 2017
1 parent 9dbb964 commit df17cd2
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"predef": [
"server",
"document",
"window",
"-Promise"
Expand Down
40 changes: 40 additions & 0 deletions mirage/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export default function() {

// These comments are here to help you get started. Feel free to delete them.

/*
Config (with defaults).
Note: these only affect routes defined *after* them!
*/

// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
// this.namespace = ''; // make this `/api`, for example, if your API is namespaced
// this.timing = 400; // delay for each request, automatically set to 0 during testing

/*
Shorthand cheatsheet:
this.get('/posts');
this.post('/posts');
this.get('/posts/:id');
this.put('/posts/:id'); // or this.patch
this.del('/posts/:id');
http://www.ember-cli-mirage.com/docs/v0.3.x/shorthands/
*/
this.namespace = '/api';
this.get('/studies/:id', function() {
return {
'data': {
id: '12345',
type: 'study',
attributes: {
'name': 'Title of my study',
'duration': '20 minutes'
}
}
}
});
}
11 changes: 11 additions & 0 deletions mirage/scenarios/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default function(/* server */) {

/*
Seed your development database using your factories.
This data will not be loaded in your tests.
Make sure to define a factory for each model you want to create.
*/

// server.createList('post', 10);
}
4 changes: 4 additions & 0 deletions mirage/serializers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { JSONAPISerializer } from 'ember-cli-mirage';

export default JSONAPISerializer.extend({
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-inject-live-reload": "^1.4.0",
"ember-cli-jshint": "^1.0.0",
"ember-cli-mirage": "0.3.1",
"ember-cli-qunit": "^2.1.0",
"ember-cli-release": "^0.2.9",
"ember-cli-sri": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions tests/.jshintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"predef": [
"server",
"document",
"window",
"location",
Expand Down
3 changes: 3 additions & 0 deletions tests/helpers/destroy-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ import Ember from 'ember';

export default function destroyApp(application) {
Ember.run(application, 'destroy');
if(window.server) {
window.server.shutdown();
}
}

0 comments on commit df17cd2

Please sign in to comment.