Skip to content
Browse files

Specify show page should display model from the database

Outer red:
✘ Element .js-post-detail-title has text "Test Post"
✘ Element .js-post-detail-body has text "This post is a test!"

We create a new acceptance test for viewing a page. We use Mirage's `server.create()` method to create a test post directly in our fake backend. We specify
that, when the post view page is shown, the post's title and body are visible.

The test fails because no title is being outputted on the page. This is the problem that happens when we don't define attributes on our model.
  • Loading branch information...
CodingItWrong committed Jan 11, 2018
1 parent b6593ff commit bc5989609ead6ea3a834208208169782b69e9b56
Showing with 20 additions and 0 deletions.
  1. +20 −0 tests/acceptance/viewing-a-blog-post-test.js
@@ -0,0 +1,20 @@
import { module, test } from 'qunit';
import { visit } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';

module('Acceptance | viewing a blog post', function(hooks) {

test('viewing a blog post', async function(assert) {
let post = server.create('post', {
title: 'Test Post',
body: 'This post is a test!'
await visit(`/posts/${}`);

assert.dom('.js-post-detail-title').hasText('Test Post');
assert.dom('.js-post-detail-body').hasText('This post is a test!');

0 comments on commit bc59896

Please sign in to comment.
You can’t perform that action at this time.