From ce9aa18178f488df63f8e3b63a2761310e4e1805 Mon Sep 17 00:00:00 2001 From: Erik Brendel Date: Fri, 3 Nov 2017 17:54:27 +0100 Subject: [PATCH] Refs #12: red test --- spec/features/author/new_author_spec.rb | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/spec/features/author/new_author_spec.rb b/spec/features/author/new_author_spec.rb index 1f88d5d..906eab7 100644 --- a/spec/features/author/new_author_spec.rb +++ b/spec/features/author/new_author_spec.rb @@ -1,12 +1,11 @@ require 'rails_helper' -describe "New author page", type: :feature do - - it "should render withour error" do +describe 'New author page', type: :feature do + it 'should render withour error' do visit new_author_path end - it "should have text input for first name, last name, and homepage" do + it 'should have text input for first name, last name, and homepage' do visit new_author_path expect(page).to have_field('First name') @@ -14,15 +13,22 @@ expect(page).to have_field('Homepage') end - it "should save the entered values to the database" do + it 'should save the entered values to the database' do visit new_author_path - fill_in "author_first_name", :with => 'Alan' - fill_in "author_last_name", :with => 'Turing' - fill_in "author_homepage", :with => 'http://wikipedia.org/Alan_Turing' + fill_in 'author_first_name', with: 'Alan' + fill_in 'author_last_name', with: 'Turing' + fill_in 'author_homepage', with: 'http://wikipedia.org/Alan_Turing' find('input[type="submit"]').click expect(Author.find_by_first_name('Alan')).not_to be_nil - end -end \ No newline at end of file + it 'should display error messages when the created author is not valid' do + visit new_author_path + fill_in 'author_first_name', with: 'Alan' + fill_in 'author_homepage', with: 'http://wikipedia.org/Alan_Turing' + find('input[type="submit"]').click + + expect(page.text).to match(/last name can't be blank/i) + end +end