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

@ -23,14 +23,14 @@ describe API::ApplicationController do
it 'sets Access-Control-Allow-Methods header' do
options :index
response.headers['Access-Control-Allow-Methods'].should ==
'GET, POST, PUT, DELETE'
expect(response.headers['Access-Control-Allow-Methods'])
.to eq 'GET, POST, PUT, DELETE'
end
it 'sets Access-Control-Allow-Methods header' do
options :index
response.headers['Access-Control-Allow-Headers'].should ==
'Content-Type, Content-Length, X-Requested-With'
expect(response.headers['Access-Control-Allow-Headers'])
.to eq 'Content-Type, Content-Length, X-Requested-With'
end
end
@ -43,8 +43,8 @@ describe API::ApplicationController do
it 'sets Access-Control-Allow-Origin header' do
get :index
response.headers['Access-Control-Allow-Origin']
.should == request.headers['Origin']
expect(response.headers['Access-Control-Allow-Origin'])
.to eq request.headers['Origin']
end
end
end

View File

@ -21,15 +21,15 @@ describe API::PlaylistsController do
end
it 'lists all playlists' do
do_get.should have(2).items
expect(do_get).to have(2).items
end
it 'lists playlists with their id' do
do_get.each { |t| t.keys.should include 'id' }
do_get.each { |t| expect(t.keys).to include 'id' }
end
it 'lists playlists with their name' do
do_get.each { |t| t.keys.should include 'name' }
do_get.each { |t| expect(t.keys).to include 'name' }
end
end
@ -48,7 +48,7 @@ describe API::PlaylistsController do
it 'assigns the playlist' do
do_create
assigns[:playlist].should be_a Playlist
expect(assigns[:playlist]).to be_a Playlist
end
end
end

View File

@ -17,31 +17,31 @@ describe API::SessionsController do
end
it 'signs the user in' do
controller.current_user.should == user
expect(controller.current_user).to eq user
end
it 'assigns the user' do
assigns[:user].should == user
expect(assigns[:user]).to eq user
end
end
[:email, :password].each do |attr|
context "with invalid credentials (#{attr})" do
before do
user.stub(attr => user.send(attr) + '_INVALID')
allow(user).to receive(attr).and_return(user.send(attr) + '_INVALID')
do_create
end
it 'returns a not found response' do
response.should be_not_found
expect(response).to be_not_found
end
it 'returns an empty body' do
response.body.should be_empty
expect(response.body).to be_empty
end
it 'assigns no user' do
assigns[:user].should be_nil
expect(assigns[:user]).to be_nil
end
end
end

View File

@ -21,19 +21,19 @@ describe API::TracksController do
end
it 'lists all tracks' do
do_get.should have(2).items
expect(do_get).to have(2).items
end
it 'lists tracks with their id' do
do_get.each { |p| p.should include 'id' }
do_get.each { |p| expect(p).to include 'id' }
end
it 'lists tracks with their name' do
do_get.each { |p| p.should include 'name' }
do_get.each { |p| expect(p).to include 'name' }
end
it 'lists tracks with sound URL' do
do_get.each { |p| p.should include 'sound_url' }
do_get.each { |p| expect(p).to include 'sound_url' }
end
end
end

View File

@ -6,7 +6,7 @@ describe ApplicationController do
describe '#current_user=' do
it 'stores the user id in the session as :user_id' do
controller.current_user = user
session[:user_id].should == user.id
expect(session[:user_id]).to eq user.id
end
end
@ -14,7 +14,7 @@ describe ApplicationController do
context 'when session[:user_id] is set' do
it 'returns the User instance from the session' do
session[:user_id] = user.id
controller.current_user.should == user
expect(controller.current_user).to eq user
end
end
end

View File

@ -11,14 +11,14 @@ describe HomeController do
it 'assigns all playlists as @playlists' do
playlist = FactoryGirl.create(:playlist)
get :index
assigns[:playlists].should == [playlist]
expect(assigns[:playlists]).to eq [playlist]
end
it 'assigns latest tracks as @tracks' 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')
get :index
assigns[:tracks].should == Track.latest
expect(assigns[:tracks]).to eq Track.latest
end
end
end

View File

@ -11,14 +11,14 @@ describe PlaylistsController do
it 'assigns all playlists as @playlists' do
playlist = FactoryGirl.create(:playlist)
get :index
assigns[:playlists].should == [playlist]
expect(assigns[:playlists]).to eq [playlist]
end
end
describe 'GET new' do
it 'assigns a new playlist as @playlist' do
get :new
assigns[:playlist].should be_a_new(Playlist)
expect(assigns[:playlist]).to be_a_new Playlist
end
end
@ -26,7 +26,7 @@ describe PlaylistsController do
it 'assigns the requested playlist as @playlist' do
playlist = FactoryGirl.create(:playlist)
get :edit, id: playlist.id.to_s
assigns[:playlist].should == playlist
expect(assigns[:playlist]).to eq playlist
end
end
@ -44,21 +44,21 @@ describe PlaylistsController do
it 'redirects to the playlists index' do
do_create
response.should redirect_to(action: 'index')
expect(response).to redirect_to action: 'index'
end
end
context 'whith invalid params' do
before { Playlist.any_instance.stub(:save).and_return(false) }
before { allow_any_instance_of(Playlist).to receive(:save) { false } }
it 'assigns the playlist as @playlist' do
do_create
assigns[:playlist].should be_a_new(Playlist)
expect(assigns[:playlist]).to be_a_new Playlist
end
it 'renders the new template' do
do_create
response.should render_template('new')
expect(response).to render_template 'new'
end
end
end
@ -72,28 +72,28 @@ describe PlaylistsController do
context 'whith valid params' do
it 'updates the playlist' do
Playlist.any_instance.should_receive(:update_attributes)
.with({'name' => 'Rock'})
expect_any_instance_of(Playlist)
.to receive(:update_attributes).with({'name' => 'Rock'})
do_update
end
it 'redirects to the playlists index' do
do_update
response.should redirect_to(action: 'index')
expect(response).to redirect_to(action: 'index')
end
end
context 'with invalid params' do
before { Playlist.any_instance.stub(:save).and_return(false) }
before { allow_any_instance_of(Playlist).to receive(:save) { false } }
it 'assigns the requested playlist as @playlist' do
do_update
assigns[:playlist].should == playlist
expect(assigns[:playlist]).to eq playlist
end
it 'renders the edit template' do
do_update
response.should render_template('edit')
expect(response).to render_template 'edit'
end
end
end

View File

@ -3,7 +3,7 @@ require 'spec_helper'
describe SessionsController do
describe 'GET new' do
it 'responds successfully' do
response.should be_success
expect(response).to be_success
end
end
@ -20,24 +20,24 @@ describe SessionsController do
context 'with valid credentials' do
it 'signs the user in' do
do_create
controller.current_user.should == user
expect(controller.current_user).to eq user
end
it 'redirects to the home page' do
do_create
response.should redirect_to(:root)
expect(response).to redirect_to :root
end
end
[:email, :password].each do |attr|
context "with invalid credentials (#{attr})" do
before do
user.stub(attr => user.send(attr) + '_INVALID')
allow(user).to receive(attr).and_return(user.send(attr) + '_INVALID')
end
it 'renders the new template' do
do_create
response.should render_template('new')
expect(response).to render_template 'new'
end
end
end

View File

@ -16,12 +16,12 @@ describe SoundsController do
it 'sets the sound file content as the response body' do
do_show
response.body.should == File.read(sound.path, encoding: 'BINARY')
expect(response.body).to eq File.read(sound.path, encoding: 'BINARY')
end
it 'sets the sound mime-type as the response content-type' do
do_show
response.content_type.should == sound.mime_type
expect(response.content_type).to eq sound.mime_type
end
end
end

View File

@ -11,14 +11,14 @@ describe TracksController do
it 'assigns the requested track as @track' do
track = FactoryGirl.create(:track)
get :show, id: track.id.to_s
assigns[:track].should == track
expect(assigns[:track]).to eq track
end
end
describe 'GET new' do
it 'assigns a new track as @track' do
get :new
assigns[:track].should be_a_new(Track)
expect(assigns[:track]).to be_a_new Track
end
end
@ -41,23 +41,23 @@ describe TracksController do
it 'redirects to the track page' do
do_create
response.should redirect_to(Track.last)
expect(response).to redirect_to Track.last
end
end
context 'whith invalid params' do
before do
Track.any_instance.stub(:save).and_return(false)
allow_any_instance_of(Track).to receive(:save) { false }
end
it 'assigns the track as @track' do
do_create
assigns[:track].should be_a_new(Track)
expect(assigns[:track]).to be_a_new Track
end
it 'renders the new template' do
do_create
response.should render_template('new')
expect(response).to render_template 'new'
end
end
end

View File

@ -4,7 +4,7 @@ describe UsersController do
describe 'GET new' do
it 'assigns a new user as @user' do
get :new
assigns[:user].should be_a_new(User)
expect(assigns[:user]).to be_a_new(User)
end
end
@ -18,26 +18,26 @@ describe UsersController do
it 'signs the user in' do
post :create, user: FactoryGirl.attributes_for(:user)
controller.current_user.should_not be_nil
expect(controller.current_user).not_to be_nil
end
it 'redirects to the home page' do
post :create, user: FactoryGirl.attributes_for(:user)
response.should redirect_to(:root)
expect(response).to redirect_to :root
end
end
context 'whith invalid params' do
before { User.any_instance.stub(:save).and_return(false) }
before { allow_any_instance_of(User).to receive(:save) { false } }
it 'assigns the user as @user' do
post :create, user: {}
assigns[:user].should be_a_new(User)
expect(assigns[:user]).to be_a_new User
end
it 'renders the new template' do
post :create, user: {}
response.should render_template('new')
expect(response).to render_template 'new'
end
end
end

View File

@ -12,7 +12,7 @@ feature 'Home page' do
visit root_path
page.should have_content('Electro')
expect(page).to have_content 'Electro'
end
scenario 'displays last track added' do
@ -27,6 +27,6 @@ feature 'Home page' do
visit root_path
page.body.should match(/Mega song 2.+Mega song 1/m)
expect(page.body).to match /Mega song 2.+Mega song 1/m
end
end

View File

@ -13,7 +13,7 @@ feature 'Playlists' do
visit playlists_path
page.body.should match(/Electro.+Reggae/m)
expect(page.body).to match /Electro.+Reggae/m
end
scenario 'creates playlist' do
@ -23,8 +23,8 @@ feature 'Playlists' do
fill_in 'Name', with: 'Electro'
click_button 'Create'
current_path.should == playlists_path
page.should have_content('Electro')
expect(current_path).to eq playlists_path
expect(page).to have_content 'Electro'
end
scenario 'edits playlist' do
@ -35,7 +35,7 @@ feature 'Playlists' do
fill_in 'Name', with: 'Rock'
click_button 'Save'
current_path.should == playlists_path
page.should have_content('Rock')
expect(current_path).to eq playlists_path
expect(page).to have_content 'Rock'
end
end

View File

@ -12,7 +12,7 @@ feature 'Tracks' do
visit track_path(track)
page.should have_content('Mega song')
expect(page).to have_content 'Mega song'
end
scenario 'creates track' do
@ -23,8 +23,8 @@ feature 'Tracks' do
attach_file 'File', File.expand_path('spec/fixtures/test.mp3')
click_button 'Upload'
current_path.should == track_path(Track.first)
page.should have_content('Mega song')
expect(current_path).to eq track_path Track.first
expect(page).to have_content 'Mega song'
end
scenario 'plays track' do
@ -32,7 +32,7 @@ feature 'Tracks' do
visit track_path(track)
page.should have_xpath "//audio[@src='#{sound_path(track.sound)}']"
expect(page).to have_xpath "//audio[@src='#{sound_path track.sound}']"
visit find('audio')[:src]
end
end

View File

@ -4,7 +4,7 @@ feature 'User sign in' do
scenario 'redirects to the home page when not signed in' do
visit root_path
current_path.should == new_session_path
expect(current_path).to eq new_session_path
end
scenario 'signs the user in' do
@ -15,6 +15,6 @@ feature 'User sign in' do
fill_in 'Password', with: user.password
click_button 'Sign in'
current_path.should == root_path
expect(current_path).to eq root_path
end
end

View File

@ -19,6 +19,6 @@ feature 'User sign up' do
scenario 'redirects to the home page' do
click_button 'Sign up'
current_path.should == root_path
expect(current_path).to eq root_path
end
end

View File

@ -13,17 +13,17 @@ feature 'API sign in' do
scenario 'signs the user in with valid credentials' do
do_create
response.should be_success
(JSON response.body).should include 'id'
expect(response).to be_success
expect(JSON response.body).to include 'id'
end
[:email, :password].each do |attr|
scenario "rejects authentication with invalid credentials (#{attr})" do
user.stub(attr => user.send(attr) + '_INVALID')
allow(user).to receive(attr).and_return(user.send(attr) + '_INVALID')
do_create
response.should be_not_found
response.body.should be_empty
expect(response).to be_not_found
expect(response.body).to be_empty
end
end
end

View File

@ -22,12 +22,12 @@ feature 'API cross origin request' do
{ 'Origin' => origin }
)
response.headers['Access-Control-Allow-Origin'].should == origin
response.headers['Access-Control-Allow-Credentials'].should == 'true'
response.headers['Access-Control-Allow-Methods'].should ==
'GET, POST, PUT, DELETE'
response.headers['Access-Control-Allow-Headers'].should ==
'Content-Type, Content-Length, X-Requested-With'
expect(response.headers['Access-Control-Allow-Origin']).to eq origin
expect(response.headers['Access-Control-Allow-Credentials']).to eq 'true'
expect(response.headers['Access-Control-Allow-Methods'])
.to eq 'GET, POST, PUT, DELETE'
expect(response.headers['Access-Control-Allow-Headers'])
.to eq 'Content-Type, Content-Length, X-Requested-With'
end
scenario 'basic request' do
@ -36,15 +36,16 @@ feature 'API cross origin request' do
'Origin' => origin
}
response.headers['Access-Control-Allow-Origin'].should == origin
response.headers['Access-Control-Allow-Credentials'].should == 'true'
response.headers['Access-Control-Expose-Headers'].should == 'Content-Length'
expect(response.headers['Access-Control-Allow-Origin']).to eq origin
expect(response.headers['Access-Control-Allow-Credentials']).to eq 'true'
expect(response.headers['Access-Control-Expose-Headers'])
.to eq 'Content-Length'
end
scenario 'request without origin' do
# FIXME: replace with a more stable/generic action
get api_playlists_path(format: :json)
response.headers['Access-Control-Allow-Origin'].should == ''
expect(response.headers['Access-Control-Allow-Origin']).to eq ''
end
end

View File

@ -16,7 +16,7 @@ feature 'API playlists' do
json = JSON response.body
json['id'].should be_a Fixnum
json['name'].should == playlist[:name]
expect(json['id']).to be_a Fixnum
expect(json['name']).to eq playlist[:name]
end
end

View File

@ -13,7 +13,7 @@ feature 'API tracks' do
get api_tracks_path, format: :json
response.body.should == [
expect(response.body).to eq [
{
id: track_1.id,
name: 'Track 1',

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

View File

@ -2,10 +2,11 @@ require 'spec_helper'
describe '/api OPTIONS requests routing' do
it 'routes to API::ApplicationController#cor_preflight' do
{ options: '/api/some_route' }.should route_to(
controller: 'api/application',
action: 'cor_preflight',
all: 'some_route'
)
expect({ options: '/api/some_route' })
.to route_to(
controller: 'api/application',
action: 'cor_preflight',
all: 'some_route'
)
end
end

View File

@ -12,16 +12,16 @@ describe 'home/index' do
it 'displays a list of playlists' do
render
rendered.should have_selector('ul>li', text: 'Electro')
expect(rendered).to have_selector 'ul>li', text: 'Electro'
end
it 'displays a link to add a track' do
render
rendered.should have_selector('a', text: 'Add a track')
expect(rendered).to have_selector 'a', text: 'Add a track'
end
it 'displays a list of tracks' do
render
rendered.should have_selector('ul>li', text: 'Mega song')
expect(rendered).to have_selector 'ul>li', text: 'Mega song'
end
end

View File

@ -11,16 +11,16 @@ describe 'playlists/edit' do
it 'renders a form to edit a playlist' do
render
rendered.should have_selector("form[method=post][action='#{playlists_path}']")
rendered.should have_selector('input[type=submit]')
expect(rendered).to have_selector("form[method=post][action='#{playlists_path}']")
expect(rendered).to have_selector('input[type=submit]')
end
it 'renders a text field with a label for the playlists name' do
playlist.stub(name: 'Electro')
allow(playlist).to receive(: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')
expect(rendered)
.to have_selector "input[type=text][name='playlist[name]'][value=Electro]"
expect(rendered)
.to have_selector 'label[for=playlist_name]', text: 'Name'
end
end

View File

@ -9,16 +9,16 @@ describe 'playlists/index' do
it 'displays a list of playlists' do
render
rendered.should have_selector('ul>li', text: 'Electro')
expect(rendered).to have_selector 'ul>li', text: 'Electro'
end
it 'displays a link to create a new playlist' do
render
rendered.should have_selector('a', text: 'Create playlist')
expect(rendered).to have_selector 'a', text: 'Create playlist'
end
it 'displays playlists as links' do
render
rendered.should have_selector('a', text: 'Electro')
expect(rendered).to have_selector 'a', text: 'Electro'
end
end

View File

@ -11,18 +11,18 @@ describe 'playlists/new' do
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]')
expect(rendered)
.to have_selector "form[method=post][action='#{playlists_path}']"
expect(rendered)
.to have_selector 'input[type=submit]'
end
it 'renders a text field with a label for the playlists name' do
playlist.stub(name: 'Electro')
allow(playlist).to receive(: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')
expect(rendered)
.to have_selector "input[type=text][name='playlist[name]'][value=Electro]"
expect(rendered)
.to have_selector 'label[for=playlist_name]', text: 'Name'
end
end

View File

@ -3,33 +3,28 @@ require 'spec_helper'
describe 'sessions/new' do
it 'renders a form to sign in' do
render
rendered.should have_selector(
"form[method=post][action='#{sessions_path}']"
)
rendered.should have_selector('input[type=submit]')
expect(rendered)
.to have_selector "form[method=post][action='#{sessions_path}']"
expect(rendered).to have_selector 'input[type=submit]'
end
it 'renders a text field with a label for the mail address' do
render
rendered.should have_selector("input[type=text][name='session[email]']")
rendered.should have_selector('label[for=session_email]', text: 'Email')
expect(rendered).to have_selector("input[type=text][name='session[email]']")
expect(rendered).to have_selector('label[for=session_email]', text: 'Email')
end
it 'renders a password field with a label for the password' do
render
rendered.should have_selector(
"input[type=password][name='session[password]']"
)
rendered.should have_selector(
'label[for=session_password]', text: 'Password'
)
expect(rendered)
.to have_selector "input[type=password][name='session[password]']"
expect(rendered)
.to have_selector 'label[for=session_password]', text: 'Password'
end
it 'renders a link to the sign in page' do
render
rendered.should have_selector(
"a[href='#{new_user_path}']",
text: 'Sign up'
)
expect(rendered)
.to have_selector "a[href='#{new_user_path}']", text: 'Sign up'
end
end

View File

@ -11,23 +11,24 @@ describe 'tracks/new' do
it 'renders a form to create a track' do
render
rendered.should have_selector("form[method=post][action='#{tracks_path}']")
rendered.should have_selector('input[type=submit]')
expect(rendered)
.to have_selector "form[method=post][action='#{tracks_path}']"
expect(rendered).to have_selector 'input[type=submit]'
end
it 'renders a text field with a label for the playlists name' do
track.stub(name: 'Mega song')
allow(track).to receive(:name) { 'Mega song' }
render
rendered.should have_selector(
"input[type=text][name='track[name]'][value='Mega song']"
)
rendered.should have_selector('label[for=track_name]', text: 'Name')
expect(rendered)
.to have_selector "input[type=text][name='track[name]'][value='Mega song']"
expect(rendered)
.to have_selector('label[for=track_name]', text: 'Name')
end
it 'renders a file field with a label for the tracks file' do
render
rendered.should have_selector("form[enctype='multipart/form-data']")
rendered.should have_selector("input[type=file][name='track[file]']")
rendered.should have_selector('label[for=track_file]', text: 'File')
expect(rendered).to have_selector("form[enctype='multipart/form-data']")
expect(rendered).to have_selector("input[type=file][name='track[file]']")
expect(rendered).to have_selector('label[for=track_file]', text: 'File')
end
end

View File

@ -9,7 +9,7 @@ describe 'tracks/show' do
it 'displays the name of the track' do
render
rendered.should have_selector('h1', text: 'Mega song')
expect(rendered).to have_selector 'h1', text: 'Mega song'
end
context 'when track has a sound' do
@ -17,22 +17,22 @@ describe 'tracks/show' do
it 'provides an audio stream for the track' do
render
rendered.should have_selector('audio[src]')
expect(rendered).to have_selector 'audio[src]'
end
it 'provides controls' do
render
rendered.should have_selector('audio[controls]')
expect(rendered).to have_selector 'audio[controls]'
end
it 'has autoplay activated' do
render
rendered.should have_selector('audio[autoplay]')
expect(rendered).to have_selector 'audio[autoplay]'
end
it 'displays a text fallback for UA without support' do
render
rendered.should have_selector(
expect(rendered).to have_selector(
'audio',
text: 'Your browser does not support the audio element'
)

View File

@ -11,36 +11,31 @@ describe 'users/new' do
it 'renders a form to sign up' do
render
rendered.should have_selector("form[method=post][action='#{users_path}']")
rendered.should have_selector('input[type=submit]')
expect(rendered)
.to have_selector "form[method=post][action='#{users_path}']"
expect(rendered).to have_selector 'input[type=submit]'
end
it 'renders a text field with a label for the mail address' do
render
rendered.should have_selector(
"input[type=text][name='user[email]']"
)
rendered.should have_selector(
'label[for=user_email]', text: 'Email'
)
expect(rendered).to have_selector "input[type=text][name='user[email]']"
expect(rendered)
.to have_selector 'label[for=user_email]', text: 'Email'
end
it 'renders a password field with a label for the password' do
render
rendered.should have_selector(
"input[type=password][name='user[password]']"
)
rendered.should have_selector(
'label[for=user_password]', text: 'Password'
)
expect(rendered)
.to have_selector "input[type=password][name='user[password]']"
expect(rendered)
.to have_selector 'label[for=user_password]', text: 'Password'
end
it 'renders a password field with a label for the password confirmation' do
render
rendered.should have_selector(
"input[type=password][name='user[password_confirmation]']"
)
rendered.should have_selector(
expect(rendered)
.to have_selector "input[type=password][name='user[password_confirmation]']"
expect(rendered).to have_selector(
'label[for=user_password_confirmation]',
text: 'Password confirmation'
)
@ -53,7 +48,7 @@ describe 'users/new' do
new_user.save
assign :user, new_user
render
rendered.should have_content 'Email has already been taken'
expect(rendered).to have_content 'Email has already been taken'
end
end
end