summaryrefslogtreecommitdiff
path: root/spec/controllers/api/sessions_controller_spec.rb
blob: c7575d1acb0eb74c869ab068904c2c64a5b4acf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'rails_helper'

describe Api::SessionsController do
  describe "#create" do
    let(:user) { create(:user, password: 'password') }

    it 'returns a JSON Web Token' do
      post :create, params: { username: user.username, password: 'password' }

      json = JSON.parse(response.body)
      expect(json['authentication_token']).to be_present
      expect(json['username']).to eql(user.username)
    end
  end
end