Browse files

Specify the feature for creating a blog post

We start by writing out an acceptance test for the full feature we want to implement. In this case, we want to visit a blog post creation page, enter a title and body, save it, and then see on the results page that title and body, as well as confirming it’s in the database.

Red: No route matches [GET] "/blog_posts/new"

The first error we get is that there is no blog-posts/new route.
  • Loading branch information...
CodingItWrong committed Feb 23, 2016
1 parent f91478f commit a5cea8f9c947f8f417a39d55c34b4b0393d18d40
Showing with 21 additions and 0 deletions.
  1. +21 −0 spec/features/creating_a_blog_post_spec.rb
@@ -0,0 +1,21 @@
require 'rails_helper'
describe 'Creating a blog post' do
it 'saves and displays the resulting blog post' do
visit '/blog_posts/new'
fill_in 'Title', with: 'Hello, World!'
fill_in 'Body', with: 'Hello, I say!'
click_on 'Create Blog Post'
expect(page).to have_content('Hello, World!')
expect(page).to have_content('Hello, I say!')
blog_post = BlogPost.order("id").last
expect(blog_post.title).to eq('Hello, World!')
expect(blog_post.body).to eq('Hello, I say!')

0 comments on commit a5cea8f

Please sign in to comment.