diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 4f6d530..2ece24f 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -1,5 +1,5 @@ describe ApplicationController do - let(:user) { FactoryGirl.create(:user) } + let(:user) { create :user } describe '#current_user=' do it 'stores the user id in the session as :user_id' do diff --git a/spec/features/sessions/sign_in_spec.rb b/spec/features/sessions/sign_in_spec.rb index 27a2899..1902004 100644 --- a/spec/features/sessions/sign_in_spec.rb +++ b/spec/features/sessions/sign_in_spec.rb @@ -6,7 +6,7 @@ feature 'User sign in' do end scenario 'signs the user in' do - user = FactoryGirl.create(:user) + user = create :user visit new_session_path fill_in 'Email', with: user.email diff --git a/spec/features/sessions/sign_up_spec.rb b/spec/features/sessions/sign_up_spec.rb index 21a618f..a7f2827 100644 --- a/spec/features/sessions/sign_up_spec.rb +++ b/spec/features/sessions/sign_up_spec.rb @@ -1,5 +1,5 @@ feature 'User sign up' do - let(:user) { FactoryGirl.build(:user) } + let(:user) { build :user } background do visit new_user_path diff --git a/spec/features/tracks/player_spec.rb b/spec/features/tracks/player_spec.rb index e805cef..cef980e 100644 --- a/spec/features/tracks/player_spec.rb +++ b/spec/features/tracks/player_spec.rb @@ -4,7 +4,7 @@ feature 'Tracks player' do background { sign_in } scenario 'includes a player in track page' do - track = FactoryGirl.create(:track_with_sound) + track = create :track_with_sound visit track_path(track) diff --git a/spec/integration/api/cross_origin_request_spec.rb b/spec/integration/api/cross_origin_request_spec.rb index c59a7d0..2b0f7ed 100644 --- a/spec/integration/api/cross_origin_request_spec.rb +++ b/spec/integration/api/cross_origin_request_spec.rb @@ -1,7 +1,7 @@ describe 'API cross origin request' do include AcceptanceHelpers - let(:user) { FactoryGirl.create(:user) } + let(:user) { create :user } let(:origin) { 'http://origin.example/' } before do diff --git a/spec/models/playlist_spec.rb b/spec/models/playlist_spec.rb index 2deaa9e..7cb7671 100644 --- a/spec/models/playlist_spec.rb +++ b/spec/models/playlist_spec.rb @@ -1,6 +1,6 @@ describe Playlist do subject { playlist } - let(:playlist) { FactoryGirl.build(:playlist) } + let(:playlist) { build :playlist } it { is_expected.to be_valid } it { is_expected.to belong_to :user } diff --git a/spec/models/sound_spec.rb b/spec/models/sound_spec.rb index 43960fc..02e0a14 100644 --- a/spec/models/sound_spec.rb +++ b/spec/models/sound_spec.rb @@ -1,6 +1,6 @@ describe Sound do subject { sound } - let(:sound) { FactoryGirl.build(:sound) } + let(:sound) { build :sound } it { is_expected.to be_valid } it { is_expected.to belong_to :track } @@ -19,7 +19,7 @@ describe Sound do end describe '#file=' do - let(:file) { FactoryGirl.attributes_for(:sound)[:file] } + let(:file) { attributes_for(:sound)[:file] } it 'saves the file SHA256 digest' do expect(sound.sha256).to eq Digest::SHA256.file(file.path).hexdigest diff --git a/spec/models/track_spec.rb b/spec/models/track_spec.rb index 1cd3846..6e928ab 100644 --- a/spec/models/track_spec.rb +++ b/spec/models/track_spec.rb @@ -1,7 +1,7 @@ describe Track do subject { track } - let(:track) { FactoryGirl.build(:track) } - let(:file) { FactoryGirl.attributes_for(:track_with_sound)[:file] } + let(:track) { build :track } + let(:file) { attributes_for(:track_with_sound)[:file] } it { is_expected.to be_valid } it { is_expected.to have_many :sounds } @@ -30,7 +30,7 @@ describe Track do describe '#sound' do context 'with a sound' do - before { track.sounds << FactoryGirl.create(:sound) } + before { track.sounds << create(:sound) } it 'returns a sound' do expect(track.sound).to be_a Sound @@ -46,7 +46,7 @@ describe Track do end context 'with a sound' do - before { track.sounds << FactoryGirl.create(:sound) } + before { track.sounds << create(:sound) } it 'returns true' do expect(track.sound?).to be true @@ -56,8 +56,8 @@ describe Track do describe '.latest' do it 'returns latest tracks in descending creation date order' do - track1 = FactoryGirl.create(:track, created_at: '2011-07-27 19:13:42') - track2 = FactoryGirl.create(:track, created_at: '2011-07-27 19:58:57') + track1 = create :track, created_at: '2011-07-27 19:13:42' + track2 = create :track, created_at: '2011-07-27 19:58:57' expect(Track.latest).to eq [track2, track1] end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 3be8156..1601813 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,5 +1,5 @@ describe User do - subject(:user) { FactoryGirl.build(:user) } + subject(:user) { build :user } it { is_expected.to be_valid } it { is_expected.to have_many :playlists } @@ -8,8 +8,8 @@ describe User do it { is_expected.to validate_presence_of :password_hash } context 'when a user with the same email address already exists' do - let(:old_user) { FactoryGirl.create(:user, email: 'unique@example.net') } - subject(:user) { FactoryGirl.build(:user, email: old_user.email) } + let(:old_user) { create :user, email: 'unique@example.net' } + subject(:user) { build :user, email: old_user.email } it { is_expected.to_not be_valid }