From e1c8a6038dc60db03c52be25020d2c6edc7e80b5 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Fri, 1 May 2015 11:40:11 +0000 Subject: [PATCH] Simplify playlists CRUD specs --- spec/features/playlists/crud_spec.rb | 24 ++---------------------- spec/support/acceptance_helpers.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/spec/features/playlists/crud_spec.rb b/spec/features/playlists/crud_spec.rb index f893071..aa5d000 100644 --- a/spec/features/playlists/crud_spec.rb +++ b/spec/features/playlists/crud_spec.rb @@ -3,31 +3,11 @@ feature 'Playlists CRUD' do background { sign_in } - scenario 'lists playlists' do - FactoryGirl.create(:playlist, name: 'Electro') - FactoryGirl.create(:playlist, name: 'Reggae') - - visit playlists_path - - expect(page.body).to match /Electro.+Reggae/m - end - - scenario 'creates playlist' do - visit playlists_path - - click_link 'Create playlist' - fill_in 'Name', with: 'Electro' - click_button 'Create' - - expect(current_path).to eq playlists_path - expect(page).to have_content 'Electro' - end - scenario 'edits playlist' do - FactoryGirl.create(:playlist, name: 'Electro') + playlist = create_playlist visit playlists_path - click_link 'Electro' + click_link playlist[:name] fill_in 'Name', with: 'Rock' click_button 'Save' diff --git a/spec/support/acceptance_helpers.rb b/spec/support/acceptance_helpers.rb index c4775f3..66fef94 100644 --- a/spec/support/acceptance_helpers.rb +++ b/spec/support/acceptance_helpers.rb @@ -15,4 +15,13 @@ module AcceptanceHelpers password: user.password } end + + def create_playlist + playlist = attributes_for :playlist + visit playlists_path + click_link 'Create playlist' + fill_in 'Name', with: playlist[:name] + click_button 'Create' + playlist + end end