Skip to content

Commit

Permalink
Update Oktakit.new convenience method for Ruby 3
Browse files Browse the repository at this point in the history
Add spec to ensure it is working

Hash and keyword coercion was deprecated in Ruby 3 w/ warnings in Ruby 2.7.
See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ for additional information or my post detailing it in https://medium.com/building-rigup/hash-and-keyword-coercion-213425f69719
  • Loading branch information
agrberg committed Oct 9, 2021
1 parent b2caa14 commit 1cb45ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/oktakit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'oktakit/client'

module Oktakit
def self.new(*args)
Client.new(*args)
def self.new(**args)
Client.new(**args)
end
end
7 changes: 7 additions & 0 deletions spec/oktakit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
expect(Oktakit::VERSION).not_to(be(nil))
end

describe '.new' do
it 'creates a client with the passed in keyword arguments' do
client = Oktakit.new(token: test_okta_token, organization: 'okta-test')
expect(client.api_endpoint).to(eq('https://okta-test.okta.com/api/v1'))
end
end

describe 'client' do
it 'has a default API endpoint' do
client = Oktakit::Client.new(token: test_okta_token, organization: 'okta-test')
Expand Down

0 comments on commit 1cb45ea

Please sign in to comment.