Files
old-holivud2/spec/controllers/api/profiles_controller_spec.rb

30 lines
697 B
Ruby
Raw Permalink Normal View History

2020-05-31 22:38:19 +02:00
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::ProfilesController, type: :controller do
let(:current_user) { create(:user) }
describe '#show' do
it 'responds with profile info for the current user' do
sign_in_to_api(current_user)
get :show
expect(response).to be_successful
expect(response_body_data).to include('id' => current_user.to_param, 'type' => 'user')
expect(response_body_data_attributes).to include('email' => current_user.email)
end
end
private
def response_body_data
JSON.parse(response.body).dig('data')
end
def response_body_data_attributes
response_body_data.dig('attributes')
end
end