Update specs to new rspec syntax
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user