Update specs to new rspec syntax

This commit is contained in:
Thibault Jouan
2014-04-01 18:15:44 +00:00
parent 99d106cf36
commit 4cef7aeab9
32 changed files with 173 additions and 179 deletions

View File

@@ -11,11 +11,12 @@ describe Sound do
describe '#path' do
it 'starts by the path specified in Rails.configuration.sound_path' do
sound.path.should match(/\A#{Rails.configuration.sounds_path}/)
expect(sound.path).to match /\A#{Rails.configuration.sounds_path}/
end
it 'returns the sound file path based on the SHA256 digest' do
sound.path.should == "#{Rails.configuration.sounds_path}/#{sound.sha256}"
expect(sound.path)
.to eq "#{Rails.configuration.sounds_path}/#{sound.sha256}"
end
end
@@ -23,15 +24,15 @@ describe Sound do
let (:file) { FactoryGirl.attributes_for(:sound)[:file] }
it 'saves the file SHA256 digest' do
sound.sha256.should == Digest::SHA256.file(file.path).hexdigest
expect(sound.sha256).to eq Digest::SHA256.file(file.path).hexdigest
end
it 'copies the file to #path' do
File.read(sound.path).should == file.read
expect(File.read(sound.path)).to eq file.read
end
it 'saves the file MIME type' do
sound.mime_type.should == 'audio/mpeg'
expect(sound.mime_type).to eq 'audio/mpeg'
end
end
end

View File

@@ -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})
allow(track).to receive(:sounds) { sounds }
expect(sounds).to receive(:build).with({file: file})
track.file = file
end
end
@@ -40,7 +40,7 @@ describe Track do
end
it 'returns a sound' do
track.sound.should be_a(Sound)
expect(track.sound).to be_a Sound
end
end
end
@@ -48,7 +48,7 @@ describe Track do
describe '#sound?' do
context 'without any sound' do
it 'returns false' do
track.sound?.should be_false
expect(track.sound?).to be false
end
end
@@ -58,7 +58,7 @@ describe Track do
end
it 'returns true' do
track.sound?.should be_true
expect(track.sound?).to be true
end
end
end
@@ -67,7 +67,7 @@ describe Track 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')
Track.latest.should == [track2, track1]
expect(Track.latest).to eq [track2, track1]
end
end
end

View File

@@ -30,20 +30,20 @@ describe User do
describe '#password=' do
it 'stores a bcrypt hash of the password in password_hash' do
BCrypt::Password.new(user.password_hash).should == user.password
expect(BCrypt::Password.new(user.password_hash)).to eq user.password
end
end
describe '#authenticate?' do
context 'with a valid password' do
it 'returns true' do
user.authenticate?(user.password).should be_true
expect(user.authenticate?(user.password)).to be true
end
end
context 'with an invalid password' do
it 'returns false' do
user.authenticate?(user.password + '_INVALID').should be_false
expect(user.authenticate?(user.password + '_INVALID')).to be false
end
end
end