Created
October 8, 2015 12:27
-
-
Save helioalb/1dc3e74189ef758c7100 to your computer and use it in GitHub Desktop.
Sugestões para rspec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RSpec.describe UsersController, type: :controller do | |
| describe 'GET #show' do | |
| before | |
| get :show, id: user_id | |
| end | |
| context 'when user exists' do | |
| let(:user_id) { create(:user).id } | |
| it 'return success (200) status code' do | |
| expect(response).to be_success | |
| end | |
| it 'returns the correct user' do | |
| expect(JSON.parse(response.body)['id']).to eq user.id | |
| end | |
| end | |
| context 'when user does not exists' do | |
| let(:user_id) { 'not existent' } | |
| it 'return not found (400) status code' do | |
| expect(response).to be_not_found | |
| end | |
| it 'returns the not found message' do | |
| expect(JSON.parse(response.body)['errors']).to inclue 'User not found' | |
| end | |
| end | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mais uma