Files
Dalan/spec/lib/barong/jwt_spec.rb
2026-08-13 19:56:46 +03:30

17 lines
438 B
Ruby

# frozen_string_literal: true
require_dependency 'barong/jwt'
describe Barong::JWT do
let(:key) { OpenSSL::PKey::RSA.generate(2048) }
it 'should encode payload with claims' do
codec = Barong::JWT.new(key: key)
token = codec.encode({hello: 'world'})
decoded = ::JWT.decode(token, key.public_key,
true, { algorithm: 'RS256' })
expect(decoded.first.fetch('hello')).to eq('world')
end
end