Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Ruby 3.2 and 3.3 #4

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.6', '2.7', '3.0', '3.1']
ruby-version: ['3.0', '3.1', '3.2', '3.3']

steps:
- uses: actions/checkout@v2
Expand Down
10 changes: 7 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
require:
- rubocop-rake
- rubocop-rspec

AllCops:
NewCops: enable
TargetRubyVersion: 2.6
TargetRubyVersion: 3.0

Metrics/BlockLength:
Exclude:
- 'spec/**/*'

Metrics/LineLength:
IgnoredPatterns: ['\A +#']
RSpec/NestedGroups:
Max: 4
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@

source 'http://rubygems.org'
gemspec

gem 'rake', '~> 12.3', '>= 12.3.3'
gem 'rspec', '~> 3'
gem 'rubocop', '~> 1.26'
gem 'rubocop-rake', '~> 0.6'
gem 'rubocop-rspec', '~> 2.9'
gem 'timecop', '~> 0'
9 changes: 1 addition & 8 deletions snuffleupagus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.description = 'Simple auth token generator/validator'
s.summary = "snuffleupagus-#{s.version}"
s.required_rubygems_version = '> 1.3.6'
s.required_ruby_version = ['>= 2.6.0', '< 3.2.0']
s.required_ruby_version = ['>= 3.0.0', '< 3.4.0']

# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
# delete this section to allow pushing this gem to any host.
Expand All @@ -22,13 +22,6 @@ Gem::Specification.new do |s|
s.metadata['allowed_push_host'] = 'https://rubygems.org'
s.metadata['rubygems_mfa_required'] = 'true'

s.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
s.add_development_dependency 'rspec', '~> 3'
s.add_development_dependency 'rubocop', '~> 1.26'
s.add_development_dependency 'rubocop-rake', '~> 0.6'
s.add_development_dependency 'rubocop-rspec', '~> 2.9'
s.add_development_dependency 'timecop', '~> 0'

s.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
s.executables = `git ls-files`.split("\n").map do |f|
f =~ %r{^bin/(.*)} ? Regexp.last_match(1) : nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
require 'timecop'

describe Snuffleupagus::AuthToken do
let(:snuffy) { Snuffleupagus::AuthToken.new('sup3r4w3s0m3p4ssw0rd') }
let(:snuffy) { described_class.new('sup3r4w3s0m3p4ssw0rd') }

describe '#create_token' do
subject { snuffy.create_token context: 'my-context' }
subject(:create_token) { snuffy.create_token context: 'my-context' }

it { is_expected.to be_a String }
it { expect(subject.length).to eq 96 }
it { expect(create_token.length).to eq 96 }
it { is_expected.to match(/\A[a-f0-9]{96}\z/) }
end

describe '#token_valid?' do
subject { snuffy.token_valid?(token: token, context: 'my-context') }
subject(:token_valid?) { snuffy.token_valid?(token: token, context: 'my-context') }

context 'with a valid token' do
let(:token) { snuffy.create_token context: 'my-context' }
Expand Down Expand Up @@ -47,31 +47,31 @@
it { is_expected.to be_falsey }
end

context 'testing expired tokens' do
context 'with an expired token' do
let(:token) { snuffy.create_token context: 'my-context' }

before { token } # pre-load the token
after { Timecop.return }

context 'just inside the time difference (expired token)' do
context 'when just inside the time difference (expired token)' do
before { Timecop.freeze Time.now - 119 }

it { is_expected.to be_truthy }
end

context 'just outside the time difference (expired token)' do
context 'when just outside the time difference (expired token)' do
before { Timecop.freeze Time.now - 120 }

it { is_expected.to be_falsey }
end

context 'just inside the time difference (future token)' do
context 'when just inside the time difference (future token)' do
before { Timecop.freeze Time.now + 119 }

it { is_expected.to be_truthy }
end

context 'just outside the time difference (future token)' do
context 'when just outside the time difference (future token)' do
before { Timecop.freeze Time.now + 120 }

it { is_expected.to be_falsey }
Expand Down
Loading