Fix coding standards in specs
This commit is contained in:
parent
c1393b8f8f
commit
cbacdd9fc1
@ -6,7 +6,7 @@ end
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :playlist do
|
||||
name 'Electro'
|
||||
name 'Some playlist'
|
||||
user
|
||||
end
|
||||
|
||||
@ -15,7 +15,7 @@ FactoryGirl.define do
|
||||
end
|
||||
|
||||
factory :track do
|
||||
name 'Mega song'
|
||||
name 'Some track'
|
||||
|
||||
factory :track_with_sound do
|
||||
file { build_sound_file }
|
||||
@ -24,7 +24,7 @@ FactoryGirl.define do
|
||||
|
||||
factory :user do
|
||||
sequence :email do |n|
|
||||
"alice_#{n}@example.net"
|
||||
"bob_#{n}@example.net"
|
||||
end
|
||||
password '733tP4s5'
|
||||
end
|
||||
|
@ -8,10 +8,10 @@ feature 'Playlists CRUD' do
|
||||
visit playlists_path
|
||||
|
||||
click_link playlist[:name]
|
||||
fill_in 'Name', with: 'Rock'
|
||||
fill_in 'Name', with: 'new playlist name'
|
||||
click_button 'Save'
|
||||
|
||||
expect(current_path).to eq playlists_path
|
||||
expect(page).to have_content 'Rock'
|
||||
expect(page).to have_content 'new playlist name'
|
||||
end
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ feature 'User sign up' do
|
||||
scenario 'creates the user' do
|
||||
expect {
|
||||
click_button 'Sign up'
|
||||
}.to change(User, :count).by(1)
|
||||
}.to change(User, :count).by 1
|
||||
end
|
||||
|
||||
scenario 'redirects to the home page' do
|
||||
|
@ -6,7 +6,7 @@ feature 'Tracks player' do
|
||||
scenario 'includes a player in track page' do
|
||||
track = create :track_with_sound
|
||||
|
||||
visit track_path(track)
|
||||
visit track_path track
|
||||
|
||||
expect(page).to have_xpath "//audio[@src='#{sound_path track.sound}']"
|
||||
end
|
||||
|
@ -1,6 +1,5 @@
|
||||
describe Playlist do
|
||||
subject { playlist }
|
||||
let(:playlist) { build :playlist }
|
||||
subject(:playlist) { build :playlist }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
it { is_expected.to belong_to :user }
|
||||
|
@ -1,6 +1,5 @@
|
||||
describe Sound do
|
||||
subject { sound }
|
||||
let(:sound) { build :sound }
|
||||
subject(:sound) { build :sound }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
it { is_expected.to belong_to :track }
|
||||
|
@ -1,7 +1,6 @@
|
||||
describe Track do
|
||||
subject { track }
|
||||
let(:track) { build :track }
|
||||
let(:file) { attributes_for(:track_with_sound)[:file] }
|
||||
let(:file) { attributes_for(:track_with_sound)[:file] }
|
||||
subject(:track) { build :track }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
it { is_expected.to have_many :sounds }
|
||||
@ -13,9 +12,15 @@ describe Track do
|
||||
it { is_expected.to be_valid }
|
||||
|
||||
it 'creates a sound for the track' do
|
||||
expect {
|
||||
track.save
|
||||
}.to change(track.sounds, :count).by(1)
|
||||
expect { track.save }.to change(track.sounds, :count).by 1
|
||||
end
|
||||
end
|
||||
|
||||
describe '.latest' do
|
||||
it 'returns latest tracks in descending creation date order' do
|
||||
track1 = create :track, created_at: '2011-07-27 19:13:42'
|
||||
track2 = create :track, created_at: '2011-07-27 19:58:57'
|
||||
expect(described_class.latest).to eq [track2, track1]
|
||||
end
|
||||
end
|
||||
|
||||
@ -23,7 +28,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
|
||||
@ -53,12 +58,4 @@ describe Track do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.latest' do
|
||||
it 'returns latest tracks in descending creation date order' do
|
||||
track1 = create :track, created_at: '2011-07-27 19:13:42'
|
||||
track2 = create :track, created_at: '2011-07-27 19:58:57'
|
||||
expect(Track.latest).to eq [track2, track1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ describe User do
|
||||
let(:old_user) { create :user, email: 'unique@example.net' }
|
||||
subject(:user) { build :user, email: old_user.email }
|
||||
|
||||
it { is_expected.to_not be_valid }
|
||||
it { is_expected.not_to be_valid }
|
||||
|
||||
it 'has an error on email attribute' do
|
||||
user.valid?
|
||||
@ -22,7 +22,7 @@ describe User do
|
||||
context 'when password_confirmation does not match password' do
|
||||
before { user.password_confirmation = user.password + 'INVALID' }
|
||||
|
||||
it { is_expected.to_not be_valid }
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
describe '#password=' do
|
||||
@ -34,13 +34,13 @@ describe User do
|
||||
describe '#authenticate?' do
|
||||
context 'with a valid password' do
|
||||
it 'returns true' do
|
||||
expect(user.authenticate?(user.password)).to be true
|
||||
expect(user.authenticate? user.password).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an invalid password' do
|
||||
it 'returns false' do
|
||||
expect(user.authenticate?(user.password + '_INVALID')).to be false
|
||||
expect(user.authenticate? user.password + '_INVALID').to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user