|
5 | 5 | let!(:user) { create :user }
|
6 | 6 |
|
7 | 7 | context 'When receive matching username and password' do
|
8 |
| - before do |
9 |
| - post '/auth/login', params: { username: user.username, password: user.password } |
10 |
| - end |
| 8 | + before { post '/auth/login', params: { username: user.username, password: user.password } } |
11 | 9 |
|
12 |
| - it 'responds :created' do |
13 |
| - expect(response).to have_http_status(:ok) |
14 |
| - end |
| 10 | + it { expect(response).to have_http_status(:ok) } |
15 | 11 |
|
16 | 12 | it "responds with user's username" do
|
17 | 13 | json_response = JSON.parse(response.body)
|
|
33 | 29 |
|
34 | 30 | context 'When receive NOT matching username and password' do
|
35 | 31 | context 'when invalid username and password' do
|
36 |
| - before do |
37 |
| - post '/auth/login', params: { username: 'invalid username', password: 'invalid passowrd' } |
38 |
| - end |
39 |
| - it 'responds :unauthorized' do |
40 |
| - expect(response).to have_http_status(:unauthorized) |
41 |
| - end |
| 32 | + before { post '/auth/login', params: { username: 'invalid username', password: 'invalid passowrd' } } |
| 33 | + |
| 34 | + it { expect(response).to have_http_status(:unauthorized) } |
42 | 35 | end
|
43 | 36 |
|
44 | 37 | context 'when valid username and invalid password' do
|
45 |
| - before do |
46 |
| - post '/auth/login', params: { username: user.username, password: 'invalid passowrd' } |
47 |
| - end |
48 |
| - it 'responds :unauthorized' do |
49 |
| - expect(response).to have_http_status(:unauthorized) |
50 |
| - end |
| 38 | + before { post '/auth/login', params: { username: user.username, password: 'invalid passowrd' } } |
| 39 | + |
| 40 | + it { expect(response).to have_http_status(:unauthorized) } |
51 | 41 | end
|
52 | 42 |
|
53 | 43 | context 'when invalid username and valid password' do
|
54 |
| - before do |
55 |
| - post '/auth/login', params: { username: 'invalid username', password: user.password } |
56 |
| - end |
57 |
| - it 'responds :unauthorized' do |
58 |
| - expect(response).to have_http_status(:unauthorized) |
59 |
| - end |
| 44 | + before { post '/auth/login', params: { username: 'invalid username', password: user.password } } |
| 45 | + |
| 46 | + it { expect(response).to have_http_status(:unauthorized) } |
60 | 47 | end
|
61 | 48 | end
|
62 | 49 | end
|
|
0 commit comments