Implement tracks/{show,listen}
This commit is contained in:
17
spec/controllers/tracks_controller_spec.rb
Normal file
17
spec/controllers/tracks_controller_spec.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe TracksController do
|
||||
def valid_attributes
|
||||
{
|
||||
:name => 'Mega song'
|
||||
}
|
||||
end
|
||||
|
||||
describe 'GET show' do
|
||||
it 'assigns the requested track as @track' do
|
||||
track = Track.create! valid_attributes
|
||||
get :show, :id => track.id.to_s
|
||||
assigns[:track].should == track
|
||||
end
|
||||
end
|
||||
end
|
18
spec/models/track_spec.rb
Normal file
18
spec/models/track_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Track do
|
||||
subject { track }
|
||||
let(:track) { Track.new :name => 'Mega song' }
|
||||
|
||||
context 'with valid attributes' do
|
||||
it { should be_valid }
|
||||
end
|
||||
|
||||
context 'when name empty' do
|
||||
before do
|
||||
track.name = ''
|
||||
end
|
||||
|
||||
it { should_not be_valid }
|
||||
end
|
||||
end
|
30
spec/views/tracks/show.html.haml_spec.rb
Normal file
30
spec/views/tracks/show.html.haml_spec.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'tracks/show.html.haml' do
|
||||
let(:track) do
|
||||
mock_model('Track', :name => 'Mega song')
|
||||
end
|
||||
|
||||
before do
|
||||
assign :track, track
|
||||
end
|
||||
|
||||
it 'displays the name of the track' do
|
||||
render
|
||||
rendered.should have_selector('h1', :text => 'Mega song')
|
||||
end
|
||||
|
||||
context 'audio tag' do
|
||||
it 'provides an audio stream for the track' do
|
||||
render
|
||||
rendered.should have_selector('audio[src]')
|
||||
end
|
||||
|
||||
it 'displays a text fallback for UA without support' do
|
||||
render
|
||||
rendered.should have_selector('audio',
|
||||
:text => 'Your browser does not support the audio element'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user