Skip to content

Commit 4127bf7

Browse files
Support ruby 3.0.2 (#197)
* Resolve compatability with ruby-3.0.2
1 parent 7cc88aa commit 4127bf7

7 files changed

Lines changed: 36 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Changed
9+
- Upgrade and set ruby-3.0.2 as default.
10+
[cyberark/conjur-api-ruby#197](https://github.com/cyberark/conjur-api-ruby/pull/197)
811

912
## [5.3.5] - 2021-05-04
1013

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source 'https://rubygems.org'
22

3-
#ruby=ruby-2.7
3+
#ruby=ruby-3.0
44
#ruby-gemset=conjur-api
55

66
# Specify your gem's dependencies in conjur-api.gemspec

Jenkinsfile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pipeline {
2626
}
2727
}
2828

29-
stage('Test 2.5') {
29+
stage('Test Ruby 2.5') {
3030
environment {
3131
RUBY_VERSION = '2.5'
3232
}
@@ -43,7 +43,7 @@ pipeline {
4343
}
4444
}
4545

46-
stage('Test 2.6') {
46+
stage('Test Ruby 2.6') {
4747
environment {
4848
RUBY_VERSION = '2.6'
4949
}
@@ -60,7 +60,7 @@ pipeline {
6060
}
6161
}
6262

63-
stage('Test 2.7') {
63+
stage('Test Ruby 2.7') {
6464
environment {
6565
RUBY_VERSION = '2.7'
6666
}
@@ -77,6 +77,22 @@ pipeline {
7777
}
7878
}
7979

80+
stage('Test Ruby 3.0') {
81+
environment {
82+
RUBY_VERSION = '3.0'
83+
}
84+
steps {
85+
sh("./test.sh")
86+
}
87+
post {
88+
always {
89+
junit 'spec/reports/*.xml'
90+
junit 'features/reports/*.xml'
91+
junit 'features_v4/reports/*.xml'
92+
}
93+
}
94+
}
95+
8096
stage('Submit Coverage Report'){
8197
steps{
8298
sh 'ci/submit-coverage'

conjur-api.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Gem::Specification.new do |gem|
2222
gem.executables -= %w{parse-changelog.sh}
2323

2424
gem.add_dependency 'rest-client'
25-
gem.add_dependency 'activesupport'
25+
gem.add_dependency 'activesupport', '>= 4.2'
26+
gem.add_dependency 'addressable', '~> 2.8.0'
2627

2728
gem.add_development_dependency 'rake', '>= 12.3.3'
2829
gem.add_development_dependency 'rspec', '~> 3'

lib/conjur/escape.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ def path_or_query_escape(str)
8080
return "false" unless str
8181
str = str.id if str.respond_to?(:id)
8282
# Leave colons and forward slashes alone
83-
require 'uri'
84-
pattern = URI::PATTERN::UNRESERVED + ":\\/@"
85-
URI.escape(str.to_s, Regexp.new("[^#{pattern}]"))
83+
require 'addressable/uri'
84+
Addressable::URI.encode(str.to_s)
8685
end
8786
end
8887

spec/api_spec.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,26 @@
44
describe Conjur::API do
55

66
let(:account) { 'api-spec-acount' }
7+
let(:remote_ip) { nil }
78
before { allow(Conjur.configuration).to receive_messages account: account }
89

910
shared_context "logged in", logged_in: true do
1011
let(:login) { "bob" }
1112
let(:token) { { 'data' => login, 'timestamp' => Time.now.to_s } }
12-
let(:remote_ip) { nil }
13-
let(:api_args) { [ token, { remote_ip: remote_ip } ] }
14-
subject(:api) { Conjur::API.new_from_token(*api_args) }
13+
subject(:api) { Conjur::API.new_from_token(token, remote_ip: remote_ip) }
1514
end
1615

1716
shared_context "logged in with an API key", logged_in: :api_key do
1817
include_context "logged in"
1918
let(:api_key) { "theapikey" }
20-
let(:api_args) { [ login, api_key, { remote_ip: remote_ip, account: account } ] }
21-
subject(:api) { Conjur::API.new_from_key(*api_args) }
19+
subject(:api) { Conjur::API.new_from_key(login, api_key, account: account ,remote_ip: remote_ip) }
2220
end
2321

2422
shared_context "logged in with a token file", logged_in: :token_file do
2523
include FakeFS::SpecHelpers
2624
include_context "logged in"
2725
let(:token_file) { "token_file" }
28-
let(:api_args) { [ token_file, { remote_ip: remote_ip } ] }
29-
subject(:api) { Conjur::API.new_from_token_file(*api_args) }
26+
subject(:api) { Conjur::API.new_from_token_file(token_file, remote_ip: remote_ip) }
3027
end
3128

3229
def time_travel delta

test.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -e
22

3-
: "${RUBY_VERSION=2.7}"
3+
: "${RUBY_VERSION=3.0}"
44
# My local RUBY_VERSION is set to ruby-#.#.# so this allows running locally.
55
RUBY_VERSION="$(cut -d '-' -f 2 <<< "$RUBY_VERSION")"
66

@@ -15,6 +15,10 @@ trap finish EXIT
1515

1616

1717
function main() {
18+
if ! docker info >/dev/null 2>&1; then
19+
echo "Docker does not seem to be running, run it first and retry"
20+
exit 1
21+
fi
1822
# Generate reports folders locally
1923
mkdir -p spec/reports features/reports features_v4/reports
2024

0 commit comments

Comments
 (0)