From eda2f3fbee232e1119e320df52f107161c38c976 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Tue, 1 Apr 2014 05:04:27 +0000 Subject: [PATCH] Update factory girl to last version --- Gemfile | 2 +- spec/controllers/api/playlists_controller_spec.rb | 6 +++--- spec/controllers/api/sessions_controller_spec.rb | 2 +- spec/controllers/api/tracks_controller_spec.rb | 4 ++-- spec/controllers/application_controller_spec.rb | 2 +- spec/controllers/home_controller_spec.rb | 6 +++--- spec/controllers/playlists_controller_spec.rb | 8 ++++---- spec/controllers/sessions_controller_spec.rb | 2 +- spec/controllers/sounds_controller_spec.rb | 2 +- spec/controllers/tracks_controller_spec.rb | 4 ++-- spec/controllers/users_controller_spec.rb | 6 +++--- spec/integration/api/api_sign_in_spec.rb | 2 +- spec/integration/api/cross_origin_request_spec.rb | 2 +- spec/integration/api/playlists_spec.rb | 2 +- spec/integration/api/tracks_spec.rb | 4 ++-- spec/integration/home_spec.rb | 6 +++--- spec/integration/playlists_spec.rb | 6 +++--- spec/integration/tracks_spec.rb | 4 ++-- spec/integration/user_sign_in_spec.rb | 2 +- spec/integration/user_sign_up_spec.rb | 2 +- spec/models/playlist_spec.rb | 2 +- spec/models/sound_spec.rb | 4 ++-- spec/models/track_spec.rb | 12 ++++++------ spec/models/user_spec.rb | 6 +++--- spec/support/user_controllers_helpers.rb | 2 +- spec/support/user_integration_helpers.rb | 4 ++-- spec/views/tracks/show.html.haml_spec.rb | 4 ++-- spec/views/users/new.html.haml_spec.rb | 4 ++-- 28 files changed, 56 insertions(+), 56 deletions(-) diff --git a/Gemfile b/Gemfile index 4d94239..7813f84 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem 'rabl', '~> 0.6' group :development, :test do gem 'rspec-rails', '~> 2.6' gem 'capybara', '~> 1.1' - gem 'factory_girl_rails', '~> 1.2' + gem 'factory_girl_rails', '~> 4.4' gem 'shoulda-matchers', '~> 1.0' end diff --git a/spec/controllers/api/playlists_controller_spec.rb b/spec/controllers/api/playlists_controller_spec.rb index 3e34a5f..4e4d5e8 100644 --- a/spec/controllers/api/playlists_controller_spec.rb +++ b/spec/controllers/api/playlists_controller_spec.rb @@ -11,8 +11,8 @@ describe API::PlaylistsController do render_views before do - playlist_1 = Factory.create(:playlist, :name => 'Playlist 1') - playlist_2 = Factory.create(:playlist, :name => 'Playlist 2') + playlist_1 = FactoryGirl.create(:playlist, :name => 'Playlist 1') + playlist_2 = FactoryGirl.create(:playlist, :name => 'Playlist 2') end def do_get @@ -37,7 +37,7 @@ describe API::PlaylistsController do def do_create post :create, :format => :json, - :playlist => Factory.attributes_for(:playlist) + :playlist => FactoryGirl.attributes_for(:playlist) end it 'creates a new playlist for the current user' do diff --git a/spec/controllers/api/sessions_controller_spec.rb b/spec/controllers/api/sessions_controller_spec.rb index c23aea3..37c2bd8 100644 --- a/spec/controllers/api/sessions_controller_spec.rb +++ b/spec/controllers/api/sessions_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe API::SessionsController do describe 'POST create' do - let(:user) { Factory.create(:user) } + let(:user) { FactoryGirl.create(:user) } def do_create post :create, :format => :json, :session => { diff --git a/spec/controllers/api/tracks_controller_spec.rb b/spec/controllers/api/tracks_controller_spec.rb index 2783f71..e9539eb 100644 --- a/spec/controllers/api/tracks_controller_spec.rb +++ b/spec/controllers/api/tracks_controller_spec.rb @@ -11,8 +11,8 @@ describe API::TracksController do render_views before do - Factory.create(:track_with_sound) - Factory.create(:track_with_sound) + FactoryGirl.create(:track_with_sound) + FactoryGirl.create(:track_with_sound) end def do_get diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 18946ba..66485db 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe ApplicationController do - let(:user) { Factory.create(:user) } + let(:user) { FactoryGirl.create(:user) } describe '#current_user=' do it 'stores the user id in the session as :user_id' do diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 4cef034..f96a542 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -9,14 +9,14 @@ describe HomeController do describe 'GET index' do it 'assigns all playlists as @playlists' do - playlist = Factory.create(:playlist) + playlist = FactoryGirl.create(:playlist) get :index assigns[:playlists].should == [playlist] end it 'assigns latest tracks as @tracks' do - track1 = Factory.create(:track, :created_at => '2011-07-27 19:13:42') - track2 = Factory.create(:track, :created_at => '2011-07-27 19:58:57') + track1 = FactoryGirl.create(:track, :created_at => '2011-07-27 19:13:42') + track2 = FactoryGirl.create(:track, :created_at => '2011-07-27 19:58:57') get :index assigns[:tracks].should == Track.latest end diff --git a/spec/controllers/playlists_controller_spec.rb b/spec/controllers/playlists_controller_spec.rb index 27ba1a9..ca0fa0f 100644 --- a/spec/controllers/playlists_controller_spec.rb +++ b/spec/controllers/playlists_controller_spec.rb @@ -9,7 +9,7 @@ describe PlaylistsController do describe 'GET index' do it 'assigns all playlists as @playlists' do - playlist = Factory.create(:playlist) + playlist = FactoryGirl.create(:playlist) get :index assigns[:playlists].should == [playlist] end @@ -24,7 +24,7 @@ describe PlaylistsController do describe 'GET edit' do it 'assigns the requested playlist as @playlist' do - playlist = Factory.create(:playlist) + playlist = FactoryGirl.create(:playlist) get :edit, :id => playlist.id.to_s assigns[:playlist].should == playlist end @@ -32,7 +32,7 @@ describe PlaylistsController do describe 'POST create' do def do_create - post :create, :playlist => Factory.attributes_for(:playlist) + post :create, :playlist => FactoryGirl.attributes_for(:playlist) end context 'whith valid params' do @@ -64,7 +64,7 @@ describe PlaylistsController do end describe 'PUT update' do - let (:playlist) { Factory.create(:playlist) } + let (:playlist) { FactoryGirl.create(:playlist) } def do_update put :update, :id => playlist.id.to_s, :playlist => { :name => 'Rock' } diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index e5d7337..ea66bbf 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -8,7 +8,7 @@ describe SessionsController do end describe 'POST create' do - let(:user) { Factory.create(:user) } + let(:user) { FactoryGirl.create(:user) } def do_create post :create, :session => { diff --git a/spec/controllers/sounds_controller_spec.rb b/spec/controllers/sounds_controller_spec.rb index 69b2129..d64419b 100644 --- a/spec/controllers/sounds_controller_spec.rb +++ b/spec/controllers/sounds_controller_spec.rb @@ -8,7 +8,7 @@ describe SoundsController do end describe 'GET show' do - let(:sound) { Factory.create(:sound) } + let(:sound) { FactoryGirl.create(:sound) } def do_show get :show, :id => sound.id diff --git a/spec/controllers/tracks_controller_spec.rb b/spec/controllers/tracks_controller_spec.rb index 4e3a87a..e203fd8 100644 --- a/spec/controllers/tracks_controller_spec.rb +++ b/spec/controllers/tracks_controller_spec.rb @@ -9,7 +9,7 @@ describe TracksController do describe 'GET show' do it 'assigns the requested track as @track' do - track = Factory.create(:track) + track = FactoryGirl.create(:track) get :show, :id => track.id.to_s assigns[:track].should == track end @@ -24,7 +24,7 @@ describe TracksController do describe 'POST create new' do def do_create - post :create, :track => Factory.attributes_for(:track).merge({ + post :create, :track => FactoryGirl.attributes_for(:track).merge({ :file => fixture_file_upload( "#{Rails.root}/spec/fixtures/test.mp3", 'audio/mpeg' diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index fbf39a7..e64b606 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -12,17 +12,17 @@ describe UsersController do context 'whith valid params' do it 'creates a new user' do expect { - post :create, :user => Factory.attributes_for(:user) + post :create, :user => FactoryGirl.attributes_for(:user) }.to change(User, :count).by(1) end it 'signs the user in' do - post :create, :user => Factory.attributes_for(:user) + post :create, :user => FactoryGirl.attributes_for(:user) controller.current_user.should_not be_nil end it 'redirects to the home page' do - post :create, :user => Factory.attributes_for(:user) + post :create, :user => FactoryGirl.attributes_for(:user) response.should redirect_to(:root) end end diff --git a/spec/integration/api/api_sign_in_spec.rb b/spec/integration/api/api_sign_in_spec.rb index 5ab63af..bdf3c1b 100644 --- a/spec/integration/api/api_sign_in_spec.rb +++ b/spec/integration/api/api_sign_in_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'API sign in' do - let(:user) { Factory.create(:user) } + let(:user) { FactoryGirl.create(:user) } def do_create post api_sessions_path, :format => :json, :session => { diff --git a/spec/integration/api/cross_origin_request_spec.rb b/spec/integration/api/cross_origin_request_spec.rb index a17fde2..5fb52ca 100644 --- a/spec/integration/api/cross_origin_request_spec.rb +++ b/spec/integration/api/cross_origin_request_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature 'API cross origin request' do include UserIntegrationHelpers - let(:user) { Factory.create(:user) } + let(:user) { FactoryGirl.create(:user) } let(:origin) { 'http://origin.example/' } background do diff --git a/spec/integration/api/playlists_spec.rb b/spec/integration/api/playlists_spec.rb index 024b922..96b4456 100644 --- a/spec/integration/api/playlists_spec.rb +++ b/spec/integration/api/playlists_spec.rb @@ -8,7 +8,7 @@ feature 'API playlists' do end scenario 'creates playlist' do - playlist = Factory.attributes_for :playlist + playlist = FactoryGirl.attributes_for :playlist post api_playlists_path, :format => :json, diff --git a/spec/integration/api/tracks_spec.rb b/spec/integration/api/tracks_spec.rb index 54432c5..1bd5977 100644 --- a/spec/integration/api/tracks_spec.rb +++ b/spec/integration/api/tracks_spec.rb @@ -8,8 +8,8 @@ feature 'API tracks' do end scenario 'lists tracks' do - track_1 = Factory.create(:track_with_sound, :name => 'Track 1') - track_2 = Factory.create(:track, :name => 'Track 2') + track_1 = FactoryGirl.create(:track_with_sound, :name => 'Track 1') + track_2 = FactoryGirl.create(:track, :name => 'Track 2') get api_tracks_path, :format => :json diff --git a/spec/integration/home_spec.rb b/spec/integration/home_spec.rb index 70a741f..5693083 100644 --- a/spec/integration/home_spec.rb +++ b/spec/integration/home_spec.rb @@ -8,7 +8,7 @@ feature 'Home page' do end scenario 'displays playlists' do - playlist = Factory.create(:playlist, :name => 'Electro') + playlist = FactoryGirl.create(:playlist, :name => 'Electro') visit root_path @@ -16,11 +16,11 @@ feature 'Home page' do end scenario 'displays last track added' do - Factory.create(:track, + FactoryGirl.create(:track, :name => 'Mega song 1', :created_at => '2011-07-27 19:13:42' ) - Factory.create(:track, + FactoryGirl.create(:track, :name => 'Mega song 2', :created_at => '2011-07-27 19:58:57' ) diff --git a/spec/integration/playlists_spec.rb b/spec/integration/playlists_spec.rb index b4fee6b..0aa8a49 100644 --- a/spec/integration/playlists_spec.rb +++ b/spec/integration/playlists_spec.rb @@ -8,8 +8,8 @@ feature 'Playlists' do end scenario 'lists playlists' do - Factory.create(:playlist, :name => 'Electro') - Factory.create(:playlist, :name => 'Reggae') + FactoryGirl.create(:playlist, :name => 'Electro') + FactoryGirl.create(:playlist, :name => 'Reggae') visit playlists_path @@ -28,7 +28,7 @@ feature 'Playlists' do end scenario 'edits playlist' do - Factory.create(:playlist, :name => 'Electro') + FactoryGirl.create(:playlist, :name => 'Electro') visit playlists_path click_link 'Electro' diff --git a/spec/integration/tracks_spec.rb b/spec/integration/tracks_spec.rb index 2d960c8..ca8a158 100644 --- a/spec/integration/tracks_spec.rb +++ b/spec/integration/tracks_spec.rb @@ -8,7 +8,7 @@ feature 'Tracks' do end scenario 'shows track' do - track = Factory.create(:track, :name => 'Mega song') + track = FactoryGirl.create(:track, :name => 'Mega song') visit track_path(track) @@ -28,7 +28,7 @@ feature 'Tracks' do end scenario 'plays track' do - track = Factory.create(:track_with_sound) + track = FactoryGirl.create(:track_with_sound) visit track_path(track) diff --git a/spec/integration/user_sign_in_spec.rb b/spec/integration/user_sign_in_spec.rb index badb00c..781999b 100644 --- a/spec/integration/user_sign_in_spec.rb +++ b/spec/integration/user_sign_in_spec.rb @@ -8,7 +8,7 @@ feature 'User sign in' do end scenario 'signs the user in' do - user = Factory.create(:user) + user = FactoryGirl.create(:user) visit new_session_path fill_in 'Email', :with => user.email diff --git a/spec/integration/user_sign_up_spec.rb b/spec/integration/user_sign_up_spec.rb index c32287d..d69a5a2 100644 --- a/spec/integration/user_sign_up_spec.rb +++ b/spec/integration/user_sign_up_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'User sign up' do - let(:user) { Factory.build(:user) } + let(:user) { FactoryGirl.build(:user) } background do visit new_user_path diff --git a/spec/models/playlist_spec.rb b/spec/models/playlist_spec.rb index 1c1bb07..d3a3e17 100644 --- a/spec/models/playlist_spec.rb +++ b/spec/models/playlist_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Playlist do subject { playlist } - let(:playlist) { Factory.build(:playlist) } + let(:playlist) { FactoryGirl.build(:playlist) } it { should be_valid } it { should belong_to :user } diff --git a/spec/models/sound_spec.rb b/spec/models/sound_spec.rb index 9f110de..758660b 100644 --- a/spec/models/sound_spec.rb +++ b/spec/models/sound_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Sound do subject { sound } - let(:sound) { Factory.build(:sound) } + let(:sound) { FactoryGirl.build(:sound) } it { should be_valid } it { should belong_to :track } @@ -20,7 +20,7 @@ describe Sound do end describe '#file=' do - let (:file) { Factory.attributes_for(:sound)[:file] } + let (:file) { FactoryGirl.attributes_for(:sound)[:file] } it 'saves the file SHA256 digest' do sound.sha256.should == Digest::SHA256.file(file.path).hexdigest diff --git a/spec/models/track_spec.rb b/spec/models/track_spec.rb index 62e4ecf..e9a340d 100644 --- a/spec/models/track_spec.rb +++ b/spec/models/track_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe Track do subject { track } - let(:track) { Factory.build(:track) } - let(:file) { Factory.attributes_for(:track_with_sound)[:file] } + let(:track) { FactoryGirl.build(:track) } + let(:file) { FactoryGirl.attributes_for(:track_with_sound)[:file] } it { should be_valid } it { should have_many :sounds } @@ -34,7 +34,7 @@ describe Track do describe '#sound' do context 'with a sound' do before do - track.sounds << Factory.create(:sound) + track.sounds << FactoryGirl.create(:sound) end it 'returns a sound' do @@ -52,7 +52,7 @@ describe Track do context 'with a sound' do before do - track.sounds << Factory.create(:sound) + track.sounds << FactoryGirl.create(:sound) end it 'returns true' do @@ -63,8 +63,8 @@ describe Track do describe '.latest' do it 'returns latest tracks in descending creation date order' do - track1 = Factory.create(:track, :created_at => '2011-07-27 19:13:42') - track2 = Factory.create(:track, :created_at => '2011-07-27 19:58:57') + track1 = FactoryGirl.create(:track, :created_at => '2011-07-27 19:13:42') + track2 = FactoryGirl.create(:track, :created_at => '2011-07-27 19:58:57') Track.latest.should == [track2, track1] end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b092228..ae2fae0 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe User do subject { user } - let(:user) { Factory.build(:user) } + let(:user) { FactoryGirl.build(:user) } it { should be_valid } it { should have_many :playlists } @@ -12,8 +12,8 @@ describe User do it { should_not allow_mass_assignment_of :password_hash } context 'when a user with the same email address already exists' do - let(:old_user) { Factory.create(:user, :email => 'unique@example.net') } - subject { Factory.build(:user, :email => old_user.email) } + let(:old_user) { FactoryGirl.create(:user, :email => 'unique@example.net') } + subject { FactoryGirl.build(:user, :email => old_user.email) } it { should_not be_valid } diff --git a/spec/support/user_controllers_helpers.rb b/spec/support/user_controllers_helpers.rb index f8569f2..58a1c7e 100644 --- a/spec/support/user_controllers_helpers.rb +++ b/spec/support/user_controllers_helpers.rb @@ -1,5 +1,5 @@ module UserControllerHelpers def sign_in - controller.current_user = Factory.create(:user) + controller.current_user = FactoryGirl.create(:user) end end diff --git a/spec/support/user_integration_helpers.rb b/spec/support/user_integration_helpers.rb index 5336be8..5d1d8a9 100644 --- a/spec/support/user_integration_helpers.rb +++ b/spec/support/user_integration_helpers.rb @@ -1,6 +1,6 @@ module UserIntegrationHelpers def sign_in - user = Factory.create(:user) + user = FactoryGirl.create(:user) visit new_session_path fill_in 'Email', :with => user.email fill_in 'Password', :with => user.password @@ -8,7 +8,7 @@ module UserIntegrationHelpers end def api_sign_in - user = Factory.create :user + user = FactoryGirl.create :user post api_sessions_path, :format => :json, :session => { :email => user.email, diff --git a/spec/views/tracks/show.html.haml_spec.rb b/spec/views/tracks/show.html.haml_spec.rb index aab3a12..4d956df 100644 --- a/spec/views/tracks/show.html.haml_spec.rb +++ b/spec/views/tracks/show.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'tracks/show' do - let(:track) { Factory.create(:track) } + let(:track) { FactoryGirl.create(:track) } before do assign :track, track @@ -13,7 +13,7 @@ describe 'tracks/show' do end context 'when track has a sound' do - let(:track) { Factory.create(:track_with_sound) } + let(:track) { FactoryGirl.create(:track_with_sound) } it 'provides an audio stream for the track' do render diff --git a/spec/views/users/new.html.haml_spec.rb b/spec/views/users/new.html.haml_spec.rb index 04c5a66..a13c50a 100644 --- a/spec/views/users/new.html.haml_spec.rb +++ b/spec/views/users/new.html.haml_spec.rb @@ -48,8 +48,8 @@ describe 'users/new' do context 'when the user has some validation errors' do it 'on the email address uniqueness' do - user = Factory.create(:user, :email => 'unique@example.net') - new_user = Factory.build(:user, :email => user.email) + user = FactoryGirl.create(:user, :email => 'unique@example.net') + new_user = FactoryGirl.build(:user, :email => user.email) new_user.save assign :user, new_user render