Update factory girl to last version

This commit is contained in:
Thibault Jouan 2014-04-01 05:04:27 +00:00
parent d2b332215e
commit eda2f3fbee
28 changed files with 56 additions and 56 deletions

View File

@ -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

View File

@ -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

View File

@ -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 => {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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' }

View File

@ -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 => {

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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 => {

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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'
)

View File

@ -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'

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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 }

View File

@ -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

View File

@ -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

View File

@ -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 }

View File

@ -1,5 +1,5 @@
module UserControllerHelpers
def sign_in
controller.current_user = Factory.create(:user)
controller.current_user = FactoryGirl.create(:user)
end
end

View File

@ -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,

View File

@ -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

View File

@ -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