Add basic playlists management
* Index of playlists * Create a new playlist * Basic playlist model with mandatory name
This commit is contained in:
22
spec/views/playlists/index.html.haml_spec.rb
Normal file
22
spec/views/playlists/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'playlists/index.html.haml' do
|
||||
before do
|
||||
assign :playlists, [
|
||||
double('Playlist', :name => 'Foo'),
|
||||
double('Playlist', :name => 'Bar')
|
||||
]
|
||||
end
|
||||
|
||||
it 'displays a list of playlists' do
|
||||
render
|
||||
rendered.should have_selector('ul>li', :count => 2)
|
||||
rendered.should have_selector('ul>li', :text => 'Foo')
|
||||
rendered.should have_selector('ul>li+li', :text => 'Bar')
|
||||
end
|
||||
|
||||
it 'displays a link to create a new playlist' do
|
||||
render
|
||||
rendered.should have_selector('a', :text => 'Create playlist')
|
||||
end
|
||||
end
|
26
spec/views/playlists/new.html.haml_spec.rb
Normal file
26
spec/views/playlists/new.html.haml_spec.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'playlists/new.html.haml' do
|
||||
let(:playlist) do
|
||||
mock_model('Playlist').as_new_record.as_null_object
|
||||
end
|
||||
|
||||
before do
|
||||
assign :playlist, playlist
|
||||
end
|
||||
|
||||
it 'renders a form to create a playlist' do
|
||||
render
|
||||
rendered.should have_selector("form[method=post][action='#{playlists_path}']")
|
||||
rendered.should have_selector('input[type=submit]')
|
||||
end
|
||||
|
||||
it 'renders a text field with a label for the playlists name' do
|
||||
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')
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user