From 2acf0371b5a0a16756badba23372f35d255434a2 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Tue, 1 Apr 2014 19:14:11 +0000 Subject: [PATCH] Fix coding standards in specs --- spec/controllers/api/playlists_controller_spec.rb | 4 ++-- spec/controllers/home_controller_spec.rb | 4 ++-- spec/controllers/playlists_controller_spec.rb | 4 ++-- spec/controllers/tracks_controller_spec.rb | 4 ++-- spec/features/home_spec.rb | 2 +- spec/integration/api/cross_origin_request_spec.rb | 6 ++---- spec/models/sound_spec.rb | 2 +- spec/models/track_spec.rb | 2 +- spec/routing/options_requests_spec.rb | 2 +- spec/views/playlists/edit.html.haml_spec.rb | 3 ++- 10 files changed, 16 insertions(+), 17 deletions(-) diff --git a/spec/controllers/api/playlists_controller_spec.rb b/spec/controllers/api/playlists_controller_spec.rb index d680ddc..05b75e1 100644 --- a/spec/controllers/api/playlists_controller_spec.rb +++ b/spec/controllers/api/playlists_controller_spec.rb @@ -9,8 +9,8 @@ describe API::PlaylistsController do render_views before do - playlist_1 = FactoryGirl.create(:playlist, name: 'Playlist 1') - playlist_2 = FactoryGirl.create(:playlist, name: 'Playlist 2') + FactoryGirl.create(:playlist, name: 'Playlist 1') + FactoryGirl.create(:playlist, name: 'Playlist 2') end def do_get diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 8f1e1cb..03dd7c4 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -13,8 +13,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') + FactoryGirl.create(:track, created_at: '2011-07-27 19:13:42') + FactoryGirl.create(:track, created_at: '2011-07-27 19:58:57') get :index expect(assigns[:tracks]).to eq Track.latest end diff --git a/spec/controllers/playlists_controller_spec.rb b/spec/controllers/playlists_controller_spec.rb index 82703bd..be881dd 100644 --- a/spec/controllers/playlists_controller_spec.rb +++ b/spec/controllers/playlists_controller_spec.rb @@ -62,7 +62,7 @@ describe PlaylistsController do end describe 'PUT update' do - let (:playlist) { FactoryGirl.create(:playlist) } + let(:playlist) { FactoryGirl.create(:playlist) } def do_update put :update, id: playlist.id.to_s, playlist: { name: 'Rock' } @@ -71,7 +71,7 @@ describe PlaylistsController do context 'whith valid params' do it 'updates the playlist' do expect_any_instance_of(Playlist) - .to receive(:update_attributes).with({'name' => 'Rock'}) + .to receive(:update_attributes).with('name' => 'Rock') do_update end diff --git a/spec/controllers/tracks_controller_spec.rb b/spec/controllers/tracks_controller_spec.rb index 5f54731..f92aca9 100644 --- a/spec/controllers/tracks_controller_spec.rb +++ b/spec/controllers/tracks_controller_spec.rb @@ -22,12 +22,12 @@ describe TracksController do describe 'POST create new' do def do_create - post :create, track: FactoryGirl.attributes_for(:track).merge({ + post :create, track: FactoryGirl.attributes_for(:track).merge( file: fixture_file_upload( "#{Rails.root}/spec/fixtures/test.mp3", 'audio/mpeg' ) - }) + ) end context 'whith valid params' do diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb index 245db11..9e2c3ca 100644 --- a/spec/features/home_spec.rb +++ b/spec/features/home_spec.rb @@ -6,7 +6,7 @@ feature 'Home page' do background { sign_in } scenario 'displays playlists' do - playlist = FactoryGirl.create(:playlist, name: 'Electro') + FactoryGirl.create(:playlist, name: 'Electro') visit root_path diff --git a/spec/integration/api/cross_origin_request_spec.rb b/spec/integration/api/cross_origin_request_spec.rb index 94fa0a9..6fa0f55 100644 --- a/spec/integration/api/cross_origin_request_spec.rb +++ b/spec/integration/api/cross_origin_request_spec.rb @@ -19,7 +19,7 @@ feature 'API cross origin request' do :options, api_playlists_path(format: :json), nil, - { 'Origin' => origin } + 'Origin' => origin ) expect(response.headers['Access-Control-Allow-Origin']).to eq origin @@ -32,9 +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, { - 'Origin' => origin - } + get api_playlists_path(format: :json), nil, 'Origin' => origin expect(response.headers['Access-Control-Allow-Origin']).to eq origin expect(response.headers['Access-Control-Allow-Credentials']).to eq 'true' diff --git a/spec/models/sound_spec.rb b/spec/models/sound_spec.rb index ae5f372..f622428 100644 --- a/spec/models/sound_spec.rb +++ b/spec/models/sound_spec.rb @@ -21,7 +21,7 @@ describe Sound do end describe '#file=' do - let (:file) { FactoryGirl.attributes_for(:sound)[:file] } + let(:file) { FactoryGirl.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 792d025..cc588d9 100644 --- a/spec/models/track_spec.rb +++ b/spec/models/track_spec.rb @@ -26,7 +26,7 @@ describe Track do it 'builds a new related sound with the file' do sounds = double 'sounds association proxy' allow(track).to receive(:sounds) { sounds } - expect(sounds).to receive(:build).with({file: file}) + expect(sounds).to receive(:build).with(file: file) track.file = file end end diff --git a/spec/routing/options_requests_spec.rb b/spec/routing/options_requests_spec.rb index d07cea9..b2315fa 100644 --- a/spec/routing/options_requests_spec.rb +++ b/spec/routing/options_requests_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe '/api OPTIONS requests routing' do it 'routes to API::ApplicationController#cor_preflight' do - expect({ options: '/api/some_route' }) + expect(options: '/api/some_route') .to route_to( controller: 'api/application', action: 'cor_preflight', diff --git a/spec/views/playlists/edit.html.haml_spec.rb b/spec/views/playlists/edit.html.haml_spec.rb index 398b66c..a610cb8 100644 --- a/spec/views/playlists/edit.html.haml_spec.rb +++ b/spec/views/playlists/edit.html.haml_spec.rb @@ -7,7 +7,8 @@ describe 'playlists/edit' do it 'renders a form to edit a playlist' do render - expect(rendered).to have_selector("form[method=post][action='#{playlists_path}']") + expect(rendered) + .to have_selector("form[method=post][action='#{playlists_path}']") expect(rendered).to have_selector('input[type=submit]') end