Use factory_girl_rails for factories

This commit is contained in:
Thibault Jouan
2011-07-25 22:08:45 +00:00
parent 6af96b0f75
commit 47fa969617
8 changed files with 35 additions and 35 deletions

View File

@@ -1,15 +1,9 @@
require 'spec_helper'
describe TracksController do
def valid_attributes
{
:name => 'Mega song'
}
end
describe 'GET show' do
it 'assigns the requested track as @track' do
track = Track.create! valid_attributes
track = Factory.create(:track)
get :show, :id => track.id.to_s
assigns[:track].should == track
end
@@ -28,9 +22,9 @@ describe TracksController do
it 'creates a new track' do
Track.should_receive(:new).
with(:name => 'Mega song').
with(Factory.attributes_for(:track)).
and_return(track)
post :create, :track => valid_attributes
post :create, :track => Factory.attributes_for(:track)
end
it 'saves the track' do
@@ -46,7 +40,7 @@ describe TracksController do
context 'when the track saves successfully' do
it 'redirects to the track page' do
post :create, :track => valid_attributes
post :create, :track => Factory.attributes_for(:track)
response.should redirect_to(track)
end
end