Use ruby 2.x hash syntax

This commit is contained in:
Thibault Jouan
2014-04-01 10:48:18 +00:00
parent 712e9501a2
commit da96c4814a
52 changed files with 148 additions and 148 deletions

View File

@@ -11,12 +11,12 @@ describe API::PlaylistsController do
render_views
before do
playlist_1 = FactoryGirl.create(:playlist, :name => 'Playlist 1')
playlist_2 = FactoryGirl.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
get :index, :format => :json
get :index, format: :json
JSON response.body
end
@@ -36,8 +36,8 @@ describe API::PlaylistsController do
describe 'POST create' do
def do_create
post :create,
:format => :json,
:playlist => FactoryGirl.attributes_for(:playlist)
format: :json,
playlist: FactoryGirl.attributes_for(:playlist)
end
it 'creates a new playlist for the current user' do

View File

@@ -5,9 +5,9 @@ describe API::SessionsController do
let(:user) { FactoryGirl.create(:user) }
def do_create
post :create, :format => :json, :session => {
:email => user.email,
:password => user.password
post :create, format: :json, session: {
email: user.email,
password: user.password
}
end

View File

@@ -16,7 +16,7 @@ describe API::TracksController do
end
def do_get
get :index, :format => :json
get :index, format: :json
JSON response.body
end

View File

@@ -15,8 +15,8 @@ describe HomeController do
end
it 'assigns latest tracks as @tracks' 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 = 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

@@ -25,14 +25,14 @@ describe PlaylistsController do
describe 'GET edit' do
it 'assigns the requested playlist as @playlist' do
playlist = FactoryGirl.create(:playlist)
get :edit, :id => playlist.id.to_s
get :edit, id: playlist.id.to_s
assigns[:playlist].should == playlist
end
end
describe 'POST create' do
def do_create
post :create, :playlist => FactoryGirl.attributes_for(:playlist)
post :create, playlist: FactoryGirl.attributes_for(:playlist)
end
context 'whith valid params' do
@@ -44,7 +44,7 @@ describe PlaylistsController do
it 'redirects to the playlists index' do
do_create
response.should redirect_to(:action => 'index')
response.should redirect_to(action: 'index')
end
end
@@ -67,19 +67,19 @@ describe PlaylistsController do
let (:playlist) { FactoryGirl.create(:playlist) }
def do_update
put :update, :id => playlist.id.to_s, :playlist => { :name => 'Rock' }
put :update, id: playlist.id.to_s, playlist: { name: 'Rock' }
end
context 'whith valid params' do
it 'updates the playlist' do
Playlist.any_instance.should_receive(:update_attributes).
with({'name' => 'Rock'})
Playlist.any_instance.should_receive(:update_attributes)
.with({'name' => 'Rock'})
do_update
end
it 'redirects to the playlists index' do
do_update
response.should redirect_to(:action => 'index')
response.should redirect_to(action: 'index')
end
end

View File

@@ -11,9 +11,9 @@ describe SessionsController do
let(:user) { FactoryGirl.create(:user) }
def do_create
post :create, :session => {
:email => user.email,
:password => user.password
post :create, session: {
email: user.email,
password: user.password
}
end

View File

@@ -11,12 +11,12 @@ describe SoundsController do
let(:sound) { FactoryGirl.create(:sound) }
def do_show
get :show, :id => sound.id
get :show, id: sound.id
end
it 'sets the sound file content as the response body' do
do_show
response.body.should == File.read(sound.path, :encoding => 'BINARY')
response.body.should == File.read(sound.path, encoding: 'BINARY')
end
it 'sets the sound mime-type as the response content-type' do

View File

@@ -10,7 +10,7 @@ describe TracksController do
describe 'GET show' do
it 'assigns the requested track as @track' do
track = FactoryGirl.create(:track)
get :show, :id => track.id.to_s
get :show, id: track.id.to_s
assigns[:track].should == track
end
end
@@ -24,8 +24,8 @@ describe TracksController do
describe 'POST create new' do
def do_create
post :create, :track => FactoryGirl.attributes_for(:track).merge({
:file => fixture_file_upload(
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 => FactoryGirl.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 => FactoryGirl.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 => FactoryGirl.attributes_for(:user)
post :create, user: FactoryGirl.attributes_for(:user)
response.should redirect_to(:root)
end
end
@@ -31,12 +31,12 @@ describe UsersController do
before { User.any_instance.stub(:save).and_return(false) }
it 'assigns the user as @user' do
post :create, :user => {}
post :create, user: {}
assigns[:user].should be_a_new(User)
end
it 'renders the new template' do
post :create, :user => {}
post :create, user: {}
response.should render_template('new')
end
end