Skip to content

Instantly share code, notes, and snippets.

@v-kolesnikov
Created January 5, 2019 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save v-kolesnikov/b125f7f5e8e2daff11bb9033092b422a to your computer and use it in GitHub Desktop.
Save v-kolesnikov/b125f7f5e8e2daff11bb9033092b422a to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require 'bundler/inline'
gemfile(true) do
gem 'jwt'
gem 'rspec'
end
require 'jwt'
require 'openssl'
require 'rspec/autorun'
RSpec.describe do
subject(:cookie) do
{
access_token: json_web_token,
refresh_token: json_web_token
}.to_json
end
let(:json_web_token) do
JWT.encode(
payload, key, 'RS256',
iat: Time.now,
exp: Time.now.to_i + (_120_minutes = 2 * 60 * 60)
)
end
let(:payload) do
{ user_id: SecureRandom.uuid }
end
let(:key) do
OpenSSL::PKey::RSA.new(_size = 2048)
end
it { expect(cookie.size).to eql 2 }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment