demarches-normaliennes/spec/controllers/api_controller_spec.rb

29 lines
763 B
Ruby
Raw Normal View History

2015-12-21 17:51:49 +01:00
require 'spec_helper'
describe APIController, type: :controller do
controller(APIController) do
def show
render json: {}, satus: 200
end
def index
render json: {}, satus: 200
end
end
describe 'GET index' do
context 'when token is missing' do
subject { get :index }
it { expect(subject.status).to eq(401) }
end
context 'when token does not exist' do
let(:token) { 'invalid_token' }
subject { get :index, token: token }
it { expect(subject.status).to eq(401) }
end
context 'when token exist' do
let(:administrateur) { create(:administrateur) }
subject { get :index, token: administrateur.api_token }
it { expect(subject.status).to eq(200) }
end
end
end