From 9c9fdcf4dafc609ea344b58649dfaf83c5d73276 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Fri, 1 May 2015 15:15:28 +0000 Subject: [PATCH] Refactor AcceptanceHelpers --- spec/support/acceptance_helpers.rb | 49 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/spec/support/acceptance_helpers.rb b/spec/support/acceptance_helpers.rb index 2358c1e..53fe41b 100644 --- a/spec/support/acceptance_helpers.rb +++ b/spec/support/acceptance_helpers.rb @@ -1,38 +1,39 @@ module AcceptanceHelpers def sign_in - user = FactoryGirl.create(:user) - visit new_session_path - fill_in 'Email', with: user.email - fill_in 'Password', with: user.password - click_button('Sign in') + create :user do |o| + visit new_session_path + fill_in 'Email', with: o.email + fill_in 'Password', with: o.password + click_button 'Sign in' + end end def api_sign_in - user = FactoryGirl.create :user - - post_via_redirect api_sessions_path, format: :json, session: { - email: user.email, - password: user.password - } + create :user do |o| + post api_sessions_path, format: :json, session: { + email: o.email, + password: o.password + } + end 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 + attributes_for :playlist do |o| + visit playlists_path + click_link 'Create playlist' + fill_in 'Name', with: o[:name] + click_button 'Create' + end end def create_track file: false - track = attributes_for(file ? :track_with_sound : :track) - visit tracks_path - click_link 'Create track' - fill_in 'Name', with: track[:name] - attach_file 'File', track[:file].path if file - click_button 'Upload' - track + attributes_for file ? :track_with_sound : :track do |o| + visit tracks_path + click_link 'Create track' + fill_in 'Name', with: o[:name] + attach_file 'File', o[:file].path if file + click_button 'Upload' + end end def json