Bundle shoulda and use ActiveModel matchers in specs

This commit is contained in:
Thibault Jouan
2011-09-21 00:07:19 +00:00
parent 72f800397d
commit 6af1540640
7 changed files with 27 additions and 84 deletions

View File

@@ -1,34 +1,11 @@
require 'spec_helper'
describe Playlist do
subject { playlist }
subject { playlist }
let(:playlist) { Factory.build(:playlist) }
context 'with valid attributes' do
it { should be_valid }
end
context 'when name empty' do
before do
playlist.name = ''
end
it { should_not be_valid }
end
context 'without user_id' do
before do
playlist.user = nil
end
it { should_not be_valid }
end
describe '#user' do
it 'returns the user who created the playlist' do
user = Factory.create(:user)
playlist = user.playlists.build(Factory.attributes_for(:playlist))
playlist.user.should == user
end
end
it { should be_valid }
it { should belong_to :user }
it { should validate_presence_of :user }
it { should validate_presence_of :name }
end