From da96c4814ab56e2cd1217f68856b0cf23f051a98 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Tue, 1 Apr 2014 10:48:18 +0000 Subject: [PATCH] Use ruby 2.x hash syntax --- Guardfile | 4 ++-- app/controllers/api/application_controller.rb | 2 +- app/controllers/api/sessions_controller.rb | 4 ++-- app/controllers/api/sounds_controller.rb | 2 +- app/controllers/playlists_controller.rb | 8 ++++---- app/controllers/sessions_controller.rb | 2 +- app/controllers/sounds_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/models/track.rb | 2 +- app/models/user.rb | 8 ++++---- app/views/api/tracks/index.rabl | 2 +- app/views/layouts/application.html.haml | 2 +- app/views/playlists/edit.html.haml | 2 +- app/views/playlists/new.html.haml | 2 +- app/views/sessions/new.html.haml | 2 +- app/views/tracks/new.html.haml | 2 +- app/views/tracks/show.html.haml | 2 +- app/views/users/new.html.haml | 2 +- config/initializers/rabl_init.rb | 2 +- config/routes.rb | 20 +++++++++---------- db/migrate/20110915211845_initial_schema.rb | 4 ++-- .../api/playlists_controller_spec.rb | 10 +++++----- .../api/sessions_controller_spec.rb | 6 +++--- .../controllers/api/tracks_controller_spec.rb | 2 +- spec/controllers/home_controller_spec.rb | 4 ++-- spec/controllers/playlists_controller_spec.rb | 14 ++++++------- spec/controllers/sessions_controller_spec.rb | 6 +++--- spec/controllers/sounds_controller_spec.rb | 4 ++-- spec/controllers/tracks_controller_spec.rb | 6 +++--- spec/controllers/users_controller_spec.rb | 10 +++++----- spec/factories.rb | 2 +- spec/features/home_spec.rb | 10 +++++----- spec/features/playlists_spec.rb | 10 +++++----- spec/features/tracks_spec.rb | 4 ++-- spec/features/user_sign_in_spec.rb | 4 ++-- spec/features/user_sign_up_spec.rb | 6 +++--- spec/integration/api/api_sign_in_spec.rb | 6 +++--- .../api/cross_origin_request_spec.rb | 12 +++++------ spec/integration/api/playlists_spec.rb | 4 ++-- spec/integration/api/tracks_spec.rb | 16 +++++++-------- spec/models/track_spec.rb | 8 ++++---- spec/models/user_spec.rb | 4 ++-- spec/routing/options_requests_spec.rb | 8 ++++---- spec/support/user_integration_helpers.rb | 10 +++++----- spec/views/home/index.html.haml_spec.rb | 10 +++++----- spec/views/playlists/edit.html.haml_spec.rb | 4 ++-- spec/views/playlists/index.html.haml_spec.rb | 8 ++++---- spec/views/playlists/new.html.haml_spec.rb | 4 ++-- spec/views/sessions/new.html.haml_spec.rb | 6 +++--- spec/views/tracks/new.html.haml_spec.rb | 6 +++--- spec/views/tracks/show.html.haml_spec.rb | 4 ++-- spec/views/users/new.html.haml_spec.rb | 10 +++++----- 52 files changed, 148 insertions(+), 148 deletions(-) diff --git a/Guardfile b/Guardfile index 421f56c..eb83ffc 100644 --- a/Guardfile +++ b/Guardfile @@ -1,4 +1,4 @@ -guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do +guard 'spork', rspec_env: { RAILS_ENV: 'test' } do watch('config/application.rb') watch('config/environment.rb') watch('config/routes.rb') @@ -8,7 +8,7 @@ guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do watch(%r{^spec/support/.+\.rb$}) end -guard 'rspec', :cmd => 'bundle exec rspec --drb -f doc' do +guard 'rspec', cmd: 'bundle exec rspec --drb -f doc' do watch(%r{^spec/.+_spec\.rb$}) watch('spec/spec_helper.rb') { 'spec' } diff --git a/app/controllers/api/application_controller.rb b/app/controllers/api/application_controller.rb index 92b1010..1eac42f 100644 --- a/app/controllers/api/application_controller.rb +++ b/app/controllers/api/application_controller.rb @@ -1,6 +1,6 @@ class API::ApplicationController < ApplicationController skip_before_filter :verify_authenticity_token - skip_before_filter :authenticate!, :only => [:cor_preflight] + skip_before_filter :authenticate!, only: [:cor_preflight] before_filter :cor_filter diff --git a/app/controllers/api/sessions_controller.rb b/app/controllers/api/sessions_controller.rb index 85b2bbf..b8c3a1f 100644 --- a/app/controllers/api/sessions_controller.rb +++ b/app/controllers/api/sessions_controller.rb @@ -1,11 +1,11 @@ class API::SessionsController < API::ApplicationController - skip_before_filter :authenticate!, :only => [:create] + skip_before_filter :authenticate!, only: [:create] def create user = User.find_by_email(params[:session][:email]) if ! user.try(:authenticate?, params[:session][:password]) - return render :json => '', :status => :not_found + return render json: '', status: :not_found end @user = user diff --git a/app/controllers/api/sounds_controller.rb b/app/controllers/api/sounds_controller.rb index c7b8111..041c081 100644 --- a/app/controllers/api/sounds_controller.rb +++ b/app/controllers/api/sounds_controller.rb @@ -2,6 +2,6 @@ class API::SoundsController < API::ApplicationController # FIXME: add some tests! def show sound = Sound.find params[:id] - send_file sound.path, :type => sound.mime_type + send_file sound.path, type: sound.mime_type end end diff --git a/app/controllers/playlists_controller.rb b/app/controllers/playlists_controller.rb index e3113c2..698635b 100644 --- a/app/controllers/playlists_controller.rb +++ b/app/controllers/playlists_controller.rb @@ -10,9 +10,9 @@ class PlaylistsController < ApplicationController def create @playlist = current_user.playlists.build(params[:playlist]) if @playlist.save - redirect_to :action => 'index' + redirect_to action: 'index' else - render :action => 'new' + render action: 'new' end end @@ -23,9 +23,9 @@ class PlaylistsController < ApplicationController def update @playlist = Playlist.find(params[:id]) if @playlist.update_attributes params[:playlist] - redirect_to :action => 'index' + redirect_to action: 'index' else - render :action => 'edit' + render action: 'edit' end end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 4017970..ba207cb 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,5 +1,5 @@ class SessionsController < ApplicationController - skip_before_filter :authenticate!, :only => [:new, :create] + skip_before_filter :authenticate!, only: [:new, :create] def create user = User.find_by_email(params[:session][:email]) diff --git a/app/controllers/sounds_controller.rb b/app/controllers/sounds_controller.rb index a88a193..c047256 100644 --- a/app/controllers/sounds_controller.rb +++ b/app/controllers/sounds_controller.rb @@ -1,6 +1,6 @@ class SoundsController < ApplicationController def show sound = Sound.find params[:id] - send_file sound.path, :type => sound.mime_type + send_file sound.path, type: sound.mime_type end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ec472cf..5b576b9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,5 @@ class UsersController < ApplicationController - skip_before_filter :authenticate!, :only => [:new, :create] + skip_before_filter :authenticate!, only: [:new, :create] def new @user = User.new diff --git a/app/models/track.rb b/app/models/track.rb index 745c791..9e6188f 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -6,7 +6,7 @@ class Track < ActiveRecord::Base validates_presence_of :name def file=(file) - sounds.build({:file => file}) + sounds.build(file: file) end def sound diff --git a/app/models/user.rb b/app/models/user.rb index de20fe3..503506a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,11 +9,11 @@ class User < ActiveRecord::Base has_many :playlists validates :email, - :presence => true, - :uniqueness => true + presence: true, + uniqueness: true validates :password, - :presence => true, - :confirmation => true + presence: true, + confirmation: true validates_presence_of :password_hash def password=(plain_password) diff --git a/app/views/api/tracks/index.rabl b/app/views/api/tracks/index.rabl index 4bb1752..4b952c3 100644 --- a/app/views/api/tracks/index.rabl +++ b/app/views/api/tracks/index.rabl @@ -3,4 +3,4 @@ collection @tracks attribute :id attribute :name -node(:sound_url, :if => ->(t) { t.sound? }) { |t| api_sound_url t.sound } +node(:sound_url, if: ->(t) { t.sound? }) { |t| api_sound_url t.sound } diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index fc493c8..31e2b29 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,7 +1,7 @@ !!! %html %head - %meta{:charset => 'utf-8'} + %meta{charset: 'utf-8'} %title scube = csrf_meta_tag %body diff --git a/app/views/playlists/edit.html.haml b/app/views/playlists/edit.html.haml index ed80003..54b326f 100644 --- a/app/views/playlists/edit.html.haml +++ b/app/views/playlists/edit.html.haml @@ -1 +1 @@ -= render 'form', :submit_text => 'Save' += render 'form', submit_text: 'Save' diff --git a/app/views/playlists/new.html.haml b/app/views/playlists/new.html.haml index 7b4174f..3efd774 100644 --- a/app/views/playlists/new.html.haml +++ b/app/views/playlists/new.html.haml @@ -1 +1 @@ -= render 'form', :submit_text => 'Create' += render 'form', submit_text: 'Create' diff --git a/app/views/sessions/new.html.haml b/app/views/sessions/new.html.haml index 960f281..fbffef9 100644 --- a/app/views/sessions/new.html.haml +++ b/app/views/sessions/new.html.haml @@ -1,4 +1,4 @@ -= form_for(:session, :url => sessions_path) do |f| += form_for(:session, url: sessions_path) do |f| %table %tbody %tr diff --git a/app/views/tracks/new.html.haml b/app/views/tracks/new.html.haml index 2b499ba..e008986 100644 --- a/app/views/tracks/new.html.haml +++ b/app/views/tracks/new.html.haml @@ -1,4 +1,4 @@ -= form_for @track, :html => { :multipart => true } do |t| += form_for @track, html: { multipart: true } do |t| %table %tbody %tr diff --git a/app/views/tracks/show.html.haml b/app/views/tracks/show.html.haml index 4f5ba18..6060fca 100644 --- a/app/views/tracks/show.html.haml +++ b/app/views/tracks/show.html.haml @@ -1,5 +1,5 @@ %h1= @track.name - if @track.sound? - %audio{:src => sound_path(@track.sound), :controls => true, :autoplay => true} + %audio{src: sound_path(@track.sound), controls: true, autoplay: true} Your browser does not support the audio element diff --git a/app/views/users/new.html.haml b/app/views/users/new.html.haml index 32879de..0280580 100644 --- a/app/views/users/new.html.haml +++ b/app/views/users/new.html.haml @@ -1,4 +1,4 @@ -= form_for(@user, :url => users_path) do |f| += form_for(@user, url: users_path) do |f| - if @user.errors.any? %ul - @user.errors.full_messages.each do |m| diff --git a/config/initializers/rabl_init.rb b/config/initializers/rabl_init.rb index ec298cf..fd674bf 100644 --- a/config/initializers/rabl_init.rb +++ b/config/initializers/rabl_init.rb @@ -12,5 +12,5 @@ Rabl.configure do |config| # config.include_plist_root = true # config.include_xml_root = false # config.enable_json_callbacks = false - # config.xml_options = { :dasherize => true, :skip_types => false } + # config.xml_options = { dasherize: true, skip_types: false } end diff --git a/config/routes.rb b/config/routes.rb index 5938bda..d253a8f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,24 +1,24 @@ Scube::Application.routes.draw do namespace :api do - resources :sounds, :only => [:show] - resources :tracks, :only => [:index] - resources :playlists, :only => [:index, :create] - resources :sessions, :only => [:create] + resources :sounds, only: [:show] + resources :tracks, only: [:index] + resources :playlists, only: [:index, :create] + resources :sessions, only: [:create] - match '*all' => 'application#cor_preflight', :via => :options + match '*all' => 'application#cor_preflight', via: :options end - resources :sounds, :only => [:show] + resources :sounds, only: [:show] - resources :users, :only => [:new, :create] + resources :users, only: [:new, :create] - resources :sessions, :only => [:new, :create] + resources :sessions, only: [:new, :create] resources :tracks do - get 'download', :on => :member + get 'download', on: :member end resources :playlists - root :to => 'home#index' + root to: 'home#index' end diff --git a/db/migrate/20110915211845_initial_schema.rb b/db/migrate/20110915211845_initial_schema.rb index af32c53..a1bbedc 100644 --- a/db/migrate/20110915211845_initial_schema.rb +++ b/db/migrate/20110915211845_initial_schema.rb @@ -9,7 +9,7 @@ class InitialSchema < ActiveRecord::Migration end create_table :sessions do |t| - t.string :session_id, :null => false + t.string :session_id, null: false t.text :data t.timestamps @@ -31,7 +31,7 @@ class InitialSchema < ActiveRecord::Migration t.timestamps end - add_index :users, :email, :unique => true + add_index :users, :email, unique: true end diff --git a/spec/controllers/api/playlists_controller_spec.rb b/spec/controllers/api/playlists_controller_spec.rb index 4e4d5e8..daab529 100644 --- a/spec/controllers/api/playlists_controller_spec.rb +++ b/spec/controllers/api/playlists_controller_spec.rb @@ -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 diff --git a/spec/controllers/api/sessions_controller_spec.rb b/spec/controllers/api/sessions_controller_spec.rb index 37c2bd8..f6c75b4 100644 --- a/spec/controllers/api/sessions_controller_spec.rb +++ b/spec/controllers/api/sessions_controller_spec.rb @@ -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 diff --git a/spec/controllers/api/tracks_controller_spec.rb b/spec/controllers/api/tracks_controller_spec.rb index e9539eb..add6ac9 100644 --- a/spec/controllers/api/tracks_controller_spec.rb +++ b/spec/controllers/api/tracks_controller_spec.rb @@ -16,7 +16,7 @@ describe API::TracksController do end def do_get - get :index, :format => :json + get :index, format: :json JSON response.body end diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index f96a542..0025279 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -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 diff --git a/spec/controllers/playlists_controller_spec.rb b/spec/controllers/playlists_controller_spec.rb index ca0fa0f..ff74d27 100644 --- a/spec/controllers/playlists_controller_spec.rb +++ b/spec/controllers/playlists_controller_spec.rb @@ -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 diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index ea66bbf..795ac8d 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -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 diff --git a/spec/controllers/sounds_controller_spec.rb b/spec/controllers/sounds_controller_spec.rb index d64419b..586c9ff 100644 --- a/spec/controllers/sounds_controller_spec.rb +++ b/spec/controllers/sounds_controller_spec.rb @@ -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 diff --git a/spec/controllers/tracks_controller_spec.rb b/spec/controllers/tracks_controller_spec.rb index e203fd8..d6efbf9 100644 --- a/spec/controllers/tracks_controller_spec.rb +++ b/spec/controllers/tracks_controller_spec.rb @@ -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' ) diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index e64b606..8ecb497 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 => 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 diff --git a/spec/factories.rb b/spec/factories.rb index dd35f49..0d2c2d3 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,6 +1,6 @@ def build_sound_file file = File.new("#{Rails.root}/spec/fixtures/test.mp3") - file.stub(:content_type => 'audio/mpeg') + file.stub(content_type: 'audio/mpeg') file end diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb index 5693083..57466a5 100644 --- a/spec/features/home_spec.rb +++ b/spec/features/home_spec.rb @@ -8,7 +8,7 @@ feature 'Home page' do end scenario 'displays playlists' do - playlist = FactoryGirl.create(:playlist, :name => 'Electro') + playlist = FactoryGirl.create(:playlist, name: 'Electro') visit root_path @@ -17,12 +17,12 @@ feature 'Home page' do scenario 'displays last track added' do FactoryGirl.create(:track, - :name => 'Mega song 1', - :created_at => '2011-07-27 19:13:42' + name: 'Mega song 1', + created_at: '2011-07-27 19:13:42' ) FactoryGirl.create(:track, - :name => 'Mega song 2', - :created_at => '2011-07-27 19:58:57' + name: 'Mega song 2', + created_at: '2011-07-27 19:58:57' ) visit root_path diff --git a/spec/features/playlists_spec.rb b/spec/features/playlists_spec.rb index 0aa8a49..bf9bc39 100644 --- a/spec/features/playlists_spec.rb +++ b/spec/features/playlists_spec.rb @@ -8,8 +8,8 @@ feature 'Playlists' do end scenario 'lists playlists' do - FactoryGirl.create(:playlist, :name => 'Electro') - FactoryGirl.create(:playlist, :name => 'Reggae') + FactoryGirl.create(:playlist, name: 'Electro') + FactoryGirl.create(:playlist, name: 'Reggae') visit playlists_path @@ -20,7 +20,7 @@ feature 'Playlists' do visit playlists_path click_link 'Create playlist' - fill_in 'Name', :with => 'Electro' + fill_in 'Name', with: 'Electro' click_button 'Create' current_path.should == playlists_path @@ -28,11 +28,11 @@ feature 'Playlists' do end scenario 'edits playlist' do - FactoryGirl.create(:playlist, :name => 'Electro') + FactoryGirl.create(:playlist, name: 'Electro') visit playlists_path click_link 'Electro' - fill_in 'Name', :with => 'Rock' + fill_in 'Name', with: 'Rock' click_button 'Save' current_path.should == playlists_path diff --git a/spec/features/tracks_spec.rb b/spec/features/tracks_spec.rb index ea070e5..196b0ab 100644 --- a/spec/features/tracks_spec.rb +++ b/spec/features/tracks_spec.rb @@ -8,7 +8,7 @@ feature 'Tracks' do end scenario 'shows track' do - track = FactoryGirl.create(:track, :name => 'Mega song') + track = FactoryGirl.create(:track, name: 'Mega song') visit track_path(track) @@ -19,7 +19,7 @@ feature 'Tracks' do visit root_path click_link 'Add a track' - fill_in 'Name', :with => 'Mega song' + fill_in 'Name', with: 'Mega song' attach_file 'File', File.expand_path('spec/fixtures/test.mp3') click_button 'Upload' diff --git a/spec/features/user_sign_in_spec.rb b/spec/features/user_sign_in_spec.rb index 781999b..e98b848 100644 --- a/spec/features/user_sign_in_spec.rb +++ b/spec/features/user_sign_in_spec.rb @@ -11,8 +11,8 @@ feature 'User sign in' do user = FactoryGirl.create(:user) visit new_session_path - fill_in 'Email', :with => user.email - fill_in 'Password', :with => user.password + fill_in 'Email', with: user.email + fill_in 'Password', with: user.password click_button 'Sign in' current_path.should == root_path diff --git a/spec/features/user_sign_up_spec.rb b/spec/features/user_sign_up_spec.rb index d69a5a2..ec07b38 100644 --- a/spec/features/user_sign_up_spec.rb +++ b/spec/features/user_sign_up_spec.rb @@ -5,9 +5,9 @@ feature 'User sign up' do background do visit new_user_path - fill_in 'Email', :with => user.email - fill_in 'Password', :with => user.password - fill_in 'Password confirmation', :with => user.password + fill_in 'Email', with: user.email + fill_in 'Password', with: user.password + fill_in 'Password confirmation', with: user.password end scenario 'creates the user' do diff --git a/spec/integration/api/api_sign_in_spec.rb b/spec/integration/api/api_sign_in_spec.rb index bdf3c1b..e758c36 100644 --- a/spec/integration/api/api_sign_in_spec.rb +++ b/spec/integration/api/api_sign_in_spec.rb @@ -4,9 +4,9 @@ feature 'API sign in' do let(:user) { FactoryGirl.create(:user) } def do_create - post api_sessions_path, :format => :json, :session => { - :email => user.email, - :password => user.password + post api_sessions_path, format: :json, session: { + email: user.email, + password: user.password } end diff --git a/spec/integration/api/cross_origin_request_spec.rb b/spec/integration/api/cross_origin_request_spec.rb index cb9f59e..641b3a8 100644 --- a/spec/integration/api/cross_origin_request_spec.rb +++ b/spec/integration/api/cross_origin_request_spec.rb @@ -7,9 +7,9 @@ feature 'API cross origin request' do let(:origin) { 'http://origin.example/' } background do - post sessions_path, :session => { - :email => user.email, - :password => user.password + post sessions_path, session: { + email: user.email, + password: user.password } end @@ -17,7 +17,7 @@ feature 'API cross origin request' do @integration_session.send( :process, :options, - api_playlists_path(:format => :json), + api_playlists_path(format: :json), nil, { 'Origin' => origin } ) @@ -32,7 +32,7 @@ feature 'API cross origin request' do scenario 'basic request' do # FIXME: replace with a more stable/generic action - get api_playlists_path(:format => :json), nil, { + get api_playlists_path(format: :json), nil, { 'Origin' => origin } @@ -43,7 +43,7 @@ feature 'API cross origin request' do scenario 'request without origin' do # FIXME: replace with a more stable/generic action - get api_playlists_path(:format => :json) + get api_playlists_path(format: :json) response.headers['Access-Control-Allow-Origin'].should == '' end diff --git a/spec/integration/api/playlists_spec.rb b/spec/integration/api/playlists_spec.rb index 96b4456..47af1e9 100644 --- a/spec/integration/api/playlists_spec.rb +++ b/spec/integration/api/playlists_spec.rb @@ -11,8 +11,8 @@ feature 'API playlists' do playlist = FactoryGirl.attributes_for :playlist post api_playlists_path, - :format => :json, - :playlist => playlist + format: :json, + playlist: playlist json = JSON response.body diff --git a/spec/integration/api/tracks_spec.rb b/spec/integration/api/tracks_spec.rb index 1bd5977..5914d58 100644 --- a/spec/integration/api/tracks_spec.rb +++ b/spec/integration/api/tracks_spec.rb @@ -8,20 +8,20 @@ feature 'API tracks' do end scenario 'lists tracks' do - track_1 = FactoryGirl.create(:track_with_sound, :name => 'Track 1') - track_2 = FactoryGirl.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 + get api_tracks_path, format: :json response.body.should == [ { - :id => track_1.id, - :name => 'Track 1', - :sound_url => api_sound_url(track_1.sound) + id: track_1.id, + name: 'Track 1', + sound_url: api_sound_url(track_1.sound) }, { - :id => track_2.id, - :name => 'Track 2' + id: track_2.id, + name: 'Track 2' } ].to_json end diff --git a/spec/models/track_spec.rb b/spec/models/track_spec.rb index cdf9718..b8ee69a 100644 --- a/spec/models/track_spec.rb +++ b/spec/models/track_spec.rb @@ -27,8 +27,8 @@ describe Track do describe '#file=' do it 'builds a new related sound with the file' do sounds = double 'sounds association proxy' - track.stub(:sounds => sounds) - sounds.should_receive(:build).with({:file => file}) + track.stub(sounds: sounds) + sounds.should_receive(:build).with({file: file}) track.file = file end end @@ -65,8 +65,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 = 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 ae2fae0..e90be27 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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) { FactoryGirl.create(:user, :email => 'unique@example.net') } - subject { FactoryGirl.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/routing/options_requests_spec.rb b/spec/routing/options_requests_spec.rb index aba8a78..23bc0a2 100644 --- a/spec/routing/options_requests_spec.rb +++ b/spec/routing/options_requests_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' describe '/api OPTIONS requests routing' do it 'routes to API::ApplicationController#cor_preflight' do - { :options => '/api/some_route' }.should route_to( - :controller => 'api/application', - :action => 'cor_preflight', - :all => 'some_route' + { options: '/api/some_route' }.should route_to( + controller: 'api/application', + action: 'cor_preflight', + all: 'some_route' ) end end diff --git a/spec/support/user_integration_helpers.rb b/spec/support/user_integration_helpers.rb index 5d1d8a9..71aebcd 100644 --- a/spec/support/user_integration_helpers.rb +++ b/spec/support/user_integration_helpers.rb @@ -2,17 +2,17 @@ module UserIntegrationHelpers def sign_in user = FactoryGirl.create(:user) visit new_session_path - fill_in 'Email', :with => user.email - fill_in 'Password', :with => user.password + fill_in 'Email', with: user.email + fill_in 'Password', with: user.password click_button('Sign in') end def api_sign_in user = FactoryGirl.create :user - post api_sessions_path, :format => :json, :session => { - :email => user.email, - :password => user.password + post api_sessions_path, format: :json, session: { + email: user.email, + password: user.password } end end diff --git a/spec/views/home/index.html.haml_spec.rb b/spec/views/home/index.html.haml_spec.rb index b7e0536..2d81442 100644 --- a/spec/views/home/index.html.haml_spec.rb +++ b/spec/views/home/index.html.haml_spec.rb @@ -3,25 +3,25 @@ require 'spec_helper' describe 'home/index' do before do assign :playlists, [ - mock_model(Playlist, :name => 'Electro') + mock_model(Playlist, name: 'Electro') ] assign :tracks, [ - mock_model(Track, :name => 'Mega song') + mock_model(Track, name: 'Mega song') ] end it 'displays a list of playlists' do render - rendered.should have_selector('ul>li', :text => 'Electro') + rendered.should have_selector('ul>li', text: 'Electro') end it 'displays a link to add a track' do render - rendered.should have_selector('a', :text => 'Add a track') + rendered.should have_selector('a', text: 'Add a track') end it 'displays a list of tracks' do render - rendered.should have_selector('ul>li', :text => 'Mega song') + rendered.should have_selector('ul>li', text: 'Mega song') end end diff --git a/spec/views/playlists/edit.html.haml_spec.rb b/spec/views/playlists/edit.html.haml_spec.rb index 9128556..fccb4cc 100644 --- a/spec/views/playlists/edit.html.haml_spec.rb +++ b/spec/views/playlists/edit.html.haml_spec.rb @@ -16,11 +16,11 @@ describe 'playlists/edit' do end it 'renders a text field with a label for the playlists name' do - playlist.stub(:name => 'Electro') + playlist.stub(name: 'Electro') render rendered.should have_selector( "input[type=text][name='playlist[name]'][value=Electro]" ) - rendered.should have_selector("label[for=playlist_name]", :text => 'Name') + rendered.should have_selector("label[for=playlist_name]", text: 'Name') end end diff --git a/spec/views/playlists/index.html.haml_spec.rb b/spec/views/playlists/index.html.haml_spec.rb index 836a504..9eb2d37 100644 --- a/spec/views/playlists/index.html.haml_spec.rb +++ b/spec/views/playlists/index.html.haml_spec.rb @@ -3,22 +3,22 @@ require 'spec_helper' describe 'playlists/index' do before do assign :playlists, [ - mock_model(Playlist, :name => 'Electro') + mock_model(Playlist, name: 'Electro') ] end it 'displays a list of playlists' do render - rendered.should have_selector('ul>li', :text => 'Electro') + rendered.should have_selector('ul>li', text: 'Electro') end it 'displays a link to create a new playlist' do render - rendered.should have_selector('a', :text => 'Create playlist') + rendered.should have_selector('a', text: 'Create playlist') end it 'displays playlists as links' do render - rendered.should have_selector('a', :text => 'Electro') + rendered.should have_selector('a', text: 'Electro') end end diff --git a/spec/views/playlists/new.html.haml_spec.rb b/spec/views/playlists/new.html.haml_spec.rb index be0860f..ef06af2 100644 --- a/spec/views/playlists/new.html.haml_spec.rb +++ b/spec/views/playlists/new.html.haml_spec.rb @@ -18,11 +18,11 @@ describe 'playlists/new' do end it 'renders a text field with a label for the playlists name' do - playlist.stub(:name => 'Electro') + playlist.stub(name: 'Electro') render rendered.should have_selector( "input[type=text][name='playlist[name]'][value=Electro]" ) - rendered.should have_selector("label[for=playlist_name]", :text => 'Name') + rendered.should have_selector("label[for=playlist_name]", text: 'Name') end end diff --git a/spec/views/sessions/new.html.haml_spec.rb b/spec/views/sessions/new.html.haml_spec.rb index d4f2e86..cad2910 100644 --- a/spec/views/sessions/new.html.haml_spec.rb +++ b/spec/views/sessions/new.html.haml_spec.rb @@ -12,7 +12,7 @@ describe 'sessions/new' do it 'renders a text field with a label for the mail address' do render rendered.should have_selector("input[type=text][name='session[email]']") - rendered.should have_selector('label[for=session_email]', :text => 'Email') + rendered.should have_selector('label[for=session_email]', text: 'Email') end it 'renders a password field with a label for the password' do @@ -21,7 +21,7 @@ describe 'sessions/new' do "input[type=password][name='session[password]']" ) rendered.should have_selector( - 'label[for=session_password]', :text => 'Password' + 'label[for=session_password]', text: 'Password' ) end @@ -29,7 +29,7 @@ describe 'sessions/new' do render rendered.should have_selector( "a[href='#{new_user_path}']", - :text => 'Sign up' + text: 'Sign up' ) end end diff --git a/spec/views/tracks/new.html.haml_spec.rb b/spec/views/tracks/new.html.haml_spec.rb index 0a35f33..a43a115 100644 --- a/spec/views/tracks/new.html.haml_spec.rb +++ b/spec/views/tracks/new.html.haml_spec.rb @@ -16,18 +16,18 @@ describe 'tracks/new' do end it 'renders a text field with a label for the playlists name' do - track.stub(:name => 'Mega song') + track.stub(name: 'Mega song') render rendered.should have_selector( "input[type=text][name='track[name]'][value='Mega song']" ) - rendered.should have_selector('label[for=track_name]', :text => 'Name') + rendered.should have_selector('label[for=track_name]', text: 'Name') end it 'renders a file field with a label for the tracks file' do render rendered.should have_selector("form[enctype='multipart/form-data']") rendered.should have_selector("input[type=file][name='track[file]']") - rendered.should have_selector('label[for=track_file]', :text => 'File') + rendered.should have_selector('label[for=track_file]', text: 'File') end end diff --git a/spec/views/tracks/show.html.haml_spec.rb b/spec/views/tracks/show.html.haml_spec.rb index 4d956df..f357885 100644 --- a/spec/views/tracks/show.html.haml_spec.rb +++ b/spec/views/tracks/show.html.haml_spec.rb @@ -9,7 +9,7 @@ describe 'tracks/show' do it 'displays the name of the track' do render - rendered.should have_selector('h1', :text => 'Mega song') + rendered.should have_selector('h1', text: 'Mega song') end context 'when track has a sound' do @@ -34,7 +34,7 @@ describe 'tracks/show' do render rendered.should have_selector( 'audio', - :text => 'Your browser does not support the audio element' + text: 'Your browser does not support the audio element' ) end end diff --git a/spec/views/users/new.html.haml_spec.rb b/spec/views/users/new.html.haml_spec.rb index a13c50a..a926bea 100644 --- a/spec/views/users/new.html.haml_spec.rb +++ b/spec/views/users/new.html.haml_spec.rb @@ -21,7 +21,7 @@ describe 'users/new' do "input[type=text][name='user[email]']" ) rendered.should have_selector( - 'label[for=user_email]', :text => 'Email' + 'label[for=user_email]', text: 'Email' ) end @@ -31,7 +31,7 @@ describe 'users/new' do "input[type=password][name='user[password]']" ) rendered.should have_selector( - 'label[for=user_password]', :text => 'Password' + 'label[for=user_password]', text: 'Password' ) end @@ -42,14 +42,14 @@ describe 'users/new' do ) rendered.should have_selector( 'label[for=user_password_confirmation]', - :text => 'Password confirmation' + text: 'Password confirmation' ) end context 'when the user has some validation errors' do it 'on the email address uniqueness' do - user = FactoryGirl.create(:user, :email => 'unique@example.net') - new_user = FactoryGirl.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